diff options
-rw-r--r-- | desktop-widgets/diveplanner.cpp | 1 | ||||
-rw-r--r-- | desktop-widgets/diveshareexportdialog.cpp | 16 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 49 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.h | 1 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferencesdialog.cpp | 6 | ||||
-rw-r--r-- | desktop-widgets/usersurvey.cpp | 10 |
6 files changed, 28 insertions, 55 deletions
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp index 26e8c446a..63c3a97ec 100644 --- a/desktop-widgets/diveplanner.cpp +++ b/desktop-widgets/diveplanner.cpp @@ -14,7 +14,6 @@ #include <QGraphicsSceneMouseEvent> #include <QMessageBox> -#include <QSettings> #include <QShortcut> #define TIME_INITIAL_MAX 30 diff --git a/desktop-widgets/diveshareexportdialog.cpp b/desktop-widgets/diveshareexportdialog.cpp index 2689eaca8..fc26e0ced 100644 --- a/desktop-widgets/diveshareexportdialog.cpp +++ b/desktop-widgets/diveshareexportdialog.cpp @@ -6,9 +6,9 @@ #include "desktop-widgets/subsurfacewebservices.h" #include "core/qthelper.h" #include "core/cloudstorage.h" +#include "core/settings/qPrefGeneral.h" #include <QDesktopServices> -#include <QSettings> DiveShareExportDialog::DiveShareExportDialog(QWidget *parent) : QDialog(parent), @@ -43,12 +43,11 @@ void DiveShareExportDialog::prepareDivesForUpload(bool selected) ui->frameConfigure->setVisible(true); ui->frameResults->setVisible(false); - QSettings settings; - if (settings.contains("diveshareExport/uid")) - ui->txtUID->setText(settings.value("diveshareExport/uid").toString()); + if (qPrefGeneral::diveshareExport_uid() != "") + ui->txtUID->setText(qPrefGeneral::diveshareExport_uid()); - if (settings.contains("diveshareExport/private")) - ui->chkPrivate->setChecked(settings.value("diveshareExport/private").toBool()); + if (qPrefGeneral::diveshareExport_private()) + ui->chkPrivate->setChecked(qPrefGeneral::diveshareExport_private()); show(); } @@ -108,9 +107,8 @@ void DiveShareExportDialog::finishedSlot() void DiveShareExportDialog::doUpload() { //Store current settings - QSettings settings; - settings.setValue("diveshareExport/uid", ui->txtUID->text()); - settings.setValue("diveshareExport/private", ui->chkPrivate->isChecked()); + qPrefGeneral::set_diveshareExport_uid(ui->txtUID->text()); + qPrefGeneral::set_diveshareExport_private(ui->chkPrivate->isChecked()); //Change UI into results mode ui->frameConfigure->setVisible(false); diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index ea5f31556..f45f27b71 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1182,12 +1182,10 @@ void MainWindow::on_actionViewAll_triggered() listGlobeSizes.append(lrint(appW * 0.3)); } - 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 (qPrefDisplay::mainSplitter() != "") { + ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter()); + ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); + ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter()); 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) @@ -1220,10 +1218,8 @@ void MainWindow::enterEditState() int appW = qApp->desktop()->size().width(); QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) }; - QSettings settings; - settings.beginGroup("MainWindow"); - if (settings.value("mainSplitter").isValid()) { - ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray()); + if (qPrefDisplay::mainSplitter() != "") { + ui.topSplitter->restoreState(qPrefDisplay::topSplitter()); if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0) ui.topSplitter->setSizes(infoProfileSizes); } else { @@ -1273,11 +1269,9 @@ void MainWindow::beginChangeState(CurrentState s) void MainWindow::saveSplitterSizes() { - QSettings settings; - settings.beginGroup("MainWindow"); - settings.setValue("mainSplitter", ui.mainSplitter->saveState()); - settings.setValue("topSplitter", ui.topSplitter->saveState()); - settings.setValue("bottomSplitter", ui.bottomSplitter->saveState()); + qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState()); + qPrefDisplay::set_topSplitter(ui.topSplitter->saveState()); + qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState()); } void MainWindow::on_actionPreviousDC_triggered() @@ -1464,17 +1458,14 @@ bool MainWindow::askSaveChanges() void MainWindow::initialUiSetup() { - QSettings settings; - settings.beginGroup("MainWindow"); - if (settings.value("maximized", isMaximized()).value<bool>()) { + if (qPrefDisplay::maximized()) { showMaximized(); } else { - restoreGeometry(settings.value("geometry").toByteArray()); - restoreState(settings.value("windowState", 0).toByteArray()); + restoreGeometry(qPrefDisplay::geometry()); + restoreState(qPrefDisplay::windowState()); } - enterState((CurrentState)settings.value("lastState", 0).toInt()); - settings.endGroup(); + enterState((CurrentState)qPrefDisplay::lastState()); show(); } @@ -1506,7 +1497,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 && !s.contains("SurveyDone"))) { + if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && qPrefDisplay::UserSurvey() == "")) { if (!survey) survey = new UserSurvey(this); survey->show(); @@ -1516,16 +1507,12 @@ void MainWindow::checkSurvey() void MainWindow::writeSettings() { - QSettings settings; - - settings.beginGroup("MainWindow"); - settings.setValue("geometry", saveGeometry()); - settings.setValue("windowState", saveState()); - settings.setValue("maximized", isMaximized()); - settings.setValue("lastState", (int)state); + qPrefDisplay::set_geometry(saveGeometry()); + qPrefDisplay::set_windowState(saveState()); + qPrefDisplay::set_maximized(isMaximized()); + qPrefDisplay::set_lastState((int)state); if (state == VIEWALL) saveSplitterSizes(); - settings.endGroup(); } void MainWindow::closeEvent(QCloseEvent *event) diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h index 06365a8e6..7bd33cbf0 100644 --- a/desktop-widgets/mainwindow.h +++ b/desktop-widgets/mainwindow.h @@ -27,7 +27,6 @@ class QItemSelection; class DiveListView; class MainTab; class QWebView; -class QSettings; class UpdateManager; class UserManual; class DivePlannerWidget; diff --git a/desktop-widgets/preferences/preferencesdialog.cpp b/desktop-widgets/preferences/preferencesdialog.cpp index 49b1f87bd..3b16260d2 100644 --- a/desktop-widgets/preferences/preferencesdialog.cpp +++ b/desktop-widgets/preferences/preferencesdialog.cpp @@ -32,12 +32,6 @@ void PreferencesDialog::emitSettingsChanged() PreferencesDialog::PreferencesDialog() { - //FIXME: This looks wrong. - //QSettings s; - //s.beginGroup("GeneralSettings"); - //s.setValue("default_directory", system_default_directory()); - //s.endGroup(); - setWindowIcon(QIcon(":subsurface-icon")); pagesList = new QListWidget(); pagesStack = new QStackedWidget(); diff --git a/desktop-widgets/usersurvey.cpp b/desktop-widgets/usersurvey.cpp index 326a51f9e..fdf3e7f95 100644 --- a/desktop-widgets/usersurvey.cpp +++ b/desktop-widgets/usersurvey.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include <QShortcut> #include <QMessageBox> -#include <QSettings> #include "desktop-widgets/usersurvey.h" #include "ui_usersurvey.h" @@ -11,6 +10,7 @@ #include "core/qthelper.h" #include "core/subsurfacesysinfo.h" +#include "core/settings/qPrefDisplay.h" UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), ui(new Ui::UserSurvey) @@ -88,9 +88,7 @@ void UserSurvey::on_buttonBox_rejected() // nothing to do here, we'll just ask again the next time they start break; case QDialog::Rejected: - QSettings s; - s.beginGroup("UserSurvey"); - s.setValue("SurveyDone", "declined"); + qPrefDisplay::set_UserSurvey("declined"); break; } hide(); @@ -116,9 +114,7 @@ void UserSurvey::requestReceived() if (responseBody == "OK") { msgText = tr("Survey successfully submitted."); - QSettings s; - s.beginGroup("UserSurvey"); - s.setValue("SurveyDone", "submitted"); + qPrefDisplay::set_UserSurvey("submitted"); } else { msgText = tr("There was an error while trying to check for updates.<br/><br/>%1").arg(responseBody); msgbox.setIcon(QMessageBox::Warning); |