diff options
author | Jan Mulder <jlmulder@xs4all.nl> | 2017-03-24 19:11:31 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-03-28 11:17:03 -0700 |
commit | bb31c77597f28976eb4784318fa7b01a28f3942b (patch) | |
tree | fc3c7c04dc0dcf89d51554289dd5537f9ff5c95e /core | |
parent | 1d0281c9234e44ce4804f8c7f376cd9d4ee68f54 (diff) | |
download | subsurface-bb31c77597f28976eb4784318fa7b01a28f3942b.tar.gz |
minimal pO2 threshold: split max threshold into min and max
Nothing really special here. Just a split of the only p02 max threshold into
a min threshold and max threshold, and the adaptation of the UI. Change of
translatable strings included.
ref: https://github.com/Subsurface-divelog/subsurface/issues/259
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'core')
-rw-r--r-- | core/pref.h | 3 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 35 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 22 | ||||
-rw-r--r-- | core/subsurfacestartup.c | 3 |
4 files changed, 44 insertions, 19 deletions
diff --git a/core/pref.h b/core/pref.h index 9122800bb..9cefd0812 100644 --- a/core/pref.h +++ b/core/pref.h @@ -14,7 +14,8 @@ typedef struct short po2; short pn2; short phe; - double po2_threshold; + double po2_threshold_min; + double po2_threshold_max; double pn2_threshold; double phe_threshold; } partial_pressure_graphs_t; diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index f5d2e0f9a..a22b0c015 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -166,11 +166,17 @@ short PartialPressureGasSettings::showPhe() const return prefs.pp_graphs.phe; } -double PartialPressureGasSettings::po2Threshold() const +double PartialPressureGasSettings::po2ThresholdMin() const { - return prefs.pp_graphs.po2_threshold; + return prefs.pp_graphs.po2_threshold_min; } +double PartialPressureGasSettings::po2ThresholdMax() const +{ + return prefs.pp_graphs.po2_threshold_max; +} + + double PartialPressureGasSettings::pn2Threshold() const { return prefs.pp_graphs.pn2_threshold; @@ -217,16 +223,28 @@ void PartialPressureGasSettings::setShowPhe(short value) emit showPheChanged(value); } -void PartialPressureGasSettings::setPo2Threshold(double value) +void PartialPressureGasSettings::setPo2ThresholdMin(double value) +{ + if (value == prefs.pp_graphs.po2_threshold_min) + return; + + QSettings s; + s.beginGroup(group); + s.setValue("po2thresholdmin", value); + prefs.pp_graphs.po2_threshold_min = value; + emit po2ThresholdMinChanged(value); +} + +void PartialPressureGasSettings::setPo2ThresholdMax(double value) { - if (value == prefs.pp_graphs.po2_threshold) + if (value == prefs.pp_graphs.po2_threshold_max) return; QSettings s; s.beginGroup(group); - s.setValue("po2threshold", value); - prefs.pp_graphs.po2_threshold = value; - emit po2ThresholdChanged(value); + s.setValue("po2thresholdmax", value); + prefs.pp_graphs.po2_threshold_max = value; + emit po2ThresholdMaxChanged(value); } void PartialPressureGasSettings::setPn2Threshold(double value) @@ -2167,7 +2185,8 @@ void SettingsObjectWrapper::load() GET_BOOL("po2graph", pp_graphs.po2); GET_BOOL("pn2graph", pp_graphs.pn2); GET_BOOL("phegraph", pp_graphs.phe); - GET_DOUBLE("po2threshold", pp_graphs.po2_threshold); + GET_DOUBLE("po2thresholdmin", pp_graphs.po2_threshold_min); + GET_DOUBLE("po2thresholdmax", pp_graphs.po2_threshold_max); GET_DOUBLE("pn2threshold", pp_graphs.pn2_threshold); GET_DOUBLE("phethreshold", pp_graphs.phe_threshold); GET_BOOL("mod", mod); diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index 1d35dd5d5..51cf4b0ae 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -69,19 +69,21 @@ 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(double po2_threshold READ po2Threshold WRITE setPo2Threshold NOTIFY po2ThresholdChanged) - Q_PROPERTY(double pn2_threshold READ pn2Threshold WRITE setPn2Threshold NOTIFY pn2ThresholdChanged) - Q_PROPERTY(double phe_threshold READ pheThreshold WRITE setPheThreshold NOTIFY pheThresholdChanged) + 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(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) + Q_PROPERTY(double phe_threshold READ pheThreshold WRITE setPheThreshold NOTIFY pheThresholdChanged) public: PartialPressureGasSettings(QObject *parent); short showPo2() const; short showPn2() const; short showPhe() const; - double po2Threshold() const; + double po2ThresholdMin() const; + double po2ThresholdMax() const; double pn2Threshold() const; double pheThreshold() const; @@ -89,7 +91,8 @@ public slots: void setShowPo2(short value); void setShowPn2(short value); void setShowPhe(short value); - void setPo2Threshold(double value); + void setPo2ThresholdMin(double value); + void setPo2ThresholdMax(double value); void setPn2Threshold(double value); void setPheThreshold(double value); @@ -97,7 +100,8 @@ signals: void showPo2Changed(short value); void showPn2Changed(short value); void showPheChanged(short value); - void po2ThresholdChanged(double value); + void po2ThresholdMaxChanged(double value); + void po2ThresholdMinChanged(double value); void pn2ThresholdChanged(double value); void pheThresholdChanged(double value); diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c index 89ecbd2fb..c2ab42583 100644 --- a/core/subsurfacestartup.c +++ b/core/subsurfacestartup.c @@ -20,7 +20,8 @@ struct preferences default_prefs = { .po2 = false, .pn2 = false, .phe = false, - .po2_threshold = 1.6, + .po2_threshold_min = 0.16, + .po2_threshold_max = 1.6, .pn2_threshold = 4.0, .phe_threshold = 13.0, }, |