summaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt/SettingsObjectWrapper.cpp
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-31 18:40:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-02 08:59:56 -0700
commitaffdc9d39428e5aa50564e3c5cb6a513b7f2a01c (patch)
treec97cd82f4442cdac9ce499dcfb9a4169d4dcc1be /core/subsurface-qt/SettingsObjectWrapper.cpp
parent54335e1ec680216bc0fd15fa880e7dbc23d098a6 (diff)
downloadsubsurface-affdc9d39428e5aa50564e3c5cb6a513b7f2a01c.tar.gz
core: activate qPrefUnits
remove Units from SettingsObjectWrapper and reference qPrefUnits update files using SettingsObjectWrapper/Units to use qPrefUnits this activated qPrefUnits and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/subsurface-qt/SettingsObjectWrapper.cpp')
-rw-r--r--core/subsurface-qt/SettingsObjectWrapper.cpp210
1 files changed, 4 insertions, 206 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp
index 296414be3..7997852e6 100644
--- a/core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -1138,191 +1138,6 @@ void DivePlannerSettings::setDecoMode(deco_mode value)
emit decoModeChanged(value);
}
-UnitsSettings::UnitsSettings(QObject *parent) :
- QObject(parent)
-{
-
-}
-
-int UnitsSettings::length() const
-{
- return prefs.units.length;
-}
-
-int UnitsSettings::pressure() const
-{
- return prefs.units.pressure;
-}
-
-int UnitsSettings::volume() const
-{
- return prefs.units.volume;
-}
-
-int UnitsSettings::temperature() const
-{
- return prefs.units.temperature;
-}
-
-int UnitsSettings::weight() const
-{
- return prefs.units.weight;
-}
-
-int UnitsSettings::verticalSpeedTime() const
-{
- return prefs.units.vertical_speed_time;
-}
-
-int UnitsSettings::durationUnits() const
-{
- return prefs.units.duration_units;
-}
-
-bool UnitsSettings::showUnitsTable() const
-{
- return prefs.units.show_units_table;
-}
-
-QString UnitsSettings::unitSystem() const
-{
- return prefs.unit_system == METRIC ? QStringLiteral("metric")
- : prefs.unit_system == IMPERIAL ? QStringLiteral("imperial")
- : QStringLiteral("personalized");
-}
-
-bool UnitsSettings::coordinatesTraditional() const
-{
- return prefs.coordinates_traditional;
-}
-
-void UnitsSettings::setLength(int value)
-{
- if (value == prefs.units.length)
- return;
-
- QSettings s;
- s.beginGroup(group);
- s.setValue("length", value);
- prefs.units.length = (units::LENGTH) value;
- emit lengthChanged(value);
-}
-
-void UnitsSettings::setPressure(int value)
-{
- if (value == prefs.units.pressure)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("pressure", value);
- prefs.units.pressure = (units::PRESSURE) value;
- emit pressureChanged(value);
-}
-
-void UnitsSettings::setVolume(int value)
-{
- if (value == prefs.units.volume)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("volume", value);
- prefs.units.volume = (units::VOLUME) value;
- emit volumeChanged(value);
-}
-
-void UnitsSettings::setTemperature(int value)
-{
- if (value == prefs.units.temperature)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("temperature", value);
- prefs.units.temperature = (units::TEMPERATURE) value;
- emit temperatureChanged(value);
-}
-
-void UnitsSettings::setWeight(int value)
-{
- if (value == prefs.units.weight)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("weight", value);
- prefs.units.weight = (units::WEIGHT) value;
- emit weightChanged(value);
-}
-
-void UnitsSettings::setVerticalSpeedTime(int value)
-{
- if (value == prefs.units.vertical_speed_time)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("vertical_speed_time", value);
- prefs.units.vertical_speed_time = (units::TIME) 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::setShowUnitsTable(bool 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)
- return;
- QSettings s;
- s.beginGroup(group);
- s.setValue("coordinates", value);
- prefs.coordinates_traditional = value;
- emit coordinatesTraditionalChanged(value);
-}
-
-void UnitsSettings::setUnitSystem(const QString& value)
-{
- short int v = value == QStringLiteral("metric") ? METRIC
- : value == QStringLiteral("imperial")? IMPERIAL
- : PERSONALIZE;
-
- if (v == prefs.unit_system)
- return;
-
- QSettings s;
- s.beginGroup(group);
- s.setValue("unit_system", value);
-
- if (value == QStringLiteral("metric")) {
- prefs.unit_system = METRIC;
- prefs.units = SI_units;
- } else if (value == QStringLiteral("imperial")) {
- prefs.unit_system = IMPERIAL;
- prefs.units = IMPERIAL_units;
- } else {
- prefs.unit_system = PERSONALIZE;
- }
-
- emit unitSystemChanged(value);
- // TODO: emit the other values here?
-}
-
GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
QObject(parent)
{
@@ -1714,7 +1529,7 @@ QObject(parent),
proxy(new qPrefProxy(this)),
cloud_storage(new qPrefCloudStorage(this)),
planner_settings(new DivePlannerSettings(this)),
- unit_settings(new UnitsSettings(this)),
+ unit_settings(new qPrefUnits(this)),
general_settings(new GeneralSettingsObjectWrapper(this)),
display_settings(new qPrefDisplay(this)),
language_settings(new LanguageSettingsObjectWrapper(this)),
@@ -1731,26 +1546,9 @@ void SettingsObjectWrapper::load()
QVariant v;
uiLanguage(NULL);
- s.beginGroup("Units");
- if (s.value("unit_system").toString() == "metric") {
- prefs.unit_system = METRIC;
- prefs.units = SI_units;
- } else if (s.value("unit_system").toString() == "imperial") {
- prefs.unit_system = IMPERIAL;
- prefs.units = IMPERIAL_units;
- } else {
- prefs.unit_system = PERSONALIZE;
- GET_UNIT("length", length, units::FEET, units::METERS);
- GET_UNIT("pressure", pressure, units::PSI, units::BAR);
- GET_UNIT("volume", volume, units::CUFT, units::LITER);
- GET_UNIT("temperature", temperature, units::FAHRENHEIT, units::CELSIUS);
- 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_UNIT_BOOL("show_units_table", show_units_table);
- GET_BOOL("coordinates", coordinates_traditional);
- s.endGroup();
+
+ qPrefUnits::instance()->load();
+
s.beginGroup("TecDetails");
GET_BOOL("po2graph", pp_graphs.po2);
GET_BOOL("pn2graph", pp_graphs.pn2);