diff -r 6d95c1a41e6e -r 63125c36de73 src/main.cpp --- a/src/main.cpp Tue Jun 14 17:55:50 2022 +0300 +++ b/src/main.cpp Tue Jun 14 19:50:31 2022 +0300 @@ -13,6 +13,7 @@ #include "document.h" #include "settingseditor/settingseditor.h" #include "widgets/colorselectdialog.h" +#include "settings.h" static const QDir LOCALE_DIR {":/locale"}; @@ -54,6 +55,8 @@ QCoreApplication::setOrganizationDomain("hecknology.net"); qRegisterMetaTypeStreamOperators("Library"); qRegisterMetaTypeStreamOperators("Libraries"); + qRegisterMetaTypeStreamOperators(); + qRegisterMetaTypeStreamOperators(); } template @@ -251,16 +254,16 @@ ui->actionDrawAxes->setChecked(renderPreferences->drawAxes); }; -static gl::RenderPreferences loadRenderPreferences(Configuration* settings) +static gl::RenderPreferences loadRenderPreferences() { return gl::RenderPreferences{ - .style = static_cast(settings->renderStyle()), - .mainColor = settings->mainColor(), - .backgroundColor = settings->backgroundColor(), - .selectedColor = settings->selectedColor(), - .lineThickness = settings->lineThickness(), - .lineAntiAliasing = settings->lineAntiAliasing(), - .drawAxes = settings->drawAxes(), + .style = setting(), + .mainColor = setting(), + .backgroundColor = setting(), + .selectedColor = setting(), + .lineThickness = setting(), + .lineAntiAliasing = setting(), + .drawAxes = setting(), }; } @@ -327,9 +330,7 @@ DocumentManager documents; QString currentLanguage = "en"; QTranslator translator{&mainWindow}; - Configuration settings; LibraryManager libraries{&mainWindow}; - QByteArray documentSplitterState; QStringList recentlyOpenedFiles; ColorTable colorTable; gl::RenderPreferences renderPreferences; @@ -337,12 +338,12 @@ const uiutilities::KeySequenceMap defaultKeyboardShortcuts = uiutilities::makeKeySequenceMap(uiutilities::collectActions(&mainWindow)); const auto saveSettings = [&]{ - settings.setMainWindowGeometry(mainWindow.saveGeometry()); - settings.setRecentFiles(recentlyOpenedFiles); - settings.setMainSplitterState(documentSplitterState); - settings.setRenderStyle(static_cast(renderPreferences.style)); - settings.setDrawAxes(renderPreferences.drawAxes); - libraries.storeToSettings(&settings); + setSetting(mainWindow.saveGeometry()); + setSetting(recentlyOpenedFiles); + setSetting(renderPreferences.style); + setSetting(renderPreferences.drawAxes); + setSetting("hello world"); + libraries.storeToSettings(); }; const auto updateRecentlyOpenedDocumentsMenu = [&]{ rebuildRecentFilesMenu(ui.menuRecentFiles, recentlyOpenedFiles, &mainWindow); @@ -370,15 +371,14 @@ }, action); }; const auto restoreSettings = [&]{ - recentlyOpenedFiles = settings.recentFiles(); - documentSplitterState = settings.mainSplitterState(); - renderPreferences = loadRenderPreferences(&settings); - changeLanguage(settings.locale(), &translator); - libraries.restoreFromSettings(&settings); + recentlyOpenedFiles = setting(); + renderPreferences = loadRenderPreferences(); + changeLanguage(setting(), &translator); + libraries.restoreFromSettings(); updateRecentlyOpenedDocumentsMenu(); colorTable = loadColors(&libraries); updateRenderPreferences(&ui, &renderPreferences, &documents); - ui.mdiArea->setViewMode(static_cast(settings.viewMode())); + ui.mdiArea->setViewMode(setting()); ui.retranslateUi(&mainWindow); }; const auto addRecentlyOpenedFile = [&](const QString& path){ @@ -407,7 +407,7 @@ data->tools->setGridMatrix(XZ); data->model = model; data->canvas->addRenderLayer(data->axesLayer.get()); - data->canvas->setLayerEnabled(data->axesLayer.get(), settings.drawAxes()); + data->canvas->setLayerEnabled(data->axesLayer.get(), setting()); data->canvas->addRenderLayer(data->gridLayer.get()); data->canvas->addRenderLayer(data->tools.get()); documents.setModelPayload(modelId, data); @@ -476,7 +476,7 @@ } }); QObject::connect(ui.actionSettingsEditor, &QAction::triggered, [&]{ - SettingsEditor settingsEditor{&settings, defaultKeyboardShortcuts, &mainWindow}; + SettingsEditor settingsEditor{defaultKeyboardShortcuts, &mainWindow}; const int result = settingsEditor.exec(); if (result == QDialog::Accepted) { @@ -600,7 +600,7 @@ } }); mainWindow.setWindowTitle(title()); - mainWindow.restoreGeometry(settings.mainWindowGeometry()); + mainWindow.restoreGeometry(setting()); restoreSettings(); updateRenderPreferences(&ui, &renderPreferences, &documents); mainWindow.show();