more fixes regarding preferences

On Tue, Nov 1, 2016 at 2:46 PM, Tomaz Canabrava <[email protected]> wrote:

>  bugfixes regarding preferences
>
> still checking for more.
> (the font issue that willem said is fixed on this series)
>
> Tomaz
>
> On Tue, Nov 1, 2016 at 12:06 PM, Tomaz Canabrava <[email protected]>
> wrote:
>
>> FINALLY
>> this finishes the unittests - sorry for all delays.
>>
>> I'll now look for misbehaving preferences, like the one willan complained.
>>
>> Tomaz
>>
>
>
From 8f1755b59a5997d9553a5296e8e27a337affddd4 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 1 Nov 2016 14:57:47 +0100
Subject: [PATCH 10/12] on first run, use system language.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 core/subsurfacestartup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c
index 7534a49..200e23b 100644
--- a/core/subsurfacestartup.c
+++ b/core/subsurfacestartup.c
@@ -83,6 +83,9 @@ struct preferences default_prefs = {
 		.tag_existing_dives = false,
 		.category = { 0 }
 	},
+	.locale = {
+		.use_system_language = true,
+	},
 	.deco_mode = BUEHLMANN,
 	.vpmb_conservatism = 3,
 	.distance_threshold = 1000,
-- 
2.10.2

From d6a7197907ff629bc8a520c1d4ffe5c79bafbbbf Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 1 Nov 2016 15:13:27 +0100
Subject: [PATCH 11/12] Use default values if value doesn't exist

By using the default value argument we can reduce
this code size to a half.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 desktop-widgets/printdialog.cpp | 45 +++++++++++++++--------------------------
 1 file changed, 16 insertions(+), 29 deletions(-)

diff --git a/desktop-widgets/printdialog.cpp b/desktop-widgets/printdialog.cpp
index 72e4d20..5fdc781 100644
--- a/desktop-widgets/printdialog.cpp
+++ b/desktop-widgets/printdialog.cpp
@@ -41,35 +41,22 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) :
 
 	// check if the options were previously stored in the settings; if not use some defaults.
 	QSettings s;
-	bool stored = s.childGroups().contains(SETTINGS_GROUP);
-	if (!stored) {
-		printOptions.print_selected = true;
-		printOptions.color_selected = true;
-		printOptions.landscape = false;
-		printOptions.p_template = "one_dive.html";
-		printOptions.type = print_options::DIVELIST;
-		templateOptions.font_index = 0;
-		templateOptions.font_size = 9;
-		templateOptions.color_palette_index = SSRF_COLORS;
-		templateOptions.line_spacing = 1;
-		custom_colors = ssrf_colors;
-	} else {
-		s.beginGroup(SETTINGS_GROUP);
-		printOptions.type = (print_options::print_type)s.value("type").toInt();
-		printOptions.print_selected = s.value("print_selected").toBool();
-		printOptions.color_selected = s.value("color_selected").toBool();
-		printOptions.landscape = s.value("landscape").toBool();
-		printOptions.p_template = s.value("template_selected").toString();
-		templateOptions.font_index = s.value("font").toInt();
-		templateOptions.font_size = s.value("font_size").toDouble();
-		templateOptions.color_palette_index = s.value("color_palette").toInt();
-		templateOptions.line_spacing = s.value("line_spacing").toDouble();
-		custom_colors.color1 = QColor(s.value("custom_color_1").toString());
-		custom_colors.color2 = QColor(s.value("custom_color_2").toString());
-		custom_colors.color3 = QColor(s.value("custom_color_3").toString());
-		custom_colors.color4 = QColor(s.value("custom_color_4").toString());
-		custom_colors.color5 = QColor(s.value("custom_color_5").toString());
-	}
+	s.beginGroup(SETTINGS_GROUP);
+	printOptions.type = (print_options::print_type)s.value("type", print_options::DIVELIST).toInt();
+	printOptions.print_selected = s.value("print_selected", true).toBool();
+	printOptions.color_selected = s.value("color_selected", true).toBool();
+	printOptions.landscape = s.value("landscape", false).toBool();
+	printOptions.p_template = s.value("template_selected", "one_dive.html").toString();
+	templateOptions.font_index = s.value("font", 0).toInt();
+	templateOptions.font_size = s.value("font_size", 9).toDouble();
+	templateOptions.color_palette_index = s.value("color_palette", SSRF_COLORS).toInt();
+	templateOptions.line_spacing = s.value("line_spacing", 1).toDouble();
+	custom_colors.color1 = QColor(s.value("custom_color_1", ssrf_colors.color1).toString());
+	custom_colors.color2 = QColor(s.value("custom_color_2", ssrf_colors.color2).toString());
+	custom_colors.color3 = QColor(s.value("custom_color_3", ssrf_colors.color3).toString());
+	custom_colors.color4 = QColor(s.value("custom_color_4", ssrf_colors.color4).toString());
+	custom_colors.color5 = QColor(s.value("custom_color_5", ssrf_colors.color5).toString());
+	s.endGroup();
 
 	// handle cases from old QSettings group
 	if (templateOptions.font_size < 9) {
-- 
2.10.2

From 2f07c91f4436f3110ff33e241925708912d31649 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 1 Nov 2016 15:18:12 +0100
Subject: [PATCH 12/12] Use the new preferences object to set the preferences

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 profile-widget/profilewidget2.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index e077bb7..65bdb09 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -748,10 +748,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
 	// so if we are calculation TTS / NDL then let's force that off.
 #ifndef SUBSURFACE_MOBILE
 	if (measureDuration.elapsed() > 1000 && prefs.calcndltts) {
-		prefs.calcndltts = false;
-		QSettings s;
-		s.beginGroup("TecDetails");
-		s.setValue("calcndltts", false);
+		SettingsObjectWrapper::instance()->techDetails->setCalcndltts(false);
 		report_error(qPrintable(tr("Show NDL / TTS was disabled because of excessive processing time")));
 	}
 #endif
-- 
2.10.2

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

Reply via email to