From 6d571984716d51ad4dccc782273f6270e80aebaa Mon Sep 17 00:00:00 2001 From: Gres Date: Tue, 29 Sep 2015 15:37:47 +0300 Subject: [PATCH] Better support of only OCR mode (cosmetic). --- Manager.cpp | 17 ++++++++++------- ResultDialog.cpp | 3 +++ ResultDialog.ui | 26 ++++++++++++++++++++++---- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Manager.cpp b/Manager.cpp index 45da884..8cdd67e 100644 --- a/Manager.cpp +++ b/Manager.cpp @@ -80,10 +80,10 @@ Manager::Manager (QObject *parent) : QMenu * Manager::trayContextMenu () { QMenu *menu = new QMenu (); captureAction_ = menu->addAction (tr ("Захват"), this, SLOT (capture ())); - QMenu *translateMenu = menu->addMenu (tr ("Перевод")); - repeatAction_ = translateMenu->addAction (tr ("Повторить"), this, + QMenu *translateMenu = menu->addMenu (tr ("Результат")); + repeatAction_ = translateMenu->addAction (tr ("Показать"), this, SLOT (showLast ())); - clipboardAction_ = translateMenu->addAction (tr ("Скопировать"), this, + clipboardAction_ = translateMenu->addAction (tr ("В буфер"), this, SLOT (copyLastToClipboard ())); menu->addAction (tr ("Настройки"), this, SLOT (settings ())); menu->addAction (tr ("О программе"), this, SLOT (about ())); @@ -215,10 +215,13 @@ void Manager::showLast () { void Manager::copyLastToClipboard () { if (lastItem_.isValid ()) { QClipboard *clipboard = QApplication::clipboard (); - QString message = lastItem_.recognized + " - " + lastItem_.translated; + QString message = lastItem_.recognized; + if (!lastItem_.translated.isEmpty ()) { + message += " - " + lastItem_.translated; + } clipboard->setText (message); - trayIcon_->showMessage (tr ("Перевод"), - tr ("Последний перевод был скопирован в буфер обмена."), + trayIcon_->showMessage (tr ("Результат"), + tr ("Последний результат был скопирован в буфер обмена."), QSystemTrayIcon::Information); } } @@ -231,7 +234,7 @@ void Manager::showResult (ProcessingItem item) { } else { QString message = item.recognized + " - " + item.translated; - trayIcon_->showMessage (tr ("Перевод"), message, QSystemTrayIcon::Information); + trayIcon_->showMessage (tr ("Результат"), message, QSystemTrayIcon::Information); } } diff --git a/ResultDialog.cpp b/ResultDialog.cpp index 479263c..caeb1bc 100644 --- a/ResultDialog.cpp +++ b/ResultDialog.cpp @@ -32,6 +32,9 @@ void ResultDialog::showResult (ProcessingItem item) { ui->sourceLabel->setPixmap (item.source); ui->recognizeLabel->setText (item.recognized); ui->translateLabel->setText (item.translated); + bool gotTranslation = !item.translated.isEmpty (); + ui->translateLabel->setVisible (gotTranslation); + ui->translateLine->setVisible (gotTranslation); show (); adjustSize (); diff --git a/ResultDialog.ui b/ResultDialog.ui index 92329f9..f7c8044 100644 --- a/ResultDialog.ui +++ b/ResultDialog.ui @@ -14,7 +14,16 @@ Результат - + + 0 + + + 0 + + + 0 + + 0 @@ -29,7 +38,16 @@ QFrame::Plain - + + 0 + + + 0 + + + 0 + + 0 @@ -49,7 +67,7 @@ - + Qt::Horizontal @@ -69,7 +87,7 @@ - + Qt::Horizontal