diff --git a/src/represent/representer.cpp b/src/represent/representer.cpp index 269ac3f..ab6efaa 100644 --- a/src/represent/representer.cpp +++ b/src/represent/representer.cpp @@ -26,8 +26,10 @@ void Representer::updateSettings(const Settings &settings) { mode_ = settings.resultShowType; font_ = QFont(settings.fontFamily, settings.fontSize); + showRecognized_ = settings.showRecognized; + showCaptured_ = settings.showCaptured; if (widget_) - widget_->changeFont(font_); + widget_->updateSettings(font_, showRecognized_, showCaptured_); } void Representer::showTooltip(const TaskPtr &task) @@ -40,7 +42,7 @@ void Representer::showWidget(const TaskPtr &task) { if (!widget_) { widget_ = std::make_unique(); - widget_->changeFont(font_); + widget_->updateSettings(font_, showRecognized_, showCaptured_); } widget_->show(task); diff --git a/src/represent/representer.h b/src/represent/representer.h index 2998eee..ded9aac 100644 --- a/src/represent/representer.h +++ b/src/represent/representer.h @@ -25,4 +25,6 @@ private: std::unique_ptr widget_; ResultMode mode_; QFont font_; + bool showRecognized_{true}; + bool showCaptured_{true}; }; diff --git a/src/represent/resultwidget.cpp b/src/represent/resultwidget.cpp index b2f07d5..2eec5f1 100644 --- a/src/represent/resultwidget.cpp +++ b/src/represent/resultwidget.cpp @@ -66,6 +66,9 @@ void ResultWidget::show(const TaskPtr &task) const auto gotTranslation = !task->translated.isEmpty(); translated_->setVisible(gotTranslation); + const auto mustShowRecognized = showRecognized_ || !gotTranslation; + recognized_->setVisible(mustShowRecognized); + show(); adjustSize(); @@ -83,11 +86,15 @@ void ResultWidget::show(const TaskPtr &task) activateWindow(); } -void ResultWidget::changeFont(const QFont &font) +void ResultWidget::updateSettings(const QFont &font, bool showRecognized, + bool showCaptured) { - // because of stylesheet + // explicit font change because of stylesheet recognized_->setFont(font); translated_->setFont(font); + + image_->setVisible(showCaptured); + showRecognized_ = showRecognized; } bool ResultWidget::eventFilter(QObject *watched, QEvent *event) diff --git a/src/represent/resultwidget.h b/src/represent/resultwidget.h index a360f01..a5b5768 100644 --- a/src/represent/resultwidget.h +++ b/src/represent/resultwidget.h @@ -14,7 +14,8 @@ public: void show(const TaskPtr& task); using QWidget::show; - void changeFont(const QFont& font); + void updateSettings(const QFont& font, bool showRecognized, + bool showCaptured); bool eventFilter(QObject* watched, QEvent* event) override; @@ -22,4 +23,5 @@ private: QLabel* image_; QLabel* recognized_; QLabel* translated_; + bool showRecognized_{true}; }; diff --git a/src/settings.cpp b/src/settings.cpp index 23ac93c..fbec81c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -42,6 +42,8 @@ const QString qs_translators = "translators"; const QString qs_representationGroup = "Representation"; const QString qs_fontFamily = "fontFamily"; const QString qs_fontSize = "fontSize"; +const QString qs_showRecognized = "showRecognized"; +const QString qs_showCaptured = "showCaptured"; QString shuffle(const QString& source) { @@ -183,6 +185,8 @@ void Settings::save() const settings.setValue(qs_fontFamily, fontFamily); settings.setValue(qs_fontSize, fontSize); + settings.setValue(qs_showRecognized, showRecognized); + settings.setValue(qs_showCaptured, showCaptured); settings.endGroup(); @@ -268,6 +272,8 @@ void Settings::load() fontFamily = settings.value(qs_fontFamily, fontFamily).toString(); fontSize = std::clamp(settings.value(qs_fontSize, fontSize).toInt(), 6, 24); + showRecognized = settings.value(qs_showRecognized, showRecognized).toBool(); + showCaptured = settings.value(qs_showCaptured, showCaptured).toBool(); settings.endGroup(); } diff --git a/src/settings.h b/src/settings.h index 3758c48..3741fb0 100644 --- a/src/settings.h +++ b/src/settings.h @@ -65,6 +65,8 @@ public: ResultMode resultShowType{ResultMode::Widget}; // dialog QString fontFamily; int fontSize{11}; + bool showRecognized{true}; + bool showCaptured{true}; private: bool isPortable_{false}; diff --git a/src/settingseditor.cpp b/src/settingseditor.cpp index 81790e0..0d097ec 100644 --- a/src/settingseditor.cpp +++ b/src/settingseditor.cpp @@ -138,6 +138,8 @@ Settings SettingsEditor::settings() const ui->trayRadio->isChecked() ? ResultMode::Tooltip : ResultMode::Widget; settings.fontFamily = ui->resultFont->currentFont().family(); settings.fontSize = ui->resultFontSize->value(); + settings.showRecognized = ui->showRecognized->isChecked(); + settings.showCaptured = ui->showCaptured->isChecked(); settings.autoUpdateIntervalDays = ui->autoUpdateInterval->value(); @@ -187,6 +189,8 @@ void SettingsEditor::setSettings(const Settings &settings) ui->dialogRadio->setChecked(settings.resultShowType == ResultMode::Widget); ui->resultFont->setCurrentFont(QFont(settings.fontFamily)); ui->resultFontSize->setValue(settings.fontSize); + ui->showRecognized->setChecked(settings.showRecognized); + ui->showCaptured->setChecked(settings.showCaptured); ui->autoUpdateInterval->setValue(settings.autoUpdateIntervalDays); } diff --git a/src/settingseditor.ui b/src/settingseditor.ui index 1be7d9e..c361989 100644 --- a/src/settingseditor.ui +++ b/src/settingseditor.ui @@ -429,13 +429,6 @@ Result window - - - - Font: - - - @@ -449,6 +442,13 @@ + + + + Font: + + + @@ -456,6 +456,20 @@ + + + + Show image + + + + + + + Show recognized + + +