Added only OCR mode (without translation).
This commit is contained in:
parent
097405038b
commit
bf6eea7f8e
25
Manager.cpp
25
Manager.cpp
@ -35,6 +35,8 @@ Manager::Manager (QObject *parent) :
|
||||
Recognizer *recognizer = new Recognizer;
|
||||
connect (this, SIGNAL (selected (ProcessingItem)),
|
||||
recognizer, SLOT (recognize (ProcessingItem)));
|
||||
connect (recognizer, SIGNAL (recognized (ProcessingItem)),
|
||||
SIGNAL (recognized (ProcessingItem)));
|
||||
connect (recognizer, SIGNAL (error (QString)),
|
||||
SLOT (showError (QString)));
|
||||
connect (this, SIGNAL (settingsEdited ()),
|
||||
@ -48,8 +50,10 @@ Manager::Manager (QObject *parent) :
|
||||
|
||||
// Translator
|
||||
Translator *translator = new Translator;
|
||||
connect (recognizer, SIGNAL (recognized (ProcessingItem)),
|
||||
connect (this, SIGNAL (requestTranslate (ProcessingItem)),
|
||||
translator, SLOT (translate (ProcessingItem)));
|
||||
connect (translator, SIGNAL (translated (ProcessingItem)),
|
||||
SLOT (showResult (ProcessingItem)));
|
||||
connect (translator, SIGNAL (error (QString)),
|
||||
SLOT (showError (QString)));
|
||||
connect (this, SIGNAL (settingsEdited ()),
|
||||
@ -60,9 +64,6 @@ Manager::Manager (QObject *parent) :
|
||||
translatorThread->start ();
|
||||
connect (qApp, SIGNAL (aboutToQuit ()), translatorThread, SLOT (quit ()));
|
||||
|
||||
connect (translator, SIGNAL (translated (ProcessingItem)),
|
||||
SLOT (showResult (ProcessingItem)));
|
||||
|
||||
connect (this, SIGNAL (settingsEdited ()), this, SLOT (applySettings ()));
|
||||
resultDialog_->setWindowIcon (trayIcon_->icon ());
|
||||
|
||||
@ -118,9 +119,25 @@ void Manager::applySettings () {
|
||||
|
||||
// Depends on SettingsEditor button indexes. 1==dialog
|
||||
useResultDialog_ = GET (resultShowType).toBool ();
|
||||
settings.endGroup ();
|
||||
|
||||
Q_CHECK_PTR (dictionary_);
|
||||
dictionary_->updateAvailableOcrLanguages ();
|
||||
|
||||
settings.beginGroup (settings_names::translationGroup);
|
||||
bool doTranslation = GET (doTranslation).toBool ();
|
||||
if (doTranslation) {
|
||||
disconnect (this, SIGNAL (recognized (ProcessingItem)),
|
||||
this, SLOT (showResult (ProcessingItem)));
|
||||
connect (this, SIGNAL (recognized (ProcessingItem)),
|
||||
this, SIGNAL (requestTranslate (ProcessingItem)), Qt::UniqueConnection);
|
||||
}
|
||||
else {
|
||||
disconnect (this, SIGNAL (recognized (ProcessingItem)),
|
||||
this, SIGNAL (requestTranslate (ProcessingItem)));
|
||||
connect (this, SIGNAL (recognized (ProcessingItem)),
|
||||
this, SLOT (showResult (ProcessingItem)), Qt::UniqueConnection);
|
||||
}
|
||||
#undef GET
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ class Manager : public QObject {
|
||||
|
||||
signals:
|
||||
void selected (ProcessingItem item);
|
||||
void recognized (ProcessingItem item);
|
||||
void requestTranslate (ProcessingItem item);
|
||||
void closeSelections ();
|
||||
void settingsEdited ();
|
||||
|
||||
|
@ -5,6 +5,5 @@ bool ProcessingItem::isValid () const {
|
||||
valid &= (!screenPos.isNull ());
|
||||
valid &= (!source.isNull ());
|
||||
valid &= (!recognized.isEmpty ());
|
||||
valid &= (!translated.isEmpty ());
|
||||
return valid;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ namespace settings_names {
|
||||
|
||||
//! Translation
|
||||
const QString translationGroup = "Translation";
|
||||
const QString doTranslation = "doTranslation";
|
||||
const QString sourceLanguage = "source_language";
|
||||
const QString translationLanguage = "translation_language";
|
||||
|
||||
@ -41,6 +42,7 @@ namespace settings_values {
|
||||
const int imageScale = 5;
|
||||
|
||||
//! Translation
|
||||
const bool doTranslation = true;
|
||||
const QString sourceLanguage = "auto";
|
||||
const QString translationLanguage = "ru";
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ void SettingsEditor::saveSettings () const {
|
||||
|
||||
|
||||
settings.beginGroup (translationGroup);
|
||||
settings.setValue (doTranslation, ui->doTranslationCombo->isChecked ());
|
||||
QString trLanguage = dictionary_.translateUiToCode (ui->translateLangCombo->currentText ());
|
||||
settings.setValue (translationLanguage, trLanguage);
|
||||
QString sourceLanguage = dictionary_.translateForOcrCode (ocrLanguage);
|
||||
@ -98,6 +99,7 @@ void SettingsEditor::loadSettings () {
|
||||
settings.endGroup ();
|
||||
|
||||
settings.beginGroup (settings_names::translationGroup);
|
||||
ui->doTranslationCombo->setChecked (GET (doTranslation).toBool ());
|
||||
QString trLanguage = dictionary_.translateCodeToUi (GET (translationLanguage).toString ());
|
||||
ui->translateLangCombo->setCurrentText (trLanguage);
|
||||
settings.endGroup ();
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>242</height>
|
||||
<width>518</width>
|
||||
<height>274</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -145,14 +145,14 @@
|
||||
<string>Вывод результата</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="trayRadio">
|
||||
<property name="text">
|
||||
<string>Трей</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="dialogRadio">
|
||||
<property name="text">
|
||||
<string>Окно</string>
|
||||
@ -171,7 +171,17 @@
|
||||
<string>Перевод</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="doTranslationCombo">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Необходимо ли переводить (вкл) распознанный текст.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Переводить текст</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html></string>
|
||||
@ -184,7 +194,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="translateLangCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user