mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
desktop-widgets: remove QSettings from desktop-widgets
The variables referenced are moved into qPref in earlier commits so in general all QSettings calls are replaced by qPref*:: calls Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
5f4a040dd2
commit
321a920a98
6 changed files with 28 additions and 55 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
#include <QShortcut>
|
||||
|
||||
#define TIME_INITIAL_MAX 30
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -27,7 +27,6 @@ class QItemSelection;
|
|||
class DiveListView;
|
||||
class MainTab;
|
||||
class QWebView;
|
||||
class QSettings;
|
||||
class UpdateManager;
|
||||
class UserManual;
|
||||
class DivePlannerWidget;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue