added language combo box in preferences

This commit is contained in:
leca 2024-12-04 18:44:40 +03:00
parent 031c1d5792
commit 7959bc5492
9 changed files with 306 additions and 200 deletions

View File

@ -9,6 +9,9 @@
id="svg1"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="icon.svg"
inkscape:export-filename="icon.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
@ -24,9 +27,9 @@
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showguides="true"
inkscape:zoom="0.64375976"
inkscape:cx="342.51908"
inkscape:cy="653.97067"
inkscape:zoom="0.84246729"
inkscape:cx="162.02409"
inkscape:cy="522.27547"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"

Before

Width:  |  Height:  |  Size: 649 KiB

After

Width:  |  Height:  |  Size: 649 KiB

View File

@ -43,9 +43,17 @@ int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QTranslator translator;
if(!translator.load(QLocale::system().name())) {
translator.load("en_US");
QString lang = "en_US";
if (s.get_all_settings().contains("language")) {
lang = QString::fromStdString(s.get_all_settings()["language"]);
} else if (translator.load(QLocale::system().name())) {
lang = QLocale::system().name();
} else {
lang = QString::fromStdString("en_US");
}
translator.load(lang);
a.installTranslator(&translator);
MainWindow w;
w.update();

View File

@ -110,7 +110,7 @@
<widget class="QPushButton" name="chooseImageButton_ocr">
<property name="geometry">
<rect>
<x>0</x>
<x>10</x>
<y>0</y>
<width>80</width>
<height>26</height>

View File

@ -26,6 +26,7 @@ Settings::Settings(std::string path) {
"stores_modules_url":"https://foxarmy.org/checks-parser/modules/stores/",
"print_header": true,
"print_total": true,
"language":"en_US",
"output_order": {
"goods_name": {
"position":1,

View File

@ -3,6 +3,8 @@
#include "ui_settingsdialog.h"
#include "utils/utils.h"
#include <QMessageBox>
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent), ui(new Ui::settingsdialog),
settings(Settings(get_path_relative_to_home(
@ -32,6 +34,9 @@ SettingsDialog::SettingsDialog(QWidget *parent)
ui->printHeaderCheckBox->setChecked(this->settings.get_all_settings()["print_header"]);
ui->printTotalCheckBox->setChecked(this->settings.get_all_settings()["print_total"]);
int index = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
ui->languageComboBox->setCurrentIndex(index);
}
SettingsDialog::~SettingsDialog() { delete ui; }
@ -121,4 +126,14 @@ void SettingsDialog::on_buttonBox_accepted() { this->settings.flush(); }
void SettingsDialog::on_buttonBox_rejected() { this->close(); }
void SettingsDialog::on_languageComboBox_currentTextChanged(const QString &changed) {
if (changed == QString::fromStdString(this->settings.get_all_settings()["language"])) return;
this->settings.get_all_settings()["language"] = changed.toStdString();
QMessageBox infoDialog;
infoDialog.setText(tr("You need to restart program to apply language changes"));
infoDialog.setIcon(QMessageBox::Information);
infoDialog.setWindowTitle(tr("Restart required"));
infoDialog.exec();
}

View File

@ -52,6 +52,8 @@ private slots:
void on_buttonBox_rejected();
void on_languageComboBox_currentTextChanged(const QString &arg1);
private:
Ui::settingsdialog *ui;
};

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>599</width>
<height>727</height>
<height>799</height>
</rect>
</property>
<property name="windowTitle">
@ -17,16 +17,16 @@
<property name="geometry">
<rect>
<x>310</x>
<y>690</y>
<y>740</y>
<width>251</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Save</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
<widget class="QScrollArea" name="scrollArea">
@ -35,7 +35,7 @@
<x>10</x>
<y>0</y>
<width>541</width>
<height>661</height>
<height>741</height>
</rect>
</property>
<property name="widgetResizable">
@ -47,7 +47,7 @@
<x>0</x>
<y>0</y>
<width>539</width>
<height>659</height>
<height>739</height>
</rect>
</property>
<widget class="QWidget" name="gridLayoutWidget">
@ -56,16 +56,126 @@
<x>0</x>
<y>0</y>
<width>531</width>
<height>651</height>
<height>731</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="11" column="1">
<widget class="QLineEdit" name="goodsNetWeightAliasEdit"/>
<item row="15" column="1">
<widget class="QCheckBox" name="printTotalCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Goods net weight position</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="goodsNamePositionSpin"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Stores modules url</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Goods quantity position</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="OFDModulesDirEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>OFD modules url</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Print header</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="goodsPricePerUnitPositionSpin"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="storesModulesURLEdit"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Goods quantity alias</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>OFD modules directory</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="goodsNameAliasEdit"/>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Print total</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="goodsTotalAliasEdit"/>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="goodsQuantityPositionSpin"/>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Goods net weight alias</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QSpinBox" name="goodsNetWeightPositionSpin"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="OFDModulesURLEdit"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Goods total alias</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="storesModulesDirEdit"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="goodsPricePerUnitAliasEdit"/>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="goodsQuantityAliasEdit"/>
</item>
<item row="11" column="1">
<widget class="QLineEdit" name="goodsNetWeightAliasEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
@ -73,6 +183,51 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="printHeaderCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Goods name alias</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Goods price per unit position</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Stores modules directory</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Goods total position</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="OFDModulesDirChooseButton">
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="goodsTotalPositionSpin"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
@ -87,159 +242,25 @@
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QLineEdit" name="goodsTotalAliasEdit"/>
</item>
<item row="14" column="0">
<widget class="QLabel" name="label_2">
<item row="16" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Print header</string>
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Goods net weight alias</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Stores modules url</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="storesModulesURLEdit"/>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_18">
<property name="text">
<string>Goods total alias</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Goods name alias</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QSpinBox" name="goodsTotalPositionSpin"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Goods quantity alias</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Stores modules directory</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="goodsNameAliasEdit"/>
</item>
<item row="10" column="1">
<widget class="QSpinBox" name="goodsNetWeightPositionSpin"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>OFD modules directory</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="goodsNamePositionSpin"/>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="goodsQuantityAliasEdit"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="goodsPricePerUnitAliasEdit"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Goods price per unit position</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Goods net weight position</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>OFD modules url</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="OFDModulesDirEdit"/>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Goods total position</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Goods quantity position</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="OFDModulesURLEdit"/>
</item>
<item row="8" column="1">
<widget class="QSpinBox" name="goodsQuantityPositionSpin"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="OFDModulesDirChooseButton">
<property name="text">
<string>Choose</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="goodsPricePerUnitPositionSpin"/>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Print total</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="printHeaderCheckBox">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="printTotalCheckBox">
<property name="text">
<string/>
</property>
<item row="16" column="1">
<widget class="QComboBox" name="languageComboBox">
<item>
<property name="text">
<string>en_US</string>
</property>
</item>
<item>
<property name="text">
<string>ru_RU</string>
</property>
</item>
</widget>
</item>
</layout>

View File

@ -308,6 +308,19 @@
<translation>Print total</translation>
</message>
</context>
<context>
<name>SettingsDialog</name>
<message>
<location filename="../settingsdialog.cpp" line="134"/>
<source>You need to restart program to apply language changes</source>
<translation>You need to restart program to apply language changes</translation>
</message>
<message>
<location filename="../settingsdialog.cpp" line="136"/>
<source>Restart required</source>
<translation>Restart required</translation>
</message>
</context>
<context>
<name>SolveCaptchaDialog</name>
<message>
@ -334,88 +347,103 @@
<translation>Dialog</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="72"/>
<location filename="../settingsdialog.ui" line="182"/>
<source>Goods name position</source>
<translation>Goods name position</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="79"/>
<location filename="../settingsdialog.ui" line="234"/>
<source>Goods price per unit alias</source>
<translation>Goods price per unit alias</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="86"/>
<location filename="../settingsdialog.ui" line="217"/>
<location filename="../settingsdialog.ui" line="248"/>
<source>TextLabel</source>
<translation>Language</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="256"/>
<source>en_US</source>
<translation>en_US</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="261"/>
<source>ru_RU</source>
<translation>ru_RU</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="224"/>
<location filename="../settingsdialog.ui" line="241"/>
<source>Choose</source>
<translation>Choose</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="96"/>
<location filename="../settingsdialog.ui" line="107"/>
<source>Print header</source>
<translation>Print header</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="103"/>
<location filename="../settingsdialog.ui" line="150"/>
<source>Goods net weight alias</source>
<translation>Goods net weight alias</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="110"/>
<location filename="../settingsdialog.ui" line="83"/>
<source>Stores modules url</source>
<translation>Stores modules url</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="120"/>
<location filename="../settingsdialog.ui" line="163"/>
<source>Goods total alias</source>
<translation>Goods total alias</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="127"/>
<location filename="../settingsdialog.ui" line="196"/>
<source>Goods name alias</source>
<translation>Goods name alias</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="137"/>
<location filename="../settingsdialog.ui" line="120"/>
<source>Goods quantity alias</source>
<translation>Goods quantity alias</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="144"/>
<location filename="../settingsdialog.ui" line="210"/>
<source>Stores modules directory</source>
<translation>Stores modules directory</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="157"/>
<location filename="../settingsdialog.ui" line="127"/>
<source>OFD modules directory</source>
<translation>OFD modules directory</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="173"/>
<location filename="../settingsdialog.ui" line="203"/>
<source>Goods price per unit position</source>
<translation>Goods price per unit position</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="180"/>
<location filename="../settingsdialog.ui" line="73"/>
<source>Goods net weight position</source>
<translation>Goods net weight position</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="187"/>
<location filename="../settingsdialog.ui" line="100"/>
<source>OFD modules url</source>
<translation>OFD modules url</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="197"/>
<location filename="../settingsdialog.ui" line="217"/>
<source>Goods total position</source>
<translation>Goods total position</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="204"/>
<location filename="../settingsdialog.ui" line="90"/>
<source>Goods quantity position</source>
<translation>Goods quantity position</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="227"/>
<location filename="../settingsdialog.ui" line="137"/>
<source>Print total</source>
<translation>Print total</translation>
</message>

View File

@ -304,6 +304,19 @@
<translation>Печатать Итого</translation>
</message>
</context>
<context>
<name>SettingsDialog</name>
<message>
<location filename="../settingsdialog.cpp" line="135"/>
<source>You need to restart program to apply language changes</source>
<translation>Требуется перезагрузить программу, чтобы применить изменения языка</translation>
</message>
<message>
<location filename="../settingsdialog.cpp" line="137"/>
<source>Restart required</source>
<translation>Требуется перезагрузка</translation>
</message>
</context>
<context>
<name>SolveCaptchaDialog</name>
<message>
@ -330,88 +343,103 @@
<translation>Диалог</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="72"/>
<location filename="../settingsdialog.ui" line="182"/>
<source>Goods name position</source>
<translation>Позиция имени товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="79"/>
<location filename="../settingsdialog.ui" line="234"/>
<source>Goods price per unit alias</source>
<translation>Алиас цены товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="86"/>
<location filename="../settingsdialog.ui" line="217"/>
<location filename="../settingsdialog.ui" line="248"/>
<source>TextLabel</source>
<translation>Язык</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="256"/>
<source>en_US</source>
<translation>en_US</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="261"/>
<source>ru_RU</source>
<translation>ru_RU</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="224"/>
<location filename="../settingsdialog.ui" line="241"/>
<source>Choose</source>
<translation>Выбрать</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="96"/>
<location filename="../settingsdialog.ui" line="107"/>
<source>Print header</source>
<translation>Печатать заголовок</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="103"/>
<location filename="../settingsdialog.ui" line="150"/>
<source>Goods net weight alias</source>
<translation>Алиас массы нетто товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="110"/>
<location filename="../settingsdialog.ui" line="83"/>
<source>Stores modules url</source>
<translation>URL модулей магазина</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="120"/>
<location filename="../settingsdialog.ui" line="163"/>
<source>Goods total alias</source>
<translation>Алиас всего за продукт</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="127"/>
<location filename="../settingsdialog.ui" line="196"/>
<source>Goods name alias</source>
<translation>Алиас имени товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="137"/>
<location filename="../settingsdialog.ui" line="120"/>
<source>Goods quantity alias</source>
<translation>Алиас количества товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="144"/>
<location filename="../settingsdialog.ui" line="210"/>
<source>Stores modules directory</source>
<translation>Директория модулей магазина</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="157"/>
<location filename="../settingsdialog.ui" line="127"/>
<source>OFD modules directory</source>
<translation>Директория модулей ОФД</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="173"/>
<location filename="../settingsdialog.ui" line="203"/>
<source>Goods price per unit position</source>
<translation>Позиция центы товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="180"/>
<location filename="../settingsdialog.ui" line="73"/>
<source>Goods net weight position</source>
<translation>Позиция массы нетто товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="187"/>
<location filename="../settingsdialog.ui" line="100"/>
<source>OFD modules url</source>
<translation>URL модулей ОФД</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="197"/>
<location filename="../settingsdialog.ui" line="217"/>
<source>Goods total position</source>
<translation>Позиция всего за товар</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="204"/>
<location filename="../settingsdialog.ui" line="90"/>
<source>Goods quantity position</source>
<translation>Позиция количества товара</translation>
</message>
<message>
<location filename="../settingsdialog.ui" line="227"/>
<location filename="../settingsdialog.ui" line="137"/>
<source>Print total</source>
<translation>Печатать Итого</translation>
</message>