diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-09 08:46:18 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-10-09 11:49:29 +0300 |
commit | 78cda85444a9b9ec384e19ec17686f2ce7c307ec (patch) | |
tree | 1e0e74006b7a9afdf7bd9046d1df459122c202ca /core | |
parent | 2cb5d45231b65a713cad0808badde250594b49de (diff) | |
download | subsurface-78cda85444a9b9ec384e19ec17686f2ce7c307ec.tar.gz |
Display units in dive list table based on prefs option
Add a preferences option which enables or disables display of units in the
main dive liste table.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core')
-rw-r--r-- | core/prefs-macros.h | 7 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 17 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 4 | ||||
-rw-r--r-- | core/units.h | 5 |
4 files changed, 31 insertions, 2 deletions
diff --git a/core/prefs-macros.h b/core/prefs-macros.h index 9208fb82e..7648580ef 100644 --- a/core/prefs-macros.h +++ b/core/prefs-macros.h @@ -18,6 +18,13 @@ else \ prefs.units.field = default_prefs.units.field +#define GET_UNIT_INT(name, field) \ + v = s.value(QString(name)); \ + if (v.isValid()) \ + prefs.units.field = v.toInt(); \ + else \ + prefs.units.field = default_prefs.units.field + #define GET_BOOL(name, field) \ v = s.value(QString(name)); \ if (v.isValid()) \ diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 4fcb96580..eb7cf0960 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1631,6 +1631,11 @@ int UnitsSettings::durationUnits() const return prefs.units.duration_units; } +int UnitsSettings::showUnitsTable() const +{ + return prefs.units.show_units_table; +} + QString UnitsSettings::unitSystem() const { return prefs.unit_system == METRIC ? QStringLiteral("metric") @@ -1721,6 +1726,17 @@ void UnitsSettings::setDurationUnits(int value) emit durationUnitChanged(value); } +void UnitsSettings::setShowUnitsTable(int value) +{ + if (value == prefs.units.show_units_table) + return; + QSettings s; + s.beginGroup(group); + s.setValue("show_units_table", value); + prefs.units.show_units_table = value; + emit showUnitsTableChanged(value); +} + void UnitsSettings::setCoordinatesTraditional(bool value) { if (value == prefs.coordinates_traditional) @@ -2197,6 +2213,7 @@ void SettingsObjectWrapper::load() } 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_UNIT_INT("show_units_table", show_units_table); 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 bbc762e28..146acfcce 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -513,6 +513,7 @@ class UnitsSettings : public QObject { 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) + Q_PROPERTY(int show_units_table READ showUnitsTable WRITE setShowUnitsTable NOTIFY showUnitsTableChanged) public: UnitsSettings(QObject *parent = 0); @@ -523,6 +524,7 @@ public: int weight() const; int verticalSpeedTime() const; int durationUnits() const; + int showUnitsTable() const; QString unitSystem() const; bool coordinatesTraditional() const; @@ -534,6 +536,7 @@ public slots: void setWeight(int value); void setVerticalSpeedTime(int value); void setDurationUnits(int value); + void setShowUnitsTable(int value); void setUnitSystem(const QString& value); void setCoordinatesTraditional(bool value); @@ -547,6 +550,7 @@ signals: void unitSystemChanged(const QString& value); void coordinatesTraditionalChanged(bool value); void durationUnitChanged(int value); + void showUnitsTableChanged(int value); private: const QString group = QStringLiteral("Units"); }; diff --git a/core/units.h b/core/units.h index 535103349..d44c50ab4 100644 --- a/core/units.h +++ b/core/units.h @@ -260,6 +260,7 @@ struct units { MINUTES_ONLY, ALWAYS_HOURS } duration_units; + int show_units_table; }; /* @@ -272,13 +273,13 @@ struct units { #define SI_UNITS \ { \ .length = METERS, .volume = LITER, .pressure = BAR, .temperature = CELSIUS, .weight = KG, \ - .vertical_speed_time = MINUTES, .duration_units = MIXED \ + .vertical_speed_time = MINUTES, .duration_units = MIXED, .show_units_table = false \ } #define IMPERIAL_UNITS \ { \ .length = FEET, .volume = CUFT, .pressure = PSI, .temperature = FAHRENHEIT, .weight = LBS, \ - .vertical_speed_time = MINUTES, .duration_units = MIXED \ + .vertical_speed_time = MINUTES, .duration_units = MIXED, .show_units_table = false \ } #ifdef __cplusplus |