diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-08-29 03:08:47 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-29 03:09:10 -0700 |
commit | 2d87a657d248c1c6d4dd6a805bbf90c98589798a (patch) | |
tree | 3f0e3a9f6c5e072a67c936e3bbf5d17957431816 /desktop-widgets/mainwindow.cpp | |
parent | 4bb72160a6323e1ab3f3d9ea2c7f90c21088347f (diff) | |
download | subsurface-2d87a657d248c1c6d4dd6a805bbf90c98589798a.tar.gz |
Revert "desktop-widgets: remove QSettings from desktop-widgets"
This reverts commit 321a920a9873a3828a24c1b28cf8eb5fe1bff2cb.
It appears that the load_xxx functions aren't called, so while the correct
values are stored to the settings, they aren't retrieved. Let's revert while
this gets fixed.
Fixes #1609
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index f45f27b71..ea5f31556 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1182,10 +1182,12 @@ void MainWindow::on_actionViewAll_triggered() listGlobeSizes.append(lrint(appW * 0.3)); } - if (qPrefDisplay::mainSplitter() != "") { - ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter()); - ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); - ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter()); + QSettings settings; + settings.beginGroup("MainWindow"); + if (settings.value("mainSplitter").isValid()) { + ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray()); + ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); + ui.bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0) ui.mainSplitter->setSizes(mainSizes); if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) @@ -1218,8 +1220,10 @@ void MainWindow::enterEditState() int appW = qApp->desktop()->size().width(); QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) }; - if (qPrefDisplay::mainSplitter() != "") { - ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); + QSettings settings; + settings.beginGroup("MainWindow"); + if (settings.value("mainSplitter").isValid()) { + ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) ui.topSplitter->setSizes(infoProfileSizes); } else { @@ -1269,9 +1273,11 @@ void MainWindow::beginChangeState(CurrentState s) void MainWindow::saveSplitterSizes() { - qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState()); - qPrefDisplay::set_topSplitter(ui.topSplitter->saveState()); - qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState()); + QSettings settings; + settings.beginGroup("MainWindow"); + settings.setValue("mainSplitter", ui.mainSplitter->saveState()); + settings.setValue("topSplitter", ui.topSplitter->saveState()); + settings.setValue("bottomSplitter", ui.bottomSplitter->saveState()); } void MainWindow::on_actionPreviousDC_triggered() @@ -1458,14 +1464,17 @@ bool MainWindow::askSaveChanges() void MainWindow::initialUiSetup() { - if (qPrefDisplay::maximized()) { + QSettings settings; + settings.beginGroup("MainWindow"); + if (settings.value("maximized", isMaximized()).value<bool>()) { showMaximized(); } else { - restoreGeometry(qPrefDisplay::geometry()); - restoreState(qPrefDisplay::windowState()); + restoreGeometry(settings.value("geometry").toByteArray()); + restoreState(settings.value("windowState", 0).toByteArray()); } - enterState((CurrentState)qPrefDisplay::lastState()); + enterState((CurrentState)settings.value("lastState", 0).toInt()); + settings.endGroup(); show(); } @@ -1497,7 +1506,7 @@ void MainWindow::checkSurvey() // wait a week for production versions, but not at all for non-tagged builds int waitTime = 7; QDate firstUse42 = s.value("FirstUse42").toDate(); - if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && qPrefDisplay::UserSurvey() == "")) { + if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s.contains("SurveyDone"))) { if (!survey) survey = new UserSurvey(this); survey->show(); @@ -1507,12 +1516,16 @@ void MainWindow::checkSurvey() void MainWindow::writeSettings() { - qPrefDisplay::set_geometry(saveGeometry()); - qPrefDisplay::set_windowState(saveState()); - qPrefDisplay::set_maximized(isMaximized()); - qPrefDisplay::set_lastState((int)state); + QSettings settings; + + settings.beginGroup("MainWindow"); + settings.setValue("geometry", saveGeometry()); + settings.setValue("windowState", saveState()); + settings.setValue("maximized", isMaximized()); + settings.setValue("lastState", (int)state); if (state == VIEWALL) saveSplitterSizes(); + settings.endGroup(); } void MainWindow::closeEvent(QCloseEvent *event) |