fixed language settings
This commit is contained in:
parent
b7b7c054d3
commit
64da9e9327
4
main.cpp
4
main.cpp
|
@ -48,16 +48,12 @@ int main(int argc, char *argv[]) {
|
|||
QString lang = "en_US";
|
||||
|
||||
if (s.get_all_settings().contains("language")) {
|
||||
std::cout << "settings" << std::endl;
|
||||
lang = QString::fromStdString(s.get_all_settings()["language"]);
|
||||
} else if (translator.load(":/translation/"+QLocale::system().name()+".qm")) {
|
||||
std::cout << "system" << std::endl;
|
||||
lang = QLocale::system().name();
|
||||
} else {
|
||||
std::cout << "default" << std::endl;
|
||||
lang = QString::fromStdString("en_US");
|
||||
}
|
||||
std::cout << lang.toStdString() << std::endl;
|
||||
translator.load(":/translation/" + lang + ".qm");
|
||||
|
||||
a.installTranslator(&translator);
|
||||
|
|
|
@ -26,7 +26,6 @@ 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,
|
||||
|
|
|
@ -35,8 +35,18 @@ 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);
|
||||
|
||||
int currentLanguageIndex = 0;
|
||||
if (!this->settings.get_all_settings().contains("language")) {
|
||||
currentLanguageIndex = ui->languageComboBox->findText(QLocale::system().name());
|
||||
if (currentLanguageIndex < 0) {
|
||||
currentLanguageIndex = ui->languageComboBox->findText("en_US");
|
||||
}
|
||||
} else {
|
||||
currentLanguageIndex = ui->languageComboBox->findText(QString::fromStdString(this->settings.get_all_settings()["language"]));
|
||||
}
|
||||
ui->languageComboBox->setCurrentIndex(currentLanguageIndex);
|
||||
|
||||
}
|
||||
|
||||
SettingsDialog::~SettingsDialog() { delete ui; }
|
||||
|
@ -127,7 +137,12 @@ void SettingsDialog::on_buttonBox_accepted() { this->settings.flush(); }
|
|||
void SettingsDialog::on_buttonBox_rejected() { this->close(); }
|
||||
|
||||
void SettingsDialog::on_languageComboBox_currentTextChanged(const QString &changed) {
|
||||
if (this->settings.get_all_settings().contains("language")) {
|
||||
if (changed == QString::fromStdString(this->settings.get_all_settings()["language"])) return;
|
||||
} else {
|
||||
if (changed == QLocale::system().name()) return;
|
||||
}
|
||||
|
||||
this->settings.get_all_settings()["language"] = changed.toStdString();
|
||||
|
||||
QMessageBox infoDialog;
|
||||
|
|
|
@ -311,12 +311,12 @@
|
|||
<context>
|
||||
<name>SettingsDialog</name>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="134"/>
|
||||
<location filename="../settingsdialog.cpp" line="149"/>
|
||||
<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"/>
|
||||
<location filename="../settingsdialog.cpp" line="151"/>
|
||||
<source>Restart required</source>
|
||||
<translation>Restart required</translation>
|
||||
</message>
|
||||
|
|
|
@ -307,12 +307,12 @@
|
|||
<context>
|
||||
<name>SettingsDialog</name>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="134"/>
|
||||
<location filename="../settingsdialog.cpp" line="149"/>
|
||||
<source>You need to restart program to apply language changes</source>
|
||||
<translation>Требуется перезагрузить программу, чтобы применить изменения языка</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../settingsdialog.cpp" line="136"/>
|
||||
<location filename="../settingsdialog.cpp" line="151"/>
|
||||
<source>Restart required</source>
|
||||
<translation>Требуется перезагрузка</translation>
|
||||
</message>
|
||||
|
|
Loading…
Reference in New Issue