Add ability to show translator from menu and close it

This commit is contained in:
Gres 2020-04-01 19:54:54 +03:00
parent 9ea8974108
commit 4dd2d2ddb6
6 changed files with 15 additions and 12 deletions

View File

@ -278,6 +278,12 @@ void Manager::showLast()
representer_->showLast(); representer_->showLast();
} }
void Manager::showTranslator()
{
SOFT_ASSERT(translator_, return );
translator_->show();
}
void Manager::copyLastToClipboard() void Manager::copyLastToClipboard()
{ {
SOFT_ASSERT(representer_, return ); SOFT_ASSERT(representer_, return );

View File

@ -22,6 +22,7 @@ public:
void repeatCapture(); void repeatCapture();
void captureLocked(); void captureLocked();
void showLast(); void showLast();
void showTranslator();
void settings(); void settings();
void copyLastToClipboard(); void copyLastToClipboard();
void about(); void about();

View File

@ -20,6 +20,8 @@ SettingsEditor::SettingsEditor(Manager &manager, update::Loader &updater)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->translatorDebugCheck->hide();
connect(ui->buttonBox, &QDialogButtonBox::clicked, // connect(ui->buttonBox, &QDialogButtonBox::clicked, //
this, &SettingsEditor::handleButtonBoxClicked); this, &SettingsEditor::handleButtonBoxClicked);

View File

@ -138,12 +138,6 @@ void Translator::updateSettings()
} }
for (const auto &script : loaded) createPage(script.first, script.second); for (const auto &script : loaded) createPage(script.first, script.second);
if (settings_.debugMode) {
show();
} else {
hide();
}
} }
void Translator::createPage(const QString &scriptName, void Translator::createPage(const QString &scriptName,
@ -311,8 +305,3 @@ void Translator::timerEvent(QTimerEvent * /*event*/)
{ {
processQueue(); processQueue();
} }
void Translator::closeEvent(QCloseEvent *event)
{
event->ignore();
}

View File

@ -26,7 +26,6 @@ public:
protected: protected:
void timerEvent(QTimerEvent *event) override; void timerEvent(QTimerEvent *event) override;
void closeEvent(QCloseEvent *event) override;
private: private:
WebPage *currentPage() const; WebPage *currentPage() const;

View File

@ -219,6 +219,12 @@ QMenu *TrayIcon::contextMenu()
} }
} }
{
auto action = menu->addAction(tr("Show translator"));
connect(action, &QAction::triggered, //
this, [this] { manager_.showTranslator(); });
}
{ {
settingsAction_ = menu->addAction(tr("Settings")); settingsAction_ = menu->addAction(tr("Settings"));
connect(settingsAction_, &QAction::triggered, // connect(settingsAction_, &QAction::triggered, //