[PATCH] Load preferences before they are saved.
Michael Andreen
harv at ruin.nu
Sat Feb 8 09:07:06 UTC 2014
Load all the settings in the PreferenceDialog constructor. Previously
all the settings were overwritten with default values the first time
PreferencesDialog::syncSettings() was called.
Signed-off-by: Michael Andreen <harv at ruin.nu>
---
qt-ui/preferences.cpp | 10 +++++++++-
qt-ui/preferences.h | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index cb8dde8..2a49a43 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -20,6 +20,7 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
connect(ui.gflow, SIGNAL(valueChanged(int)), this, SLOT(gflowChanged(int)));
connect(ui.gfhigh, SIGNAL(valueChanged(int)), this, SLOT(gfhighChanged(int)));
+ loadSettings();
setUiFromPrefs();
rememberPrefs();
}
@@ -245,10 +246,18 @@ void PreferencesDialog::syncSettings()
s.setValue("UseSystemLanguage", ui.languageSystemDefault->isChecked());
s.setValue("UiLanguage", ui.languageView->currentIndex().data(Qt::UserRole));
s.endGroup();
+
+ loadSettings();
+ emit settingsChanged();
+}
+
+void PreferencesDialog::loadSettings()
+{
// This code was on the mainwindow, it should belong nowhere, but since we dind't
// correctly fixed this code yet ( too much stuff on the code calling preferences )
// force this here.
+ QSettings s;
QVariant v;
s.beginGroup("Units");
if (s.value("unit_system").toString() == "metric") {
@@ -304,7 +313,6 @@ void PreferencesDialog::syncSettings()
GET_INT("font_size", font_size);
GET_INT("displayinvalid", display_invalid_dives);
s.endGroup();
- emit settingsChanged();
}
void PreferencesDialog::buttonClicked(QAbstractButton* button)
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index a309141..d7cf775 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -21,6 +21,7 @@ public slots:
void buttonClicked(QAbstractButton* button);
void on_chooseFile_clicked();
void syncSettings();
+ void loadSettings();
void restorePrefs();
void rememberPrefs();
void gflowChanged(int gf);
--
1.8.3.2
More information about the subsurface
mailing list