2020-02-21 00:45:53 +07:00
|
|
|
#include "representer.h"
|
|
|
|
|
#include "manager.h"
|
|
|
|
|
#include "resultwidget.h"
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "task.h"
|
|
|
|
|
#include "trayicon.h"
|
|
|
|
|
|
2020-03-21 17:03:58 +07:00
|
|
|
Representer::Representer(Manager &manager, TrayIcon &tray,
|
|
|
|
|
const Settings &settings)
|
2020-02-21 00:45:53 +07:00
|
|
|
: manager_(manager)
|
|
|
|
|
, tray_(tray)
|
2020-03-21 17:03:58 +07:00
|
|
|
, settings_(settings)
|
2020-02-21 00:45:53 +07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Representer::~Representer() = default;
|
|
|
|
|
|
|
|
|
|
void Representer::represent(const TaskPtr &task)
|
|
|
|
|
{
|
2020-03-21 17:03:58 +07:00
|
|
|
if (settings_.resultShowType == ResultMode::Tooltip)
|
2020-02-21 00:45:53 +07:00
|
|
|
showTooltip(task);
|
|
|
|
|
else
|
|
|
|
|
showWidget(task);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-21 17:03:58 +07:00
|
|
|
void Representer::updateSettings()
|
2020-02-21 00:45:53 +07:00
|
|
|
{
|
2020-03-20 01:47:46 +07:00
|
|
|
if (widget_)
|
2020-03-21 17:03:58 +07:00
|
|
|
widget_->updateSettings();
|
2020-02-21 00:45:53 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Representer::showTooltip(const TaskPtr &task)
|
|
|
|
|
{
|
|
|
|
|
auto message = task->recognized + " - " + task->translated;
|
|
|
|
|
tray_.showInformation(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Representer::showWidget(const TaskPtr &task)
|
|
|
|
|
{
|
2020-03-21 17:03:58 +07:00
|
|
|
if (!widget_)
|
|
|
|
|
widget_ = std::make_unique<ResultWidget>(settings_);
|
2020-02-21 00:45:53 +07:00
|
|
|
|
|
|
|
|
widget_->show(task);
|
|
|
|
|
}
|