diff options
author | Tomaz Canabrava <tomaz.canabrava@gmail.com> | 2016-08-26 16:01:31 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-08-27 11:40:45 -0700 |
commit | f8f87b729472357613dee873febbf59bb965b495 (patch) | |
tree | 5625f8bd3eecc80bbb0b89a1b2fb3f6ee700b6ef /core/subsurface-qt | |
parent | 12eccda523da4e25a29aaaae441acfc5ad7825d1 (diff) | |
download | subsurface-f8f87b729472357613dee873febbf59bb965b495.tar.gz |
Settings update: Move preferences sync / initialization
Move Preferences sync / initialization out of the planner
widget prerferences to the ObjectWrapper.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 61 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 2 |
2 files changed, 63 insertions, 0 deletions
diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index 7c6001984..6145e277a 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1743,6 +1743,67 @@ QObject(parent), { } +void SettingsObjectWrapper::load() +{ + QSettings s; + s.beginGroup("Planner"); + prefs.last_stop = s.value("last_stop", prefs.last_stop).toBool(); + prefs.verbatim_plan = s.value("verbatim_plan", prefs.verbatim_plan).toBool(); + prefs.display_duration = s.value("display_duration", prefs.display_duration).toBool(); + prefs.display_runtime = s.value("display_runtime", prefs.display_runtime).toBool(); + prefs.display_transitions = s.value("display_transitions", prefs.display_transitions).toBool(); + prefs.deco_mode = deco_mode(s.value("deco_mode", prefs.deco_mode).toInt()); + prefs.safetystop = s.value("safetystop", prefs.safetystop).toBool(); + prefs.reserve_gas = s.value("reserve_gas", prefs.reserve_gas).toInt(); + prefs.ascrate75 = s.value("ascrate75", prefs.ascrate75).toInt(); + prefs.ascrate50 = s.value("ascrate50", prefs.ascrate50).toInt(); + prefs.ascratestops = s.value("ascratestops", prefs.ascratestops).toInt(); + prefs.ascratelast6m = s.value("ascratelast6m", prefs.ascratelast6m).toInt(); + prefs.descrate = s.value("descrate", prefs.descrate).toInt(); + prefs.bottompo2 = s.value("bottompo2", prefs.bottompo2).toInt(); + prefs.decopo2 = s.value("decopo2", prefs.decopo2).toInt(); + prefs.bestmixend.mm = s.value("bestmixend", prefs.bestmixend.mm).toInt(); + prefs.doo2breaks = s.value("doo2breaks", prefs.doo2breaks).toBool(); + prefs.switch_at_req_stop = s.value("switch_at_req_stop", prefs.switch_at_req_stop).toBool(); + prefs.min_switch_duration = s.value("min_switch_duration", prefs.min_switch_duration).toInt(); + prefs.drop_stone_mode = s.value("drop_stone_mode", prefs.drop_stone_mode).toBool(); + prefs.bottomsac = s.value("bottomsac", prefs.bottomsac).toInt(); + prefs.decosac = s.value("decosac", prefs.decosac).toInt(); + prefs.conservatism_level = s.value("conservatism", prefs.conservatism_level).toInt(); + s.endGroup(); + +} + +void SettingsObjectWrapper::sync() +{ + QSettings s; + s.beginGroup("Planner"); + s.setValue("last_stop", prefs.last_stop); + s.setValue("verbatim_plan", prefs.verbatim_plan); + s.setValue("display_duration", prefs.display_duration); + s.setValue("display_runtime", prefs.display_runtime); + s.setValue("display_transitions", prefs.display_transitions); + s.setValue("safetystop", prefs.safetystop); + s.setValue("reserve_gas", prefs.reserve_gas); + s.setValue("ascrate75", prefs.ascrate75); + s.setValue("ascrate50", prefs.ascrate50); + s.setValue("ascratestops", prefs.ascratestops); + s.setValue("ascratelast6m", prefs.ascratelast6m); + s.setValue("descrate", prefs.descrate); + s.setValue("bottompo2", prefs.bottompo2); + s.setValue("decopo2", prefs.decopo2); + s.setValue("bestmixend", prefs.bestmixend.mm); + s.setValue("doo2breaks", prefs.doo2breaks); + s.setValue("drop_stone_mode", prefs.drop_stone_mode); + s.setValue("switch_at_req_stop", prefs.switch_at_req_stop); + s.setValue("min_switch_duration", prefs.min_switch_duration); + s.setValue("bottomsac", prefs.bottomsac); + s.setValue("decosac", prefs.decosac); + s.setValue("deco_mode", int(prefs.deco_mode)); + s.setValue("conservatism", prefs.conservatism_level); + s.endGroup(); +} + SettingsObjectWrapper* SettingsObjectWrapper::instance() { static SettingsObjectWrapper settings; diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index 472150a42..2f9bffd67 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -695,6 +695,8 @@ public: UpdateManagerSettings *update_manager_settings; DiveComputerSettings *dive_computer_settings; + void sync(); + void load(); private: SettingsObjectWrapper(QObject *parent = NULL); }; |