From 66c4397efd2d825a61e0dab534cb590c8fea4440 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Tue, 16 Oct 2018 19:35:01 +0200 Subject: Preferences: wire-up the deco parameters The deco parameters need special treatment to wire them up to the underlying deco model code. And with the new preferences setup this is a lot of boilerplate. Signed-off-by: Jan Mulder --- core/settings/qPrefTechnicalDetails.cpp | 60 +++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/settings/qPrefTechnicalDetails.cpp b/core/settings/qPrefTechnicalDetails.cpp index d0c00cd24..fcc77863a 100644 --- a/core/settings/qPrefTechnicalDetails.cpp +++ b/core/settings/qPrefTechnicalDetails.cpp @@ -64,9 +64,45 @@ HANDLE_PREFERENCE_BOOL(TechnicalDetails, "display_unused_tanks", display_unused_ HANDLE_PREFERENCE_BOOL(TechnicalDetails, "ead", ead); -HANDLE_PREFERENCE_INT(TechnicalDetails, "gfhigh", gfhigh); +void qPrefTechnicalDetails::set_gfhigh(int value) +{ + if (value != prefs.gfhigh) { + prefs.gfhigh = value; + disk_gfhigh(true); + emit instance()->gfhighChanged(value); + } +} + +void qPrefTechnicalDetails::disk_gfhigh(bool doSync) +{ + if (doSync) { + if (prefs.gfhigh) + qPrefPrivate::propSetValue(keyFromGroupAndName(group, "gfhigh"), prefs.gfhigh, default_prefs.gfhigh); + } else { + prefs.gfhigh = qPrefPrivate::propValue(keyFromGroupAndName(group, "gfhigh"), default_prefs.gfhigh).toInt(); + set_gf(-1, prefs.gfhigh); + } +} -HANDLE_PREFERENCE_INT(TechnicalDetails, "gflow", gflow); +void qPrefTechnicalDetails::set_gflow(int value) +{ + if (value != prefs.gflow) { + prefs.gflow = value; + disk_gflow(true); + emit instance()->gflowChanged(value); + } +} + +void qPrefTechnicalDetails::disk_gflow(bool doSync) +{ + if (doSync) { + if (prefs.gflow) + qPrefPrivate::propSetValue(keyFromGroupAndName(group, "gflow"), prefs.gflow, default_prefs.gflow); + } else { + prefs.gflow = qPrefPrivate::propValue(keyFromGroupAndName(group, "gflow"), default_prefs.gflow).toInt(); + set_gf(prefs.gflow, -1); + } +} HANDLE_PREFERENCE_BOOL(TechnicalDetails, "gf_low_at_maxdepth", gf_low_at_maxdepth); @@ -98,6 +134,24 @@ HANDLE_PREFERENCE_BOOL(TechnicalDetails, "show_scr_ocpo2", show_scr_ocpo2); HANDLE_PREFERENCE_BOOL(TechnicalDetails, "tankbar", tankbar); -HANDLE_PREFERENCE_INT(TechnicalDetails, "vpmb_conservatism", vpmb_conservatism); +void qPrefTechnicalDetails::set_vpmb_conservatism(int value) +{ + if (value != prefs.vpmb_conservatism) { + prefs.vpmb_conservatism = value; + disk_vpmb_conservatism(true); + emit instance()->vpmb_conservatismChanged(value); + } +} + +void qPrefTechnicalDetails::disk_vpmb_conservatism(bool doSync) +{ + if (doSync) { + if (prefs.vpmb_conservatism) + qPrefPrivate::propSetValue(keyFromGroupAndName(group, "vpmb_conservatism"), prefs.vpmb_conservatism, default_prefs.vpmb_conservatism); + } else { + prefs.vpmb_conservatism = qPrefPrivate::propValue(keyFromGroupAndName(group, "vpmb_conservatism"), default_prefs.vpmb_conservatism).toInt(); + set_vpmb_conservatism(prefs.vpmb_conservatism); + } +} HANDLE_PREFERENCE_BOOL(TechnicalDetails, "zoomed_plot", zoomed_plot); -- cgit v1.2.3-70-g09d2