--- a/src/settingseditor/settingseditor.cpp Tue Jun 14 17:55:50 2022 +0300 +++ b/src/settingseditor/settingseditor.cpp Tue Jun 14 19:50:31 2022 +0300 @@ -1,20 +1,19 @@ #include <QSettings> #include <QMdiArea> +#include "settings.h" #include "gl/common.h" #include "keyboardshortcutseditor.h" #include "settingseditor.h" #include "ui_settingseditor.h" SettingsEditor::SettingsEditor( - Configuration* settings, const uiutilities::KeySequenceMap& defaultKeyboardShortcuts, QWidget* parent ) : QDialog{parent}, ui{*new Ui_SettingsEditor}, - settings{settings}, - libraries{settings, this}, - librariesEditor{settings, this}, + libraries{this}, + librariesEditor{this}, defaultKeyboardShortcuts{defaultKeyboardShortcuts} { this->ui.setupUi(this); @@ -40,17 +39,17 @@ void SettingsEditor::handleAccepted() { - this->settings->setLocale(this->ui.language->currentData().toString()); - this->settings->setMainColor(this->ui.mainColorButton->selectedColor()); - this->settings->setBackgroundColor(this->ui.backgroundColorButton->selectedColor()); - this->settings->setSelectedColor(this->ui.selectedColorButton->selectedColor()); - this->settings->setLineThickness(static_cast<GLfloat>(this->ui.lineThickness->value())); - this->settings->setLineAntiAliasing(this->ui.lineAntiAliasing->isChecked()); + setSetting<Setting::Locale>(this->ui.language->currentData().toString()); + setSetting<Setting::MainColor>(this->ui.mainColorButton->selectedColor()); + setSetting<Setting::BackgroundColor>(this->ui.backgroundColorButton->selectedColor()); + setSetting<Setting::SelectedColor>(this->ui.selectedColorButton->selectedColor()); + setSetting<Setting::LineThickness>(static_cast<GLfloat>(this->ui.lineThickness->value())); + setSetting<Setting::LineAntiAliasing>(this->ui.lineAntiAliasing->isChecked()); const int viewMode = this->ui.viewModeButtonGroup->checkedId(); if (viewMode != -1) { - this->settings->setViewMode(viewMode); + setSetting<Setting::ViewMode>(static_cast<QMdiArea::ViewMode>(viewMode)); } - this->librariesEditor.saveSettings(this->settings); + this->librariesEditor.saveSettings(); } void SettingsEditor::loadLocales() @@ -77,13 +76,13 @@ void SettingsEditor::setDefaults() { - this->setCurrentLanguage(this->settings->locale()); - this->ui.mainColorButton->setSelectedColor(this->settings->mainColor()); - this->ui.backgroundColorButton->setSelectedColor(this->settings->backgroundColor()); - this->ui.selectedColorButton->setSelectedColor(this->settings->selectedColor()); - this->ui.lineThickness->setValue(static_cast<double>(this->settings->lineThickness())); - this->ui.lineAntiAliasing->setChecked(this->settings->lineAntiAliasing()); - auto* const viewModeButton = this->ui.viewModeButtonGroup->button(this->settings->viewMode()); + this->setCurrentLanguage(setting<Setting::Locale>()); + this->ui.mainColorButton->setSelectedColor(setting<Setting::MainColor>()); + this->ui.backgroundColorButton->setSelectedColor(setting<Setting::BackgroundColor>()); + this->ui.selectedColorButton->setSelectedColor(setting<Setting::SelectedColor>()); + this->ui.lineThickness->setValue(double_cast(setting<Setting::LineThickness>())); + this->ui.lineAntiAliasing->setChecked(setting<Setting::LineAntiAliasing>()); + auto* const viewModeButton = this->ui.viewModeButtonGroup->button(setting<Setting::ViewMode>()); if (viewModeButton != nullptr) { viewModeButton->setChecked(true); }