Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Better support of only OCR mode (cosmetic).
  • Loading branch information
OneMoreGres committed Sep 29, 2015
1 parent bf6eea7 commit 6d57198
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
17 changes: 10 additions & 7 deletions Manager.cpp
Expand Up @@ -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 ()));
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions ResultDialog.cpp
Expand Up @@ -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 ();
Expand Down
26 changes: 22 additions & 4 deletions ResultDialog.ui
Expand Up @@ -14,7 +14,16 @@
<string>Результат</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
Expand All @@ -29,7 +38,16 @@
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
Expand All @@ -49,7 +67,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="Line" name="line_2">
<widget class="Line" name="recognizeLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -69,7 +87,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="Line" name="line">
<widget class="Line" name="translateLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down

0 comments on commit 6d57198

Please sign in to comment.