SettingsEditor updated. Added rescent translator settings.
This commit is contained in:
parent
90cce0a370
commit
468a6fd039
@ -1,15 +1,17 @@
|
||||
#include "SettingsEditor.h"
|
||||
#include "ui_SettingsEditor.h"
|
||||
#include "LanguageHelper.h"
|
||||
#include "TranslatorHelper.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
#include <QDir>
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
SettingsEditor::SettingsEditor (const LanguageHelper &dictionary, QWidget *parent) :
|
||||
QDialog (parent),
|
||||
ui (new Ui::SettingsEditor), dictionary_ (dictionary),
|
||||
ui (new Ui::SettingsEditor), translatorHelper_ (new TranslatorHelper), dictionary_ (dictionary),
|
||||
buttonGroup_ (new QButtonGroup (this)) {
|
||||
ui->setupUi (this);
|
||||
|
||||
@ -27,6 +29,7 @@ SettingsEditor::SettingsEditor (const LanguageHelper &dictionary, QWidget *paren
|
||||
|
||||
SettingsEditor::~SettingsEditor () {
|
||||
saveState ();
|
||||
delete translatorHelper_;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -52,19 +55,32 @@ void SettingsEditor::saveSettings () const {
|
||||
|
||||
settings.beginGroup (recogntionGroup);
|
||||
settings.setValue (tessDataPlace, ui->tessdataEdit->text ());
|
||||
QString ocrLanguage = dictionary_.ocrUiToCode (ui->ocrLangCombo->currentText ());
|
||||
settings.setValue (ocrLanguage, ocrLanguage);
|
||||
QString ocrLanguageVal = dictionary_.ocrUiToCode (ui->ocrLangCombo->currentText ());
|
||||
settings.setValue (ocrLanguage, ocrLanguageVal);
|
||||
settings.setValue (imageScale, ui->imageScaleSpin->value ());
|
||||
settings.endGroup ();
|
||||
|
||||
|
||||
settings.beginGroup (translationGroup);
|
||||
settings.setValue (doTranslation, ui->doTranslationCombo->isChecked ());
|
||||
settings.setValue (doTranslation, ui->doTranslationCheck->isChecked ());
|
||||
settings.setValue (translationDebugMode, ui->translatorDebugCheck->isChecked ());
|
||||
QString trLanguage = dictionary_.translateUiToCode (ui->translateLangCombo->currentText ());
|
||||
settings.setValue (translationLanguage, trLanguage);
|
||||
QString sourceLanguage = dictionary_.translateForOcrCode (ocrLanguage);
|
||||
settings.setValue (sourceLanguage, sourceLanguage);
|
||||
QString sourceLanguageVal = dictionary_.translateForOcrCode (ocrLanguage);
|
||||
settings.setValue (sourceLanguage, sourceLanguageVal);
|
||||
settings.setValue (translationTimeout, ui->translateTimeoutSpin->value ());
|
||||
|
||||
{//Translators
|
||||
QStringList enabled;
|
||||
for (int i = 0, end = ui->translatorList->count (); i < end; ++i) {
|
||||
QListWidgetItem *item = ui->translatorList->item (i);
|
||||
if (item->checkState () == Qt::Checked) {
|
||||
enabled << item->text ();
|
||||
}
|
||||
}
|
||||
translatorHelper_->setEnabledTranslators (enabled);
|
||||
}
|
||||
|
||||
settings.endGroup ();
|
||||
}
|
||||
|
||||
@ -102,10 +118,22 @@ void SettingsEditor::loadSettings () {
|
||||
settings.endGroup ();
|
||||
|
||||
settings.beginGroup (settings_names::translationGroup);
|
||||
ui->doTranslationCombo->setChecked (GET (doTranslation).toBool ());
|
||||
ui->doTranslationCheck->setChecked (GET (doTranslation).toBool ());
|
||||
ui->translatorDebugCheck->setChecked (GET (translationDebugMode).toBool ());
|
||||
QString trLanguage = dictionary_.translateCodeToUi (GET (translationLanguage).toString ());
|
||||
ui->translateLangCombo->setCurrentText (trLanguage);
|
||||
ui->translateTimeoutSpin->setValue (GET (translationTimeout).toInt ());
|
||||
|
||||
{// Translators
|
||||
QStringList enabled;
|
||||
ui->translatorList->addItems (translatorHelper_->possibleTranslators (enabled));
|
||||
for (int i = 0, end = ui->translatorList->count (); i < end; ++i) {
|
||||
QListWidgetItem *item = ui->translatorList->item (i);
|
||||
Qt::CheckState state = enabled.contains (item->text ()) ? Qt::Checked : Qt::Unchecked;
|
||||
item->setCheckState (state);
|
||||
}
|
||||
}
|
||||
|
||||
settings.endGroup ();
|
||||
#undef GET
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace Ui {
|
||||
class SettingsEditor;
|
||||
}
|
||||
class LanguageHelper;
|
||||
class TranslatorHelper;
|
||||
|
||||
class SettingsEditor : public QDialog {
|
||||
Q_OBJECT
|
||||
@ -35,6 +36,7 @@ class SettingsEditor : public QDialog {
|
||||
|
||||
private:
|
||||
Ui::SettingsEditor *ui;
|
||||
TranslatorHelper *translatorHelper_;
|
||||
const LanguageHelper &dictionary_;
|
||||
QButtonGroup *buttonGroup_;
|
||||
};
|
||||
|
@ -6,92 +6,15 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>603</width>
|
||||
<height>296</height>
|
||||
<width>509</width>
|
||||
<height>338</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Настройки</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Распознавание</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Необходимо для распознавания.</p><p>Скачивается отсюда: <a href="https://github.com/tesseract-ocr/tessdata"><span style=" text-decoration: underline; color:#7593bc;">https://github.com/tesseract-ocr/tessdata</span></a></p><p>&quot;./&quot; означает, что папка &quot;tessdata&quot; находится в одной директории с исполняемым файлом программы.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Путь к tessdata</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tessdataEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="tessdataEdit"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="tessdataButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Заполняется на основании содержания tessdata</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Язык распознавания</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ocrLangCombo</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Масштабирование изображения для улучшения распознания. Больше - лучше (до определенных пределов), но медленнее и потребляет больше памяти.</p><p>Рекомендуемые значения от 5 до 10.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Увеличение масштаба</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>imageScaleSpin</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="ocrLangCombo"/>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="imageScaleSpin"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -101,33 +24,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="resultGroup">
|
||||
<property name="title">
|
||||
<string>Вывод результата</string>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="trayRadio">
|
||||
<property name="text">
|
||||
<string>Трей</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="dialogRadio">
|
||||
<property name="text">
|
||||
<string>Окно</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QWidget" name="commonTab">
|
||||
<attribute name="title">
|
||||
<string>Общее</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Горячие клавиши</string>
|
||||
@ -188,14 +95,129 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" rowspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Перевод</string>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="doTranslationCombo">
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>270</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="resultGroup">
|
||||
<property name="title">
|
||||
<string>Вывод результата</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="trayRadio">
|
||||
<property name="text">
|
||||
<string>Трей</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="dialogRadio">
|
||||
<property name="text">
|
||||
<string>Окно</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="recognizeTab">
|
||||
<attribute name="title">
|
||||
<string>Распознавание</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Необходимо для распознавания.</p><p>Скачивается отсюда: <a href="https://github.com/tesseract-ocr/tessdata"><span style=" text-decoration: underline; color:#7593bc;">https://github.com/tesseract-ocr/tessdata</span></a></p><p>&quot;./&quot; означает, что папка &quot;tessdata&quot; находится в одной директории с исполняемым файлом программы.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Путь к tessdata</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>tessdataEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="tessdataEdit"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="tessdataButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Заполняется на основании содержания tessdata</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Язык распознавания</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>ocrLangCombo</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="ocrLangCombo"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Масштабирование изображения для улучшения распознания. Больше - лучше (до определенных пределов), но медленнее и потребляет больше памяти.</p><p>Рекомендуемые значения от 5 до 10.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Увеличение масштаба</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>imageScaleSpin</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="imageScaleSpin"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>132</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="translateTab">
|
||||
<attribute name="title">
|
||||
<string>Перевод</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="doTranslationCheck">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Необходимо ли переводить (вкл) распознанный текст.</p></body></html></string>
|
||||
</property>
|
||||
@ -204,9 +226,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QCheckBox" name="translatorDebugCheck">
|
||||
<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_9">
|
||||
<property name="whatsThis">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Максимальное время, которое может быть затрачено на перевод, чтобы он не считался &quot;зависшим&quot;.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
@ -214,13 +246,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="translateTimeoutSpin">
|
||||
<property name="suffix">
|
||||
<string> сек.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="toolTip">
|
||||
@ -234,21 +259,65 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Переводчики:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="translateLangCombo"/>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="translateTimeoutSpin">
|
||||
<property name="suffix">
|
||||
<string> сек.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QListWidget" name="translatorList">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Отображены в порядке убывания приоритета.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>translateLangCombo</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>captureEdit</tabstop>
|
||||
<tabstop>repeatCaptureEdit</tabstop>
|
||||
<tabstop>repeatEdit</tabstop>
|
||||
<tabstop>clipboardEdit</tabstop>
|
||||
<tabstop>trayRadio</tabstop>
|
||||
<tabstop>dialogRadio</tabstop>
|
||||
<tabstop>tessdataEdit</tabstop>
|
||||
<tabstop>tessdataButton</tabstop>
|
||||
<tabstop>ocrLangCombo</tabstop>
|
||||
<tabstop>imageScaleSpin</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
<tabstop>doTranslationCheck</tabstop>
|
||||
<tabstop>translatorDebugCheck</tabstop>
|
||||
<tabstop>translateTimeoutSpin</tabstop>
|
||||
<tabstop>translateLangCombo</tabstop>
|
||||
<tabstop>translatorList</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
Loading…
Reference in New Issue
Block a user