settings and bugfixes

This commit is contained in:
2025-03-23 20:55:34 +03:00
parent e58d6068e0
commit d17695a7fa
14 changed files with 487 additions and 395 deletions

View File

@@ -1,7 +1,10 @@
#include "settingsdialog.h"
#include "settings/settings.h"
#include "ui_settingsdialog.h"
#include "utils/utils.h"
#include <settings/settings.h>
#include <utils/utils.h>
#include <iostream>
#include <QMessageBox>
@@ -34,10 +37,14 @@ SettingsDialog::SettingsDialog(QWidget *parent)
ui->printHeaderCheckBox->setChecked(this->settings.get_all_settings()["print_header"]);
ui->printTotalCheckBox->setChecked(this->settings.get_all_settings()["print_total"]);
std::cout << settings.get_all_settings() << std::endl;
int currentLanguageIndex = 0;
if (!this->settings.get_all_settings().contains("language")) {
bool languageSettingPresent = false;
//TODO: check that "language" exists before getting its value
languageSettingPresent = settings.get_all_settings().find("language") != settings.get_all_settings().end();
if (languageSettingPresent) {
currentLanguageIndex = ui->languageComboBox->findText(QLocale::system().name());
if (currentLanguageIndex < 0) {
currentLanguageIndex = ui->languageComboBox->findText("en_US");
@@ -137,7 +144,11 @@ 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")) {
bool languageSettingPresent = false;
languageSettingPresent = settings.get_all_settings().find("language") != settings.get_all_settings().end();
if (languageSettingPresent) {
if (changed == QString::fromStdString(this->settings.get_all_settings()["language"])) return;
} else {
if (changed == QLocale::system().name()) return;
@@ -151,4 +162,3 @@ void SettingsDialog::on_languageComboBox_currentTextChanged(const QString &chang
infoDialog.setWindowTitle(tr("Restart required"));
infoDialog.exec();
}