diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-05-06 13:44:22 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-05-06 13:49:36 -0700 |
commit | 876b479d695acda652e7b6c81c6b899946d42a85 (patch) | |
tree | cc01ab6c306c94e0d542fd43000d11f62e056cd8 /core/subsurface-qt | |
parent | 38b9185974e4f5199ee8f65bac97dab76b058e41 (diff) | |
download | subsurface-876b479d695acda652e7b6c81c6b899946d42a85.tar.gz |
Wire up duration units preference UI
Now we track the preference, but we don't act on it, yet.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 17 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 2752567ae..25161a904 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1626,6 +1626,11 @@ int UnitsSettings::verticalSpeedTime() const return prefs.units.vertical_speed_time; } +int UnitsSettings::durationUnits() const +{ + return prefs.units.duration_units; +} + QString UnitsSettings::unitSystem() const { return prefs.unit_system == METRIC ? QStringLiteral("metric") @@ -1705,6 +1710,17 @@ void UnitsSettings::setVerticalSpeedTime(int value) emit verticalSpeedTimeChanged(value); } +void UnitsSettings::setDurationUnits(int value) +{ + if (value == prefs.units.duration_units) + return; + QSettings s; + s.beginGroup(group); + s.setValue("duration_units", value); + prefs.units.duration_units = (units::DURATION) value; + emit durationUnitChanged(value); +} + void UnitsSettings::setCoordinatesTraditional(bool value) { if (value == prefs.coordinates_traditional) @@ -2180,6 +2196,7 @@ void SettingsObjectWrapper::load() GET_UNIT("weight", weight, units::LBS, units::KG); } GET_UNIT("vertical_speed_time", vertical_speed_time, units::MINUTES, units::SECONDS); + GET_UNIT3("duration_units", duration_units, units::MIXED, units::ALWAYS_HOURS, units::DURATION); GET_BOOL("coordinates", coordinates_traditional); s.endGroup(); s.beginGroup("TecDetails"); diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index bb0e9db62..7116e682e 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -511,6 +511,7 @@ class UnitsSettings : public QObject { Q_PROPERTY(QString unit_system READ unitSystem WRITE setUnitSystem NOTIFY unitSystemChanged) Q_PROPERTY(bool coordinates_traditional READ coordinatesTraditional WRITE setCoordinatesTraditional NOTIFY coordinatesTraditionalChanged) Q_PROPERTY(int vertical_speed_time READ verticalSpeedTime WRITE setVerticalSpeedTime NOTIFY verticalSpeedTimeChanged) + Q_PROPERTY(int duration_units READ durationUnits WRITE setDurationUnits NOTIFY durationUnitChanged) public: UnitsSettings(QObject *parent = 0); @@ -520,6 +521,7 @@ public: int temperature() const; int weight() const; int verticalSpeedTime() const; + int durationUnits() const; QString unitSystem() const; bool coordinatesTraditional() const; @@ -530,6 +532,7 @@ public slots: void setTemperature(int value); void setWeight(int value); void setVerticalSpeedTime(int value); + void setDurationUnits(int value); void setUnitSystem(const QString& value); void setCoordinatesTraditional(bool value); @@ -542,6 +545,7 @@ signals: void verticalSpeedTimeChanged(int value); void unitSystemChanged(const QString& value); void coordinatesTraditionalChanged(bool value); + void durationUnitChanged(int value); private: const QString group = QStringLiteral("Units"); }; |