Use only one settings instance
This commit is contained in:
parent
0da289e16f
commit
705bae636d
@ -6,8 +6,9 @@
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
Capturer::Capturer(Manager &manager)
|
||||
Capturer::Capturer(Manager &manager, const Settings &settings)
|
||||
: manager_(manager)
|
||||
, settings_(settings)
|
||||
{
|
||||
}
|
||||
|
||||
@ -21,12 +22,8 @@ void Capturer::repeatCapture()
|
||||
showOverlays(false);
|
||||
}
|
||||
|
||||
void Capturer::updateSettings(const Settings &settings)
|
||||
void Capturer::updateSettings()
|
||||
{
|
||||
sourceLanguage_ = settings.sourceLanguage;
|
||||
targetLanguage_ = settings.targetLanguage;
|
||||
translators_ = settings.translators;
|
||||
doTranslation_ = settings.doTranslation;
|
||||
}
|
||||
|
||||
void Capturer::captured(const TaskPtr &task)
|
||||
@ -34,10 +31,10 @@ void Capturer::captured(const TaskPtr &task)
|
||||
hideOverlays();
|
||||
// TODO respect more overlay's options
|
||||
// TODO process modifiers
|
||||
task->translators = translators_;
|
||||
task->sourceLanguage = sourceLanguage_;
|
||||
if (doTranslation_)
|
||||
task->targetLanguage = targetLanguage_;
|
||||
task->translators = settings_.translators;
|
||||
task->sourceLanguage = settings_.sourceLanguage;
|
||||
if (settings_.doTranslation)
|
||||
task->targetLanguage = settings_.targetLanguage;
|
||||
manager_.captured(task);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
#include "stfwd.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class CaptureOverlay;
|
||||
@ -11,11 +9,11 @@ class CaptureOverlay;
|
||||
class Capturer
|
||||
{
|
||||
public:
|
||||
explicit Capturer(Manager &manager);
|
||||
Capturer(Manager &manager, const Settings &settings);
|
||||
|
||||
void capture();
|
||||
void repeatCapture();
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
|
||||
void captured(const TaskPtr &task);
|
||||
void canceled();
|
||||
@ -25,10 +23,6 @@ private:
|
||||
void hideOverlays();
|
||||
|
||||
Manager &manager_;
|
||||
const Settings &settings_;
|
||||
std::vector<CaptureOverlay *> overlays_;
|
||||
|
||||
LanguageId sourceLanguage_;
|
||||
LanguageId targetLanguage_;
|
||||
QStringList translators_;
|
||||
bool doTranslation_{false};
|
||||
};
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "corrector.h"
|
||||
#include "debug.h"
|
||||
#include "manager.h"
|
||||
#include "settings.h"
|
||||
#include "task.h"
|
||||
|
||||
Corrector::Corrector(Manager &manager)
|
||||
Corrector::Corrector(Manager &manager, const Settings &settings)
|
||||
: manager_(manager)
|
||||
, settings_(settings)
|
||||
{
|
||||
}
|
||||
|
||||
@ -18,15 +20,14 @@ void Corrector::correct(const TaskPtr &task)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userSubstitutions_.empty())
|
||||
if (!settings_.userSubstitutions.empty())
|
||||
task->corrected = substituteUser(task->recognized, task->sourceLanguage);
|
||||
|
||||
manager_.corrected(task);
|
||||
}
|
||||
|
||||
void Corrector::updateSettings(const Settings &settings)
|
||||
void Corrector::updateSettings()
|
||||
{
|
||||
userSubstitutions_ = settings.userSubstitutions;
|
||||
}
|
||||
|
||||
QString Corrector::substituteUser(const QString &source,
|
||||
@ -34,8 +35,8 @@ QString Corrector::substituteUser(const QString &source,
|
||||
{
|
||||
auto result = source;
|
||||
|
||||
const auto range = userSubstitutions_.equal_range(language);
|
||||
if (range.first == userSubstitutions_.cend())
|
||||
const auto range = settings_.userSubstitutions.equal_range(language);
|
||||
if (range.first == settings_.userSubstitutions.cend())
|
||||
return result;
|
||||
|
||||
while (true) {
|
||||
|
@ -1,20 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "settings.h"
|
||||
#include "stfwd.h"
|
||||
|
||||
class Corrector
|
||||
{
|
||||
public:
|
||||
explicit Corrector(Manager &manager);
|
||||
Corrector(Manager &manager, const Settings &settings);
|
||||
|
||||
void correct(const TaskPtr &task);
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
|
||||
private:
|
||||
QString substituteUser(const QString &source,
|
||||
const LanguageId &language) const;
|
||||
|
||||
Manager &manager_;
|
||||
Substitutions userSubstitutions_;
|
||||
const Settings &settings_;
|
||||
};
|
||||
|
@ -27,22 +27,24 @@ const auto updatesUrl =
|
||||
} // namespace
|
||||
|
||||
Manager::Manager()
|
||||
: updater_(std::make_unique<update::Loader>(QUrl(updatesUrl)))
|
||||
: settings_(std::make_unique<Settings>())
|
||||
, updater_(std::make_unique<update::Loader>(QUrl(updatesUrl)))
|
||||
{
|
||||
tray_ = std::make_unique<TrayIcon>(*this);
|
||||
capturer_ = std::make_unique<Capturer>(*this);
|
||||
recognizer_ = std::make_unique<Recognizer>(*this);
|
||||
translator_ = std::make_unique<Translator>(*this);
|
||||
corrector_ = std::make_unique<Corrector>(*this);
|
||||
representer_ = std::make_unique<Representer>(*this, *tray_);
|
||||
SOFT_ASSERT(settings_, return );
|
||||
|
||||
tray_ = std::make_unique<TrayIcon>(*this, *settings_);
|
||||
capturer_ = std::make_unique<Capturer>(*this, *settings_);
|
||||
recognizer_ = std::make_unique<Recognizer>(*this, *settings_);
|
||||
translator_ = std::make_unique<Translator>(*this, *settings_);
|
||||
corrector_ = std::make_unique<Corrector>(*this, *settings_);
|
||||
representer_ = std::make_unique<Representer>(*this, *tray_, *settings_);
|
||||
|
||||
qRegisterMetaType<TaskPtr>();
|
||||
|
||||
Settings settings;
|
||||
settings.load();
|
||||
updateSettings(settings);
|
||||
settings_->load();
|
||||
updateSettings();
|
||||
|
||||
if (settings.showMessageOnStart)
|
||||
if (settings_->showMessageOnStart)
|
||||
tray_->showInformation(QObject::tr("Screen translator started"));
|
||||
|
||||
QObject::connect(updater_.get(), &update::Loader::error, //
|
||||
@ -62,33 +64,37 @@ Manager::Manager()
|
||||
|
||||
Manager::~Manager()
|
||||
{
|
||||
if (updateAutoChecker_ && updateAutoChecker_->isLastCheckDateChanged())
|
||||
Settings::saveLastUpdateCheck(updateAutoChecker_->lastCheckDate());
|
||||
SOFT_ASSERT(settings_, return );
|
||||
if (updateAutoChecker_ && updateAutoChecker_->isLastCheckDateChanged()) {
|
||||
settings_->lastUpdateCheck = updateAutoChecker_->lastCheckDate();
|
||||
settings_->saveLastUpdateCheck();
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::updateSettings(const Settings &settings)
|
||||
void Manager::updateSettings()
|
||||
{
|
||||
LTRACE() << "updateSettings";
|
||||
setupProxy(settings);
|
||||
SOFT_ASSERT(settings_, return );
|
||||
setupProxy(*settings_);
|
||||
|
||||
updater_->model()->setExpansions({
|
||||
{"$translators$", settings.translatorsDir},
|
||||
{"$tessdata$", settings.tessdataPath},
|
||||
{"$translators$", settings_->translatorsDir},
|
||||
{"$tessdata$", settings_->tessdataPath},
|
||||
});
|
||||
if (settings.autoUpdateIntervalDays > 0) {
|
||||
if (settings_->autoUpdateIntervalDays > 0) {
|
||||
updateAutoChecker_ = std::make_unique<update::AutoChecker>(*updater_);
|
||||
updateAutoChecker_->setLastCheckDate(settings.lastUpdateCheck);
|
||||
updateAutoChecker_->setCheckIntervalDays(settings.autoUpdateIntervalDays);
|
||||
updateAutoChecker_->setLastCheckDate(settings_->lastUpdateCheck);
|
||||
updateAutoChecker_->setCheckIntervalDays(settings_->autoUpdateIntervalDays);
|
||||
} else {
|
||||
updateAutoChecker_.reset();
|
||||
}
|
||||
|
||||
tray_->updateSettings(settings);
|
||||
capturer_->updateSettings(settings);
|
||||
recognizer_->updateSettings(settings);
|
||||
translator_->updateSettings(settings);
|
||||
corrector_->updateSettings(settings);
|
||||
representer_->updateSettings(settings);
|
||||
tray_->updateSettings();
|
||||
capturer_->updateSettings();
|
||||
recognizer_->updateSettings();
|
||||
translator_->updateSettings();
|
||||
corrector_->updateSettings();
|
||||
representer_->updateSettings();
|
||||
}
|
||||
|
||||
void Manager::setupProxy(const Settings &settings)
|
||||
@ -202,8 +208,10 @@ void Manager::translated(const TaskPtr &task)
|
||||
|
||||
void Manager::applySettings(const Settings &settings)
|
||||
{
|
||||
updateSettings(settings);
|
||||
settings.save();
|
||||
SOFT_ASSERT(settings_, return );
|
||||
*settings_ = settings;
|
||||
settings_->save();
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
void Manager::fatalError(const QString &text)
|
||||
@ -239,9 +247,8 @@ void Manager::settings()
|
||||
{
|
||||
SettingsEditor editor(*this, *updater_);
|
||||
|
||||
Settings settings;
|
||||
settings.load();
|
||||
editor.setSettings(settings);
|
||||
SOFT_ASSERT(settings_, return );
|
||||
editor.setSettings(*settings_);
|
||||
|
||||
tray_->blockActions(true);
|
||||
auto result = editor.exec();
|
||||
@ -252,9 +259,8 @@ void Manager::settings()
|
||||
|
||||
tray_->resetFatalError();
|
||||
|
||||
settings = editor.settings();
|
||||
settings.save();
|
||||
updateSettings(settings);
|
||||
const auto edited = editor.settings();
|
||||
applySettings(edited);
|
||||
}
|
||||
|
||||
void Manager::copyLastToClipboard()
|
||||
|
@ -27,10 +27,11 @@ public:
|
||||
void quit();
|
||||
|
||||
private:
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
void setupProxy(const Settings &settings);
|
||||
void finishTask(const TaskPtr &task);
|
||||
|
||||
std::unique_ptr<Settings> settings_;
|
||||
std::unique_ptr<TrayIcon> tray_;
|
||||
std::unique_ptr<Capturer> capturer_;
|
||||
std::unique_ptr<Recognizer> recognizer_;
|
||||
|
@ -6,8 +6,9 @@
|
||||
|
||||
#include <QThread>
|
||||
|
||||
Recognizer::Recognizer(Manager &manager)
|
||||
Recognizer::Recognizer(Manager &manager, const Settings &settings)
|
||||
: manager_(manager)
|
||||
, settings_(settings)
|
||||
, workerThread_(new QThread(this))
|
||||
{
|
||||
auto worker = new RecognizeWorker;
|
||||
@ -37,12 +38,12 @@ Recognizer::~Recognizer()
|
||||
workerThread_->terminate();
|
||||
}
|
||||
|
||||
void Recognizer::updateSettings(const Settings &settings)
|
||||
void Recognizer::updateSettings()
|
||||
{
|
||||
if (settings.tessdataPath.isEmpty()) {
|
||||
if (settings_.tessdataPath.isEmpty()) {
|
||||
manager_.fatalError(tr("Tessdata path is empty"));
|
||||
return;
|
||||
}
|
||||
|
||||
emit reset(settings.tessdataPath);
|
||||
emit reset(settings_.tessdataPath);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ class Recognizer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Recognizer(Manager &manager);
|
||||
Recognizer(Manager &manager, const Settings &settings);
|
||||
~Recognizer();
|
||||
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
|
||||
signals:
|
||||
void recognize(const TaskPtr &task);
|
||||
@ -21,5 +21,6 @@ private:
|
||||
void recognized(const TaskPtr &task);
|
||||
|
||||
Manager &manager_;
|
||||
const Settings &settings_;
|
||||
QThread *workerThread_;
|
||||
};
|
||||
|
@ -5,10 +5,11 @@
|
||||
#include "task.h"
|
||||
#include "trayicon.h"
|
||||
|
||||
Representer::Representer(Manager &manager, TrayIcon &tray)
|
||||
Representer::Representer(Manager &manager, TrayIcon &tray,
|
||||
const Settings &settings)
|
||||
: manager_(manager)
|
||||
, tray_(tray)
|
||||
, mode_{ResultMode::Widget}
|
||||
, settings_(settings)
|
||||
{
|
||||
}
|
||||
|
||||
@ -16,20 +17,16 @@ Representer::~Representer() = default;
|
||||
|
||||
void Representer::represent(const TaskPtr &task)
|
||||
{
|
||||
if (mode_ == ResultMode::Tooltip)
|
||||
if (settings_.resultShowType == ResultMode::Tooltip)
|
||||
showTooltip(task);
|
||||
else
|
||||
showWidget(task);
|
||||
}
|
||||
|
||||
void Representer::updateSettings(const Settings &settings)
|
||||
void Representer::updateSettings()
|
||||
{
|
||||
mode_ = settings.resultShowType;
|
||||
font_ = QFont(settings.fontFamily, settings.fontSize);
|
||||
showRecognized_ = settings.showRecognized;
|
||||
showCaptured_ = settings.showCaptured;
|
||||
if (widget_)
|
||||
widget_->updateSettings(font_, showRecognized_, showCaptured_);
|
||||
widget_->updateSettings();
|
||||
}
|
||||
|
||||
void Representer::showTooltip(const TaskPtr &task)
|
||||
@ -40,10 +37,8 @@ void Representer::showTooltip(const TaskPtr &task)
|
||||
|
||||
void Representer::showWidget(const TaskPtr &task)
|
||||
{
|
||||
if (!widget_) {
|
||||
widget_ = std::make_unique<ResultWidget>();
|
||||
widget_->updateSettings(font_, showRecognized_, showCaptured_);
|
||||
}
|
||||
if (!widget_)
|
||||
widget_ = std::make_unique<ResultWidget>(settings_);
|
||||
|
||||
widget_->show(task);
|
||||
}
|
||||
|
@ -2,19 +2,17 @@
|
||||
|
||||
#include "stfwd.h"
|
||||
|
||||
#include <QFont>
|
||||
|
||||
enum class ResultMode;
|
||||
class ResultWidget;
|
||||
|
||||
class Representer
|
||||
{
|
||||
public:
|
||||
Representer(Manager &manager, TrayIcon &tray);
|
||||
Representer(Manager &manager, TrayIcon &tray, const Settings &settings);
|
||||
~Representer();
|
||||
|
||||
void represent(const TaskPtr &task);
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
|
||||
private:
|
||||
void showTooltip(const TaskPtr &task);
|
||||
@ -22,9 +20,6 @@ private:
|
||||
|
||||
Manager &manager_;
|
||||
TrayIcon &tray_;
|
||||
const Settings &settings_;
|
||||
std::unique_ptr<ResultWidget> widget_;
|
||||
ResultMode mode_;
|
||||
QFont font_;
|
||||
bool showRecognized_{true};
|
||||
bool showCaptured_{true};
|
||||
};
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "resultwidget.h"
|
||||
#include "debug.h"
|
||||
#include "settings.h"
|
||||
#include "task.h"
|
||||
|
||||
#include <QApplication>
|
||||
@ -8,8 +9,9 @@
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
|
||||
ResultWidget::ResultWidget(QWidget *parent)
|
||||
ResultWidget::ResultWidget(const Settings &settings, QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, settings_(settings)
|
||||
, image_(new QLabel(this))
|
||||
, recognized_(new QLabel(this))
|
||||
, translated_(new QLabel(this))
|
||||
@ -66,7 +68,7 @@ void ResultWidget::show(const TaskPtr &task)
|
||||
const auto gotTranslation = !task->translated.isEmpty();
|
||||
translated_->setVisible(gotTranslation);
|
||||
|
||||
const auto mustShowRecognized = showRecognized_ || !gotTranslation;
|
||||
const auto mustShowRecognized = settings_.showRecognized || !gotTranslation;
|
||||
recognized_->setVisible(mustShowRecognized);
|
||||
|
||||
show();
|
||||
@ -86,15 +88,14 @@ void ResultWidget::show(const TaskPtr &task)
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void ResultWidget::updateSettings(const QFont &font, bool showRecognized,
|
||||
bool showCaptured)
|
||||
void ResultWidget::updateSettings()
|
||||
{
|
||||
// explicit font change because of stylesheet
|
||||
QFont font(settings_.fontFamily, settings_.fontSize);
|
||||
recognized_->setFont(font);
|
||||
translated_->setFont(font);
|
||||
|
||||
image_->setVisible(showCaptured);
|
||||
showRecognized_ = showRecognized;
|
||||
image_->setVisible(settings_.showCaptured);
|
||||
}
|
||||
|
||||
bool ResultWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
|
@ -10,18 +10,17 @@ class ResultWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResultWidget(QWidget* parent = nullptr);
|
||||
explicit ResultWidget(const Settings& settings, QWidget* parent = nullptr);
|
||||
|
||||
void show(const TaskPtr& task);
|
||||
using QWidget::show;
|
||||
void updateSettings(const QFont& font, bool showRecognized,
|
||||
bool showCaptured);
|
||||
void updateSettings();
|
||||
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
private:
|
||||
const Settings& settings_;
|
||||
QLabel* image_;
|
||||
QLabel* recognized_;
|
||||
QLabel* translated_;
|
||||
bool showRecognized_{true};
|
||||
};
|
||||
|
@ -286,7 +286,7 @@ void Settings::load()
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void Settings::saveLastUpdateCheck(const QDateTime& dt)
|
||||
void Settings::saveLastUpdateCheck()
|
||||
{
|
||||
std::unique_ptr<QSettings> ptr;
|
||||
if (QFile::exists(iniFileName)) {
|
||||
@ -297,7 +297,7 @@ void Settings::saveLastUpdateCheck(const QDateTime& dt)
|
||||
auto& settings = *ptr;
|
||||
|
||||
settings.beginGroup(qs_guiGroup);
|
||||
settings.setValue(qs_lastUpdateCheck, dt);
|
||||
settings.setValue(qs_lastUpdateCheck, lastUpdateCheck);
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
void save() const;
|
||||
void load();
|
||||
|
||||
static void saveLastUpdateCheck(const QDateTime& dt);
|
||||
void saveLastUpdateCheck();
|
||||
|
||||
bool isPortable() const;
|
||||
void setPortable(bool isPortable);
|
||||
|
@ -32,8 +32,9 @@ static std::map<QString, QString> loadScripts(const QString &dir,
|
||||
return result;
|
||||
}
|
||||
|
||||
Translator::Translator(Manager &manager)
|
||||
Translator::Translator(Manager &manager, const Settings &settings)
|
||||
: manager_(manager)
|
||||
, settings_(settings)
|
||||
, view_(nullptr)
|
||||
, url_(new QLineEdit(this))
|
||||
, loadImages_(
|
||||
@ -106,7 +107,7 @@ void Translator::translate(const TaskPtr &task)
|
||||
processQueue();
|
||||
}
|
||||
|
||||
void Translator::updateSettings(const Settings &settings)
|
||||
void Translator::updateSettings()
|
||||
{
|
||||
view_->setPage(nullptr);
|
||||
pages_.clear();
|
||||
@ -121,11 +122,11 @@ void Translator::updateSettings(const Settings &settings)
|
||||
tabs_->blockSignals(false);
|
||||
|
||||
const auto loaded =
|
||||
loadScripts(settings.translatorsDir, settings.translators);
|
||||
loadScripts(settings_.translatorsDir, settings_.translators);
|
||||
if (loaded.empty()) {
|
||||
manager_.fatalError(
|
||||
tr("No translators loaded from %1 (named %2)")
|
||||
.arg(settings.translatorsDir, settings.translators.join(", ")));
|
||||
.arg(settings_.translatorsDir, settings_.translators.join(", ")));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,8 +138,8 @@ void Translator::updateSettings(const Settings &settings)
|
||||
SOFT_ASSERT(pageIt.second, continue);
|
||||
|
||||
const auto &page = pageIt.first->second;
|
||||
page->setIgnoreSslErrors(settings.ignoreSslErrors);
|
||||
page->setTimeout(settings.translationTimeout);
|
||||
page->setIgnoreSslErrors(settings_.ignoreSslErrors);
|
||||
page->setTimeout(settings_.translationTimeout);
|
||||
|
||||
auto log = new QTextEdit(tabs_);
|
||||
tabs_->addTab(log, scriptName);
|
||||
@ -152,7 +153,7 @@ void Translator::updateSettings(const Settings &settings)
|
||||
log->document()->setMaximumBlockCount(1000);
|
||||
}
|
||||
|
||||
if (settings.debugMode) {
|
||||
if (settings_.debugMode) {
|
||||
show();
|
||||
} else {
|
||||
hide();
|
||||
|
@ -14,11 +14,11 @@ class Translator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Translator(Manager &manager);
|
||||
Translator(Manager &manager, const Settings &settings);
|
||||
~Translator();
|
||||
|
||||
void translate(const TaskPtr &task);
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
void finish(const TaskPtr &task);
|
||||
|
||||
protected:
|
||||
@ -34,6 +34,7 @@ private:
|
||||
void markTranslated(const TaskPtr &task);
|
||||
|
||||
Manager &manager_;
|
||||
const Settings &settings_;
|
||||
QWebEngineView *view_;
|
||||
QLineEdit *url_;
|
||||
QAction *loadImages_;
|
||||
|
@ -7,8 +7,9 @@
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
|
||||
TrayIcon::TrayIcon(Manager &manager)
|
||||
TrayIcon::TrayIcon(Manager &manager, const Settings &settings)
|
||||
: manager_(manager)
|
||||
, settings_(settings)
|
||||
, tray_(std::make_unique<QSystemTrayIcon>())
|
||||
, iconUpdateTimer_(std::make_unique<QTimer>())
|
||||
{
|
||||
@ -29,17 +30,18 @@ TrayIcon::TrayIcon(Manager &manager)
|
||||
|
||||
TrayIcon::~TrayIcon() = default;
|
||||
|
||||
void TrayIcon::updateSettings(const Settings &settings)
|
||||
void TrayIcon::updateSettings()
|
||||
{
|
||||
QStringList failedActions;
|
||||
if (!GlobalAction::update(captureAction_, settings.captureHotkey))
|
||||
failedActions << settings.captureHotkey;
|
||||
if (!GlobalAction::update(repeatCaptureAction_, settings.repeatCaptureHotkey))
|
||||
failedActions << settings.repeatCaptureHotkey;
|
||||
if (!GlobalAction::update(showLastAction_, settings.showLastHotkey))
|
||||
failedActions << settings.showLastHotkey;
|
||||
if (!GlobalAction::update(clipboardAction_, settings.clipboardHotkey))
|
||||
failedActions << settings.clipboardHotkey;
|
||||
if (!GlobalAction::update(captureAction_, settings_.captureHotkey))
|
||||
failedActions << settings_.captureHotkey;
|
||||
if (!GlobalAction::update(repeatCaptureAction_,
|
||||
settings_.repeatCaptureHotkey))
|
||||
failedActions << settings_.repeatCaptureHotkey;
|
||||
if (!GlobalAction::update(showLastAction_, settings_.showLastHotkey))
|
||||
failedActions << settings_.showLastHotkey;
|
||||
if (!GlobalAction::update(clipboardAction_, settings_.clipboardHotkey))
|
||||
failedActions << settings_.clipboardHotkey;
|
||||
|
||||
if (!failedActions.isEmpty()) {
|
||||
showError(tr("Failed to register global shortcuts:\n%1")
|
||||
|
@ -10,10 +10,10 @@ class TrayIcon : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrayIcon(Manager &manager);
|
||||
TrayIcon(Manager &manager, const Settings &settings);
|
||||
~TrayIcon();
|
||||
|
||||
void updateSettings(const Settings &settings);
|
||||
void updateSettings();
|
||||
|
||||
void blockActions(bool block);
|
||||
void setTaskActionsEnabled(bool isEnabled);
|
||||
@ -36,6 +36,7 @@ private:
|
||||
void updateActions();
|
||||
|
||||
Manager &manager_;
|
||||
const Settings &settings_;
|
||||
std::unique_ptr<QSystemTrayIcon> tray_;
|
||||
|
||||
QAction *captureAction_{nullptr};
|
||||
|
Loading…
Reference in New Issue
Block a user