aboutsummaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-11-18 16:06:41 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-20 20:56:13 +0100
commitdd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6 (patch)
tree5bf0f8872a35f71430733c9766bc70ad65cea499 /core/subsurface-qt
parente762fd2d416cbe77669a83e302709aa3fbda68f7 (diff)
downloadsubsurface-dd8e4fae2aa31f1fac2a8a6f086db0db0a3209c6.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp22
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.h40
2 files changed, 31 insertions, 31 deletions
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");
diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h
index 19cfcdd50..e8fe6a103 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.h
+++ b/core/subsurface-qt/SettingsObjectWrapper.h
@@ -74,9 +74,9 @@ private:
/* Control the state of the Partial Pressure Graphs preferences */
class PartialPressureGasSettings : public QObject {
Q_OBJECT
- Q_PROPERTY(short show_po2 READ showPo2 WRITE setShowPo2 NOTIFY showPo2Changed)
- Q_PROPERTY(short show_pn2 READ showPn2 WRITE setShowPn2 NOTIFY showPn2Changed)
- Q_PROPERTY(short show_phe READ showPhe WRITE setShowPhe NOTIFY showPheChanged)
+ Q_PROPERTY(bool show_po2 READ showPo2 WRITE setShowPo2 NOTIFY showPo2Changed)
+ Q_PROPERTY(bool show_pn2 READ showPn2 WRITE setShowPn2 NOTIFY showPn2Changed)
+ Q_PROPERTY(bool show_phe READ showPhe WRITE setShowPhe NOTIFY showPheChanged)
Q_PROPERTY(double po2_threshold_min READ po2ThresholdMin WRITE setPo2ThresholdMin NOTIFY po2ThresholdMinChanged)
Q_PROPERTY(double po2_threshold_max READ po2ThresholdMax WRITE setPo2ThresholdMax NOTIFY po2ThresholdMaxChanged)
Q_PROPERTY(double pn2_threshold READ pn2Threshold WRITE setPn2Threshold NOTIFY pn2ThresholdChanged)
@@ -84,27 +84,27 @@ class PartialPressureGasSettings : public QObject {
public:
PartialPressureGasSettings(QObject *parent);
- short showPo2() const;
- short showPn2() const;
- short showPhe() const;
+ bool showPo2() const;
+ bool showPn2() const;
+ bool showPhe() const;
double po2ThresholdMin() const;
double po2ThresholdMax() const;
double pn2Threshold() const;
double pheThreshold() const;
public slots:
- void setShowPo2(short value);
- void setShowPn2(short value);
- void setShowPhe(short value);
+ void setShowPo2(bool value);
+ void setShowPn2(bool value);
+ void setShowPhe(bool value);
void setPo2ThresholdMin(double value);
void setPo2ThresholdMax(double value);
void setPn2Threshold(double value);
void setPheThreshold(double value);
signals:
- void showPo2Changed(short value);
- void showPn2Changed(short value);
- void showPheChanged(short value);
+ void showPo2Changed(bool value);
+ void showPn2Changed(bool value);
+ void showPheChanged(bool value);
void po2ThresholdMaxChanged(double value);
void po2ThresholdMinChanged(double value);
void pn2ThresholdChanged(double value);
@@ -328,7 +328,7 @@ class CloudStorageSettings : public QObject {
Q_PROPERTY(QString userid READ userId WRITE setUserId NOTIFY userIdChanged)
Q_PROPERTY(QString base_url READ baseUrl WRITE setBaseUrl NOTIFY baseUrlChanged)
Q_PROPERTY(QString git_url READ gitUrl WRITE setGitUrl NOTIFY gitUrlChanged)
- Q_PROPERTY(short save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged)
+ Q_PROPERTY(bool save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged)
Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged)
Q_PROPERTY(bool save_password_local READ savePasswordLocal WRITE setSavePasswordLocal NOTIFY savePasswordLocalChanged)
Q_PROPERTY(short verification_status READ verificationStatus WRITE setVerificationStatus NOTIFY verificationStatusChanged)
@@ -346,7 +346,7 @@ public:
short verificationStatus() const;
bool backgroundSync() const;
bool gitLocalOnly() const;
- short saveUserIdLocal() const;
+ bool saveUserIdLocal() const;
public slots:
void setPassword(const QString& value);
@@ -360,7 +360,7 @@ public slots:
void setVerificationStatus(short value);
void setBackgroundSync(bool value);
void setGitLocalOnly(bool value);
- void setSaveUserIdLocal(short value);
+ void setSaveUserIdLocal(bool value);
signals:
void passwordChanged(const QString& value);
@@ -374,7 +374,7 @@ signals:
void verificationStatusChanged(short value);
void backgroundSyncChanged(bool value);
void gitLocalOnlyChanged(bool value);
- void saveUserIdLocalChanged(short value);
+ void saveUserIdLocalChanged(bool value);
private:
const QString group = QStringLiteral("CloudStorage");
@@ -592,20 +592,20 @@ class DisplaySettingsObjectWrapper : public QObject {
Q_OBJECT
Q_PROPERTY(QString divelist_font READ divelistFont WRITE setDivelistFont NOTIFY divelistFontChanged)
Q_PROPERTY(double font_size READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
- Q_PROPERTY(short display_invalid_dives READ displayInvalidDives WRITE setDisplayInvalidDives NOTIFY displayInvalidDivesChanged)
+ Q_PROPERTY(bool display_invalid_dives READ displayInvalidDives WRITE setDisplayInvalidDives NOTIFY displayInvalidDivesChanged)
public:
DisplaySettingsObjectWrapper(QObject *parent);
QString divelistFont() const;
double fontSize() const;
- short displayInvalidDives() const;
+ bool displayInvalidDives() const;
public slots:
void setDivelistFont(const QString& value);
void setFontSize(double value);
- void setDisplayInvalidDives(short value);
+ void setDisplayInvalidDives(bool value);
signals:
void divelistFontChanged(const QString& value);
void fontSizeChanged(double value);
- void displayInvalidDivesChanged(short value);
+ void displayInvalidDivesChanged(bool value);
private:
const QString group = QStringLiteral("Display");
};