mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +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 <QGraphicsSceneMouseEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#define TIME_INITIAL_MAX 30
|
#define TIME_INITIAL_MAX 30
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#include "desktop-widgets/subsurfacewebservices.h"
|
#include "desktop-widgets/subsurfacewebservices.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/cloudstorage.h"
|
#include "core/cloudstorage.h"
|
||||||
|
#include "core/settings/qPrefGeneral.h"
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
DiveShareExportDialog::DiveShareExportDialog(QWidget *parent) :
|
DiveShareExportDialog::DiveShareExportDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -43,12 +43,11 @@ void DiveShareExportDialog::prepareDivesForUpload(bool selected)
|
||||||
ui->frameConfigure->setVisible(true);
|
ui->frameConfigure->setVisible(true);
|
||||||
ui->frameResults->setVisible(false);
|
ui->frameResults->setVisible(false);
|
||||||
|
|
||||||
QSettings settings;
|
if (qPrefGeneral::diveshareExport_uid() != "")
|
||||||
if (settings.contains("diveshareExport/uid"))
|
ui->txtUID->setText(qPrefGeneral::diveshareExport_uid());
|
||||||
ui->txtUID->setText(settings.value("diveshareExport/uid").toString());
|
|
||||||
|
|
||||||
if (settings.contains("diveshareExport/private"))
|
if (qPrefGeneral::diveshareExport_private())
|
||||||
ui->chkPrivate->setChecked(settings.value("diveshareExport/private").toBool());
|
ui->chkPrivate->setChecked(qPrefGeneral::diveshareExport_private());
|
||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
@ -108,9 +107,8 @@ void DiveShareExportDialog::finishedSlot()
|
||||||
void DiveShareExportDialog::doUpload()
|
void DiveShareExportDialog::doUpload()
|
||||||
{
|
{
|
||||||
//Store current settings
|
//Store current settings
|
||||||
QSettings settings;
|
qPrefGeneral::set_diveshareExport_uid(ui->txtUID->text());
|
||||||
settings.setValue("diveshareExport/uid", ui->txtUID->text());
|
qPrefGeneral::set_diveshareExport_private(ui->chkPrivate->isChecked());
|
||||||
settings.setValue("diveshareExport/private", ui->chkPrivate->isChecked());
|
|
||||||
|
|
||||||
//Change UI into results mode
|
//Change UI into results mode
|
||||||
ui->frameConfigure->setVisible(false);
|
ui->frameConfigure->setVisible(false);
|
||||||
|
|
|
@ -1182,12 +1182,10 @@ void MainWindow::on_actionViewAll_triggered()
|
||||||
listGlobeSizes.append(lrint(appW * 0.3));
|
listGlobeSizes.append(lrint(appW * 0.3));
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings settings;
|
if (qPrefDisplay::mainSplitter() != "") {
|
||||||
settings.beginGroup("MainWindow");
|
ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter());
|
||||||
if (settings.value("mainSplitter").isValid()) {
|
ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
|
||||||
ui.mainSplitter->restoreState(settings.value("mainSplitter").toByteArray());
|
ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter());
|
||||||
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)
|
if (ui.mainSplitter->sizes().first() == 0 || ui.mainSplitter->sizes().last() == 0)
|
||||||
ui.mainSplitter->setSizes(mainSizes);
|
ui.mainSplitter->setSizes(mainSizes);
|
||||||
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
||||||
|
@ -1220,10 +1218,8 @@ void MainWindow::enterEditState()
|
||||||
int appW = qApp->desktop()->size().width();
|
int appW = qApp->desktop()->size().width();
|
||||||
QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) };
|
QList<int> infoProfileSizes { (int)lrint(appW * 0.3), (int)lrint(appW * 0.7) };
|
||||||
|
|
||||||
QSettings settings;
|
if (qPrefDisplay::mainSplitter() != "") {
|
||||||
settings.beginGroup("MainWindow");
|
ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
|
||||||
if (settings.value("mainSplitter").isValid()) {
|
|
||||||
ui.topSplitter->restoreState(settings.value("topSplitter").toByteArray());
|
|
||||||
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
||||||
ui.topSplitter->setSizes(infoProfileSizes);
|
ui.topSplitter->setSizes(infoProfileSizes);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1273,11 +1269,9 @@ void MainWindow::beginChangeState(CurrentState s)
|
||||||
|
|
||||||
void MainWindow::saveSplitterSizes()
|
void MainWindow::saveSplitterSizes()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState());
|
||||||
settings.beginGroup("MainWindow");
|
qPrefDisplay::set_topSplitter(ui.topSplitter->saveState());
|
||||||
settings.setValue("mainSplitter", ui.mainSplitter->saveState());
|
qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState());
|
||||||
settings.setValue("topSplitter", ui.topSplitter->saveState());
|
|
||||||
settings.setValue("bottomSplitter", ui.bottomSplitter->saveState());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPreviousDC_triggered()
|
void MainWindow::on_actionPreviousDC_triggered()
|
||||||
|
@ -1464,17 +1458,14 @@ bool MainWindow::askSaveChanges()
|
||||||
|
|
||||||
void MainWindow::initialUiSetup()
|
void MainWindow::initialUiSetup()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
if (qPrefDisplay::maximized()) {
|
||||||
settings.beginGroup("MainWindow");
|
|
||||||
if (settings.value("maximized", isMaximized()).value<bool>()) {
|
|
||||||
showMaximized();
|
showMaximized();
|
||||||
} else {
|
} else {
|
||||||
restoreGeometry(settings.value("geometry").toByteArray());
|
restoreGeometry(qPrefDisplay::geometry());
|
||||||
restoreState(settings.value("windowState", 0).toByteArray());
|
restoreState(qPrefDisplay::windowState());
|
||||||
}
|
}
|
||||||
|
|
||||||
enterState((CurrentState)settings.value("lastState", 0).toInt());
|
enterState((CurrentState)qPrefDisplay::lastState());
|
||||||
settings.endGroup();
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1506,7 +1497,7 @@ void MainWindow::checkSurvey()
|
||||||
// wait a week for production versions, but not at all for non-tagged builds
|
// wait a week for production versions, but not at all for non-tagged builds
|
||||||
int waitTime = 7;
|
int waitTime = 7;
|
||||||
QDate firstUse42 = s.value("FirstUse42").toDate();
|
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)
|
if (!survey)
|
||||||
survey = new UserSurvey(this);
|
survey = new UserSurvey(this);
|
||||||
survey->show();
|
survey->show();
|
||||||
|
@ -1516,16 +1507,12 @@ void MainWindow::checkSurvey()
|
||||||
|
|
||||||
void MainWindow::writeSettings()
|
void MainWindow::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
qPrefDisplay::set_geometry(saveGeometry());
|
||||||
|
qPrefDisplay::set_windowState(saveState());
|
||||||
settings.beginGroup("MainWindow");
|
qPrefDisplay::set_maximized(isMaximized());
|
||||||
settings.setValue("geometry", saveGeometry());
|
qPrefDisplay::set_lastState((int)state);
|
||||||
settings.setValue("windowState", saveState());
|
|
||||||
settings.setValue("maximized", isMaximized());
|
|
||||||
settings.setValue("lastState", (int)state);
|
|
||||||
if (state == VIEWALL)
|
if (state == VIEWALL)
|
||||||
saveSplitterSizes();
|
saveSplitterSizes();
|
||||||
settings.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
|
|
|
@ -27,7 +27,6 @@ class QItemSelection;
|
||||||
class DiveListView;
|
class DiveListView;
|
||||||
class MainTab;
|
class MainTab;
|
||||||
class QWebView;
|
class QWebView;
|
||||||
class QSettings;
|
|
||||||
class UpdateManager;
|
class UpdateManager;
|
||||||
class UserManual;
|
class UserManual;
|
||||||
class DivePlannerWidget;
|
class DivePlannerWidget;
|
||||||
|
|
|
@ -32,12 +32,6 @@ void PreferencesDialog::emitSettingsChanged()
|
||||||
|
|
||||||
PreferencesDialog::PreferencesDialog()
|
PreferencesDialog::PreferencesDialog()
|
||||||
{
|
{
|
||||||
//FIXME: This looks wrong.
|
|
||||||
//QSettings s;
|
|
||||||
//s.beginGroup("GeneralSettings");
|
|
||||||
//s.setValue("default_directory", system_default_directory());
|
|
||||||
//s.endGroup();
|
|
||||||
|
|
||||||
setWindowIcon(QIcon(":subsurface-icon"));
|
setWindowIcon(QIcon(":subsurface-icon"));
|
||||||
pagesList = new QListWidget();
|
pagesList = new QListWidget();
|
||||||
pagesStack = new QStackedWidget();
|
pagesStack = new QStackedWidget();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include "desktop-widgets/usersurvey.h"
|
#include "desktop-widgets/usersurvey.h"
|
||||||
#include "ui_usersurvey.h"
|
#include "ui_usersurvey.h"
|
||||||
|
@ -11,6 +10,7 @@
|
||||||
|
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/subsurfacesysinfo.h"
|
#include "core/subsurfacesysinfo.h"
|
||||||
|
#include "core/settings/qPrefDisplay.h"
|
||||||
|
|
||||||
UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent),
|
UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent),
|
||||||
ui(new Ui::UserSurvey)
|
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
|
// nothing to do here, we'll just ask again the next time they start
|
||||||
break;
|
break;
|
||||||
case QDialog::Rejected:
|
case QDialog::Rejected:
|
||||||
QSettings s;
|
qPrefDisplay::set_UserSurvey("declined");
|
||||||
s.beginGroup("UserSurvey");
|
|
||||||
s.setValue("SurveyDone", "declined");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hide();
|
hide();
|
||||||
|
@ -116,9 +114,7 @@ void UserSurvey::requestReceived()
|
||||||
|
|
||||||
if (responseBody == "OK") {
|
if (responseBody == "OK") {
|
||||||
msgText = tr("Survey successfully submitted.");
|
msgText = tr("Survey successfully submitted.");
|
||||||
QSettings s;
|
qPrefDisplay::set_UserSurvey("submitted");
|
||||||
s.beginGroup("UserSurvey");
|
|
||||||
s.setValue("SurveyDone", "submitted");
|
|
||||||
} else {
|
} else {
|
||||||
msgText = tr("There was an error while trying to check for updates.<br/><br/>%1").arg(responseBody);
|
msgText = tr("There was an error while trying to check for updates.<br/><br/>%1").arg(responseBody);
|
||||||
msgbox.setIcon(QMessageBox::Warning);
|
msgbox.setIcon(QMessageBox::Warning);
|
||||||
|
|
Loading…
Reference in a new issue