From dd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 18 Nov 2017 16:06:41 +0100 Subject: Make handling of booleans consistent on the C++-side of preferences In general, the C++-side of the preferences code consistently uses the bool data type for boolean settings. There are five exceptions, which use short instead: showPo2 showPn2 showPhe saveUserIdLocal displayInvalidDives This patch attempts to make the code more consistent by turning these into bools as well. Tests showed that writing as short and reading as bool is handled gracefully by the Qt variant code. Therefore, an upgrade should not cause user-visible changes to their settings. As a bonus, two extern declarations of the set_save_userid_local() function, which is not defined anywhere, were removed. Signed-off-by: Berthold Stoeger --- core/subsurface-qt/SettingsObjectWrapper.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'core/subsurface-qt/SettingsObjectWrapper.cpp') diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 16f4471ed..7fc738461 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -169,17 +169,17 @@ PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent): } -short PartialPressureGasSettings::showPo2() const +bool PartialPressureGasSettings::showPo2() const { return prefs.pp_graphs.po2; } -short PartialPressureGasSettings::showPn2() const +bool PartialPressureGasSettings::showPn2() const { return prefs.pp_graphs.pn2; } -short PartialPressureGasSettings::showPhe() const +bool PartialPressureGasSettings::showPhe() const { return prefs.pp_graphs.phe; } @@ -205,7 +205,7 @@ double PartialPressureGasSettings::pheThreshold() const return prefs.pp_graphs.phe_threshold; } -void PartialPressureGasSettings::setShowPo2(short value) +void PartialPressureGasSettings::setShowPo2(bool value) { if (value == prefs.pp_graphs.po2) return; @@ -217,7 +217,7 @@ void PartialPressureGasSettings::setShowPo2(short value) emit showPo2Changed(value); } -void PartialPressureGasSettings::setShowPn2(short value) +void PartialPressureGasSettings::setShowPn2(bool value) { if (value == prefs.pp_graphs.pn2) return; @@ -229,7 +229,7 @@ void PartialPressureGasSettings::setShowPn2(short value) emit showPn2Changed(value); } -void PartialPressureGasSettings::setShowPhe(short value) +void PartialPressureGasSettings::setShowPhe(bool value) { if (value == prefs.pp_graphs.phe) return; @@ -1092,7 +1092,7 @@ void CloudStorageSettings::setBackgroundSync(bool value) emit backgroundSyncChanged(value); } -void CloudStorageSettings::setSaveUserIdLocal(short int value) +void CloudStorageSettings::setSaveUserIdLocal(bool value) { //TODO: this is not saved on disk? if (value == prefs.save_userid_local) @@ -1101,7 +1101,7 @@ void CloudStorageSettings::setSaveUserIdLocal(short int value) emit saveUserIdLocalChanged(value); } -short int CloudStorageSettings::saveUserIdLocal() const +bool CloudStorageSettings::saveUserIdLocal() const { return prefs.save_userid_local; } @@ -1895,7 +1895,7 @@ double DisplaySettingsObjectWrapper::fontSize() const return prefs.font_size; } -short DisplaySettingsObjectWrapper::displayInvalidDives() const +bool DisplaySettingsObjectWrapper::displayInvalidDives() const { return prefs.display_invalid_dives; } @@ -1937,7 +1937,7 @@ void DisplaySettingsObjectWrapper::setFontSize(double value) emit fontSizeChanged(value); } -void DisplaySettingsObjectWrapper::setDisplayInvalidDives(short value) +void DisplaySettingsObjectWrapper::setDisplayInvalidDives(bool value) { if (value == prefs.display_invalid_dives) return; @@ -2272,7 +2272,7 @@ void SettingsObjectWrapper::load() } defaultFont.setPointSizeF(prefs.font_size); qApp->setFont(defaultFont); - GET_INT("displayinvalid", display_invalid_dives); + GET_BOOL("displayinvalid", display_invalid_dives); s.endGroup(); s.beginGroup("Animations"); -- cgit v1.2.3-70-g09d2