Some fields in the preference window are not restored correctly, This patch fixes them.
I am not sure if the commit message is clear enough or not.

--
Regards,
Gehad Elrobey

>From 5f7308f07b5a1921d5eb11018399ea8a1559275f Mon Sep 17 00:00:00 2001
From: Gehad elrobey <[email protected]>
Date: Mon, 7 Apr 2014 18:45:52 +0200
Subject: [PATCH] Unexpected Behaviour in preference window.

When doing some changes in the preference window then appling,
the 'Close without saving' button is supposed to restore the
previous values. however some fields aren't restored correctly.

-The Animations Slider was never restored to its initial value.
(A new member in the pref struct was added - pref.animation)

-The 'Font' and 'Font size' are restored correctly to the fields
but their effects aren't restored to the UI and that required to
open the prefrences window again and press ok.

Fixes #481

Signed-off-by: Gehad elrobey <[email protected]>
---
 pref.h                | 1 +
 qt-ui/preferences.cpp | 8 +++-----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/pref.h b/pref.h
index c9cb271..4a6b2ad 100644
--- a/pref.h
+++ b/pref.h
@@ -33,6 +33,7 @@ struct preferences {
 	short calc_ndl_tts;
 	short gflow;
 	short gfhigh;
+	short animation;
 	bool gf_low_at_maxdepth;
 	short display_invalid_dives;
 	short unit_system;
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index e49984c..27570dc 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -90,6 +90,7 @@ void PreferencesDialog::setUiFromPrefs()
 	ui.show_average_depth->setChecked(prefs.show_average_depth);
 	ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
 	ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
+	ui.velocitySlider->setValue(prefs.animation);
 
 	QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
 	filterModel->setSourceModel(LanguageModel::instance());
@@ -107,9 +108,6 @@ void PreferencesDialog::setUiFromPrefs()
 		ui.languageView->setCurrentIndex(languages.first());
 
 	s.endGroup();
-	s.beginGroup("Animations");
-	int animVelocity = s.value("animation_speed",500).toInt();
-	ui.velocitySlider->setValue(animVelocity);
 }
 
 void PreferencesDialog::restorePrefs()
@@ -298,8 +296,7 @@ void PreferencesDialog::loadSettings()
 	s.endGroup();
 
 	s.beginGroup("Animations");
-	int animVelocity = s.value("animation_speed",500).toInt();
-	ui.velocitySlider->setValue(animVelocity);
+	GET_INT("animation_speed", animation);
 }
 
 void PreferencesDialog::buttonClicked(QAbstractButton *button)
@@ -307,6 +304,7 @@ void PreferencesDialog::buttonClicked(QAbstractButton *button)
 	switch (ui.buttonBox->standardButton(button)) {
 	case QDialogButtonBox::Discard:
 		restorePrefs();
+		syncSettings();
 		close();
 		break;
 	case QDialogButtonBox::Apply:
-- 
1.8.3.2

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to