diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/main-window.cpp | 5 | ||||
-rw-r--r-- | gui/main.cpp | 6 | ||||
-rw-r--r-- | gui/options-dialog.cpp | 10 | ||||
-rw-r--r-- | gui/process_detector.cpp | 20 |
4 files changed, 27 insertions, 14 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp index e12b85a7..7791f520 100644 --- a/gui/main-window.cpp +++ b/gui/main-window.cpp @@ -873,6 +873,7 @@ bool MainWindow::start_in_tray() void MainWindow::set_profile_in_registry(const QString &profile) { - QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); + group::with_global_settings_object([&](QSettings& s) { + s.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); + }); } diff --git a/gui/main.cpp b/gui/main.cpp index d929c543..3739232f 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -167,9 +167,11 @@ main(int argc, char** argv) // QLocale::setDefault(QLocale("ru_RU")); // force i18n for testing - if (!QSettings(OPENTRACK_ORG).value("disable-translation", false).toBool()) + if (group::with_global_settings_object([&](QSettings& s) { + return !s.value("disable-translation", false).toBool(); + })) { - (void) t.load(QLocale(), "", "", QCoreApplication::applicationDirPath() + "/" OPENTRACK_I18N_PATH, ".qm"); + (void) t.load(QLocale(), "", "", OPENTRACK_BASE_PATH + "/" OPENTRACK_I18N_PATH, ".qm"); (void) QCoreApplication::installTranslator(&t); } diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp index 7eb6f68d..c35a6b52 100644 --- a/gui/options-dialog.cpp +++ b/gui/options-dialog.cpp @@ -33,7 +33,10 @@ QString OptionsDialog::kopts_to_string(const key_opts& kopts) void OptionsDialog::set_disable_translation_state(bool value) { - QSettings(OPENTRACK_ORG).setValue("disable-translation", value); + group::with_global_settings_object([&](QSettings& s) + { + s.setValue("disable-translation", value); + }); } OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) : @@ -88,7 +91,10 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) : tie_setting(main.neck_enable, ui.neck_enable); - ui.disable_translation->setChecked(QSettings(OPENTRACK_ORG).value("disable-translation", false).toBool()); + const bool is_translation_disabled = group::with_global_settings_object([] (QSettings& s) { + return s.value("disable-translation", false).toBool(); + }); + ui.disable_translation->setChecked(is_translation_disabled); struct tmp { diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index e45c0215..b1ad541d 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -19,26 +19,30 @@ void settings::set_game_list(const QString &game_list) { - QSettings settings(OPENTRACK_ORG); - settings.setValue("executable-list", game_list); + group::with_global_settings_object([&](QSettings& settings) { + settings.setValue("executable-list", game_list); + }); } QString settings::get_game_list() { - QSettings settings(OPENTRACK_ORG); - return settings.value("executable-list").toString(); + return group::with_global_settings_object([&](QSettings& settings) { + return settings.value("executable-list").toString(); + }); } bool settings::is_enabled() { - QSettings settings(OPENTRACK_ORG); - return settings.value("executable-detector-enabled", false).toBool(); + return group::with_global_settings_object([&](QSettings& settings) { + return settings.value("executable-detector-enabled", false).toBool(); + }); } void settings::set_is_enabled(bool enabled) { - QSettings settings(OPENTRACK_ORG); - settings.setValue("executable-detector-enabled", enabled); + group::with_global_settings_object([&](QSettings& settings) { + settings.setValue("executable-detector-enabled", enabled); + }); } QHash<QString, QString> settings::split_process_names() |