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