diff --git a/Settings.h b/Settings.h
index 3468989..1f67a4e 100644
--- a/Settings.h
+++ b/Settings.h
@@ -31,6 +31,7 @@ namespace settings_names {
const QString translationGroup = "Translation";
const QString doTranslation = "doTranslation";
const QString ignoreSslErrors = "ignoreSslErrors";
+ const QString forceRotateTranslators = "forceRotateTranslators";
const QString sourceLanguage = "source_language";
const QString translationLanguage = "translation_language";
const QString translationTimeout = "translation_timeout";
@@ -69,6 +70,7 @@ namespace settings_values {
//! Translation
const bool doTranslation = true;
const bool ignoreSslErrors = false;
+ const bool forceRotateTranslators = false;
const QString sourceLanguage = "auto";
const QString translationLanguage = "ru";
const int translationTimeout = 15; // secs
diff --git a/SettingsEditor.cpp b/SettingsEditor.cpp
index fe6cb11..47d2c2f 100644
--- a/SettingsEditor.cpp
+++ b/SettingsEditor.cpp
@@ -129,6 +129,7 @@ void SettingsEditor::saveSettings () const {
settings.beginGroup (translationGroup);
settings.setValue (doTranslation, ui->doTranslationCheck->isChecked ());
settings.setValue (ignoreSslErrors, ui->ignoreSslCheck->isChecked ());
+ settings.setValue (forceRotateTranslators, ui->forceRotateCheck->isChecked ());
settings.setValue (translationDebugMode, ui->translatorDebugCheck->isChecked ());
QString trLanguage = dictionary_.translateUiToCode (ui->translateLangCombo->currentText ());
settings.setValue (translationLanguage, trLanguage);
@@ -218,6 +219,7 @@ void SettingsEditor::loadSettings () {
settings.beginGroup (settings_names::translationGroup);
ui->doTranslationCheck->setChecked (GET (doTranslation).toBool ());
ui->ignoreSslCheck->setChecked (GET (ignoreSslErrors).toBool ());
+ ui->forceRotateCheck->setChecked (GET (forceRotateTranslators).toBool ());
ui->translatorDebugCheck->setChecked (GET (translationDebugMode).toBool ());
QString trLanguage = dictionary_.translateCodeToUi (GET (translationLanguage).toString ());
ui->translateLangCombo->setCurrentText (trLanguage);
diff --git a/SettingsEditor.ui b/SettingsEditor.ui
index 064b900..a28dd18 100644
--- a/SettingsEditor.ui
+++ b/SettingsEditor.ui
@@ -7,7 +7,7 @@
0
0
553
- 456
+ 483
@@ -378,24 +378,7 @@
- -
-
-
- <html><head/><body><p>Отображает окно переводчика. Следует использовать только для разработки переводчиков.</p></body></html>
-
-
- Режим отладки
-
-
-
- -
-
-
- Игнорировать ошибки SSL
-
-
-
- -
+
-
<html><head/><body><p>Максимальное время, которое может быть затрачено на перевод, чтобы он не считался "зависшим".</p></body></html>
@@ -405,14 +388,17 @@
- -
+
-
сек.
- -
+
-
+
+
+ -
<html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html>
@@ -425,10 +411,7 @@
- -
-
-
- -
+
-
Переводчики:
@@ -438,7 +421,7 @@
- -
+
-
<html><head/><body><p>Отображены в порядке убывания приоритета.</p></body></html>
@@ -454,6 +437,30 @@
+ -
+
+
+ <html><head/><body><p>Отображает окно переводчика. Следует использовать только для разработки переводчиков.</p></body></html>
+
+
+ Режим отладки
+
+
+
+ -
+
+
+ Игнорировать ошибки SSL
+
+
+
+ -
+
+
+ Принудительно менять переводчики
+
+
+
diff --git a/TranslatorHelper.cpp b/TranslatorHelper.cpp
index cabb379..68e48e8 100644
--- a/TranslatorHelper.cpp
+++ b/TranslatorHelper.cpp
@@ -7,7 +7,7 @@
#include "Settings.h"
TranslatorHelper::TranslatorHelper ()
- : translatorsDir_ ("translators"), currentIndex_ (0) {
+ : translatorsDir_ ("translators"), currentIndex_ (0), triesLeft_ (0) {
translatorsDir_ = QApplication::applicationDirPath () + QDir::separator () + translatorsDir_;
}
@@ -58,19 +58,25 @@ void TranslatorHelper::loadScripts () {
scripts_ = enabledTranslatorScripts ();
}
-void TranslatorHelper::newItem () {
- currentIndex_ = 0;
-}
-
-QString TranslatorHelper::currentScript () const {
- return (currentIndex_ < scripts_.size () ? scripts_.at (currentIndex_) : QString ());
+void TranslatorHelper::newItem (bool forceRotate) {
+ triesLeft_ = scripts_.size ();
+ currentIndex_ = forceRotate ? currentIndex_ + 1 : 0;
}
QString TranslatorHelper::nextScript () {
- ++currentIndex_;
+ --triesLeft_;
+
+ if (++currentIndex_ >= scripts_.size ()) {
+ currentIndex_ = 0;
+ }
+
return currentScript ();
}
+QString TranslatorHelper::currentScript () const {
+ return (triesLeft_ > 0 ? scripts_.at (currentIndex_) : QString ());
+}
+
bool TranslatorHelper::gotScripts () const {
return !scripts_.isEmpty ();
}
diff --git a/TranslatorHelper.h b/TranslatorHelper.h
index 40370d8..9083c76 100644
--- a/TranslatorHelper.h
+++ b/TranslatorHelper.h
@@ -13,15 +13,16 @@ class TranslatorHelper {
void setEnabledTranslators (const QStringList &enabled) const;
void loadScripts ();
- void newItem ();
- QString currentScript () const;
+ void newItem (bool forceRotate);
QString nextScript ();
+ QString currentScript () const;
bool gotScripts () const;
private:
QString translatorsDir_;
QStringList scripts_;
int currentIndex_;
+ int triesLeft_;
};
#endif // TRANSLATORHELPER_H
diff --git a/WebTranslator.cpp b/WebTranslator.cpp
index 6293816..a1ba04b 100644
--- a/WebTranslator.cpp
+++ b/WebTranslator.cpp
@@ -15,7 +15,8 @@ WebTranslator::WebTranslator ()
: QObject (),
proxy_ (new WebTranslatorProxy (this)), view_ (new QWebView),
translatorHelper_ (new TranslatorHelper), isReady_ (true),
- ignoreSslErrors_ (settings_values::ignoreSslErrors){
+ ignoreSslErrors_ (settings_values::ignoreSslErrors),
+ forceRotateTranslators_ (settings_values::forceRotateTranslators) {
view_->settings ()->setAttribute (QWebSettings::AutoLoadImages, false);
view_->settings ()->setAttribute (QWebSettings::DeveloperExtrasEnabled, true);
@@ -60,7 +61,7 @@ void WebTranslator::translate (ProcessingItem item) {
void WebTranslator::translateQueued () {
if (isReady_ && !queue_.isEmpty ()) {
- translatorHelper_->newItem ();
+ translatorHelper_->newItem (forceRotateTranslators_);
proxy_->setItem (queue_.first ());
if (!tryNextTranslator (true)) {
return;
@@ -145,7 +146,8 @@ void WebTranslator::applySettings () {
bool debugMode = GET (translationDebugMode).toBool ();
setDebugMode (debugMode);
- ignoreSslErrors_ = GET(ignoreSslErrors).toBool ();
+ ignoreSslErrors_ = GET (ignoreSslErrors).toBool ();
+ forceRotateTranslators_ = GET (forceRotateTranslators).toBool ();
#undef GET
}
diff --git a/WebTranslator.h b/WebTranslator.h
index bcc31a3..8ddc462 100644
--- a/WebTranslator.h
+++ b/WebTranslator.h
@@ -50,6 +50,7 @@ class WebTranslator : public QObject {
QVector queue_;
bool isReady_;
bool ignoreSslErrors_;
+ bool forceRotateTranslators_;
QTimer translationTimeout_;
};
diff --git a/translations/translation_en.ts b/translations/translation_en.ts
index cfbd843..f5290ac 100644
--- a/translations/translation_en.ts
+++ b/translations/translation_en.ts
@@ -736,27 +736,27 @@ Key modifiers what capturing :
Result
-
+
Распознать другой язык
Recognize another language
-
+
Перевести на другой язык
Translate to another language
-
+
Скопировать в буфер
Copy to clipboard
-
+
Скопировать рисунок в буфер
Copy image to clibpoard
-
+
Исправить распознанный текст
Correct recognized text
@@ -846,7 +846,7 @@ Key modifiers what capturing :
-
+
Путь к tessdata
Tessdata path
@@ -990,52 +990,57 @@ Key modifiers what capturing :
Translate text
-
+
<html><head/><body><p>Отображает окно переводчика. Следует использовать только для разработки переводчиков.</p></body></html>
<html><head/><body><p>Displays translator's window. Should me used only for new translators development.</p></body></html>
-
+
Режим отладки
Debug mode
-
+
Игнорировать ошибки SSL
Ignore SSL errors
-
+
+ Принудительно менять переводчики
+ Force rotate translators
+
+
+
<html><head/><body><p>Максимальное время, которое может быть затрачено на перевод, чтобы он не считался "зависшим".</p></body></html>
<html><head/><body><p>Max time of translation process.</p></body></html>
-
+
Максимальное время перевода:
Max translation time:
-
+
<html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html>
<html><head/><body><p>Translated text language.</p></body></html>
-
+
Язык результата:
Translation language:
-
+
Переводчики:
Translators:
-
+
сек.
secs.
-
+
<html><head/><body><p>Отображены в порядке убывания приоритета.</p></body></html>
<html><head/><body><p>Sorted by priority descending.</p></body></html>
@@ -1451,17 +1456,17 @@ Change dirs permissions and try again or perform manual update.
WebTranslator
-
+
Перевод отменен по таймауту.
Translation timed out.
-
+
Ошибка загрузки страницы (%1) для перевода.
Page (%1) load failed.
-
+
Нет сценариев для перевода. Измените настройки.
Not found any translators. Change settings.
diff --git a/translations/translation_ru.ts b/translations/translation_ru.ts
index 05cbd2c..93062ec 100644
--- a/translations/translation_ru.ts
+++ b/translations/translation_ru.ts
@@ -741,27 +741,27 @@
Результат
-
+
Распознать другой язык
Распознать другой язык
-
+
Перевести на другой язык
Перевести на другой язык
-
+
Скопировать в буфер
Скопировать в буфер
-
+
Скопировать рисунок в буфер
Скопировать рисунок в буфер
-
+
Исправить распознанный текст
Исправить распознанный текст
@@ -851,7 +851,7 @@
-
+
Путь к tessdata
Путь к tessdata
@@ -995,52 +995,57 @@
Переводить текст
-
+
<html><head/><body><p>Отображает окно переводчика. Следует использовать только для разработки переводчиков.</p></body></html>
<html><head/><body><p>Отображает окно переводчика. Следует использовать только для разработки переводчиков.</p></body></html>
-
+
Режим отладки
Режим отладки
-
+
Игнорировать ошибки SSL
Игнорировать ошибки SSL
-
+
+ Принудительно менять переводчики
+ Принудительно менять переводчики
+
+
+
<html><head/><body><p>Максимальное время, которое может быть затрачено на перевод, чтобы он не считался "зависшим".</p></body></html>
<html><head/><body><p>Максимальное время, которое может быть затрачено на перевод, чтобы он не считался "зависшим".</p></body></html>
-
+
Максимальное время перевода:
Максимальное время перевода:
-
+
<html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html>
<html><head/><body><p>Язык, на который осуществляется перевод.</p></body></html>
-
+
Язык результата:
Язык результата:
-
+
Переводчики:
Переводчики:
-
+
сек.
сек.
-
+
<html><head/><body><p>Отображены в порядке убывания приоритета.</p></body></html>
<html><head/><body><p>Отображены в порядке убывания приоритета.</p></body></html>
@@ -1460,17 +1465,17 @@
WebTranslator
-
+
Перевод отменен по таймауту.
Перевод отменен по таймауту.
-
+
Ошибка загрузки страницы (%1) для перевода.
Ошибка загрузки страницы (%1) для перевода.
-
+
Нет сценариев для перевода. Измените настройки.
Нет сценариев для перевода. Измените настройки.