43 { offsetof(Ui_MainWindow, actionRenderStyleNormal), gl::RenderStyle::Normal }, |
43 { offsetof(Ui_MainWindow, actionRenderStyleNormal), gl::RenderStyle::Normal }, |
44 { offsetof(Ui_MainWindow, actionRenderStyleBfc), gl::RenderStyle::BfcRedGreen }, |
44 { offsetof(Ui_MainWindow, actionRenderStyleBfc), gl::RenderStyle::BfcRedGreen }, |
45 { offsetof(Ui_MainWindow, actionRenderStyleRandom), gl::RenderStyle::RandomColors }, |
45 { offsetof(Ui_MainWindow, actionRenderStyleRandom), gl::RenderStyle::RandomColors }, |
46 }; |
46 }; |
47 |
47 |
|
48 class A : public QSettings |
|
49 { |
|
50 using QSettings::QSettings; |
|
51 }; |
|
52 |
48 MainWindow::MainWindow(QWidget *parent) : |
53 MainWindow::MainWindow(QWidget *parent) : |
49 QMainWindow{parent}, |
54 QMainWindow{parent}, |
50 ui{std::make_unique<Ui_MainWindow>()}, |
55 ui{std::make_unique<Ui_MainWindow>()}, |
51 documents{this}, |
56 documents{this}, |
52 settings{}, |
57 settings{}, |
288 /** |
293 /** |
289 * @brief Stores the settings of the main window, storing geometry, etc |
294 * @brief Stores the settings of the main window, storing geometry, etc |
290 */ |
295 */ |
291 void MainWindow::saveSettings() |
296 void MainWindow::saveSettings() |
292 { |
297 { |
293 this->settings.setValue("MainWindow/Geometry", this->saveGeometry()); |
298 this->settings.setMainWindowGeometry(this->saveGeometry()); |
294 this->settings.setValue("MainWindow/RecentlyOpened", this->recentlyOpenedFiles); |
299 this->settings.setRecentFiles(this->recentlyOpenedFiles); |
295 this->settings.setValue("MainWindow/DocumentSplitterState", this->documentSplitterState); |
300 this->settings.setMainSplitterState(this->documentSplitterState); |
296 this->settings.setValue("MainWindow/RenderStyle", static_cast<int>(this->renderPreferences.style)); |
301 this->settings.setRenderStyle(static_cast<int>(this->renderPreferences.style)); |
297 this->libraries.storeToSettings(&this->settings); |
302 this->libraries.storeToSettings(&this->settings); |
298 } |
303 } |
299 |
304 |
300 void MainWindow::restoreStartupSettings() |
305 void MainWindow::restoreStartupSettings() |
301 { |
306 { |
302 this->restoreGeometry(this->settings.value("MainWindow/Geometry").toByteArray()); |
307 this->restoreGeometry(this->settings.mainWindowGeometry()); |
303 } |
308 } |
304 |
309 |
305 /** |
310 /** |
306 * @brief Restores saved settings relating to the main window |
311 * @brief Restores saved settings relating to the main window |
307 */ |
312 */ |
308 void MainWindow::restoreSettings() |
313 void MainWindow::restoreSettings() |
309 { |
314 { |
310 this->recentlyOpenedFiles = this->settings.value("MainWindow/RecentlyOpened").toStringList(); |
315 this->recentlyOpenedFiles = this->settings.recentFiles(); |
311 this->documentSplitterState = this->settings.value("MainWindow/DocumentSplitterState").toByteArray(); |
316 this->documentSplitterState = this->settings.mainSplitterState(); |
312 this->renderPreferences.style = static_cast<gl::RenderStyle>(this->settings.value("Render/Style").toInt()); |
317 this->renderPreferences.style = static_cast<gl::RenderStyle>(this->settings.renderStyle()); |
313 this->renderPreferences.mainColor = this->settings.value( |
318 this->renderPreferences.mainColor = this->settings.mainColor(); |
314 "Render/MainColor", |
319 this->renderPreferences.backgroundColor = this->settings.backgroundColor(); |
315 gl::RenderPreferences{}.mainColor).toString(); |
|
316 this->renderPreferences.backgroundColor = this->settings.value( |
|
317 "Render/BackgroundColor", |
|
318 gl::RenderPreferences{}.backgroundColor).toString(); |
|
319 const QString systemLocale = QLocale::system().name(); |
320 const QString systemLocale = QLocale::system().name(); |
320 const QVariant defaultLocale = this->settings.value("locale", systemLocale); |
321 const QVariant defaultLocale = this->settings.locale(); |
321 changeLanguage(defaultLocale.toString()); |
322 this->changeLanguage(defaultLocale.toString()); |
322 this->libraries.restoreFromSettings(&this->settings); |
323 this->libraries.restoreFromSettings(&this->settings); |
323 this->updateRecentlyOpenedDocumentsMenu(); |
324 this->updateRecentlyOpenedDocumentsMenu(); |
324 this->loadColors(); |
325 this->loadColors(); |
325 this->updateRenderPreferences(); |
326 this->updateRenderPreferences(); |
326 } |
327 } |