mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Revert "desktop-widgets: remove QSettings from desktop-widgets"
This reverts commit 321a920a98
.
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>
This commit is contained in:
parent
4bb72160a6
commit
2d87a657d2
6 changed files with 55 additions and 28 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#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,11 +43,12 @@ void DiveShareExportDialog::prepareDivesForUpload(bool selected)
|
||||||
ui->frameConfigure->setVisible(true);
|
ui->frameConfigure->setVisible(true);
|
||||||
ui->frameResults->setVisible(false);
|
ui->frameResults->setVisible(false);
|
||||||
|
|
||||||
if (qPrefGeneral::diveshareExport_uid() != "")
|
QSettings settings;
|
||||||
ui->txtUID->setText(qPrefGeneral::diveshareExport_uid());
|
if (settings.contains("diveshareExport/uid"))
|
||||||
|
ui->txtUID->setText(settings.value("diveshareExport/uid").toString());
|
||||||
|
|
||||||
if (qPrefGeneral::diveshareExport_private())
|
if (settings.contains("diveshareExport/private"))
|
||||||
ui->chkPrivate->setChecked(qPrefGeneral::diveshareExport_private());
|
ui->chkPrivate->setChecked(settings.value("diveshareExport/private").toBool());
|
||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
@ -107,8 +108,9 @@ void DiveShareExportDialog::finishedSlot()
|
||||||
void DiveShareExportDialog::doUpload()
|
void DiveShareExportDialog::doUpload()
|
||||||
{
|
{
|
||||||
//Store current settings
|
//Store current settings
|
||||||
qPrefGeneral::set_diveshareExport_uid(ui->txtUID->text());
|
QSettings settings;
|
||||||
qPrefGeneral::set_diveshareExport_private(ui->chkPrivate->isChecked());
|
settings.setValue("diveshareExport/uid", ui->txtUID->text());
|
||||||
|
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,10 +1182,12 @@ void MainWindow::on_actionViewAll_triggered()
|
||||||
listGlobeSizes.append(lrint(appW * 0.3));
|
listGlobeSizes.append(lrint(appW * 0.3));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qPrefDisplay::mainSplitter() != "") {
|
QSettings settings;
|
||||||
ui.mainSplitter->restoreState(qPrefDisplay::mainSplitter());
|
settings.beginGroup("MainWindow");
|
||||||
ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
|
if (settings.value("mainSplitter").isValid()) {
|
||||||
ui.bottomSplitter->restoreState(qPrefDisplay::bottomSplitter());
|
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)
|
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)
|
||||||
|
@ -1218,8 +1220,10 @@ 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) };
|
||||||
|
|
||||||
if (qPrefDisplay::mainSplitter() != "") {
|
QSettings settings;
|
||||||
ui.topSplitter->restoreState(qPrefDisplay::topSplitter());
|
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)
|
if (ui.topSplitter->sizes().first() == 0 || ui.topSplitter->sizes().last() == 0)
|
||||||
ui.topSplitter->setSizes(infoProfileSizes);
|
ui.topSplitter->setSizes(infoProfileSizes);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1269,9 +1273,11 @@ void MainWindow::beginChangeState(CurrentState s)
|
||||||
|
|
||||||
void MainWindow::saveSplitterSizes()
|
void MainWindow::saveSplitterSizes()
|
||||||
{
|
{
|
||||||
qPrefDisplay::set_mainSplitter(ui.mainSplitter->saveState());
|
QSettings settings;
|
||||||
qPrefDisplay::set_topSplitter(ui.topSplitter->saveState());
|
settings.beginGroup("MainWindow");
|
||||||
qPrefDisplay::set_bottomSplitter(ui.bottomSplitter->saveState());
|
settings.setValue("mainSplitter", ui.mainSplitter->saveState());
|
||||||
|
settings.setValue("topSplitter", ui.topSplitter->saveState());
|
||||||
|
settings.setValue("bottomSplitter", ui.bottomSplitter->saveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPreviousDC_triggered()
|
void MainWindow::on_actionPreviousDC_triggered()
|
||||||
|
@ -1458,14 +1464,17 @@ bool MainWindow::askSaveChanges()
|
||||||
|
|
||||||
void MainWindow::initialUiSetup()
|
void MainWindow::initialUiSetup()
|
||||||
{
|
{
|
||||||
if (qPrefDisplay::maximized()) {
|
QSettings settings;
|
||||||
|
settings.beginGroup("MainWindow");
|
||||||
|
if (settings.value("maximized", isMaximized()).value<bool>()) {
|
||||||
showMaximized();
|
showMaximized();
|
||||||
} else {
|
} else {
|
||||||
restoreGeometry(qPrefDisplay::geometry());
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||||||
restoreState(qPrefDisplay::windowState());
|
restoreState(settings.value("windowState", 0).toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
enterState((CurrentState)qPrefDisplay::lastState());
|
enterState((CurrentState)settings.value("lastState", 0).toInt());
|
||||||
|
settings.endGroup();
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,7 +1506,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 && qPrefDisplay::UserSurvey() == "")) {
|
if (run_survey || (firstUse42.daysTo(QDate().currentDate()) > waitTime && !s.contains("SurveyDone"))) {
|
||||||
if (!survey)
|
if (!survey)
|
||||||
survey = new UserSurvey(this);
|
survey = new UserSurvey(this);
|
||||||
survey->show();
|
survey->show();
|
||||||
|
@ -1507,12 +1516,16 @@ void MainWindow::checkSurvey()
|
||||||
|
|
||||||
void MainWindow::writeSettings()
|
void MainWindow::writeSettings()
|
||||||
{
|
{
|
||||||
qPrefDisplay::set_geometry(saveGeometry());
|
QSettings settings;
|
||||||
qPrefDisplay::set_windowState(saveState());
|
|
||||||
qPrefDisplay::set_maximized(isMaximized());
|
settings.beginGroup("MainWindow");
|
||||||
qPrefDisplay::set_lastState((int)state);
|
settings.setValue("geometry", saveGeometry());
|
||||||
|
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,6 +27,7 @@ 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,6 +32,12 @@ 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,6 +1,7 @@
|
||||||
// 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"
|
||||||
|
@ -10,7 +11,6 @@
|
||||||
|
|
||||||
#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,7 +88,9 @@ 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:
|
||||||
qPrefDisplay::set_UserSurvey("declined");
|
QSettings s;
|
||||||
|
s.beginGroup("UserSurvey");
|
||||||
|
s.setValue("SurveyDone", "declined");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hide();
|
hide();
|
||||||
|
@ -114,7 +116,9 @@ void UserSurvey::requestReceived()
|
||||||
|
|
||||||
if (responseBody == "OK") {
|
if (responseBody == "OK") {
|
||||||
msgText = tr("Survey successfully submitted.");
|
msgText = tr("Survey successfully submitted.");
|
||||||
qPrefDisplay::set_UserSurvey("submitted");
|
QSettings s;
|
||||||
|
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