[PATCH] Set the prefs-value alongside the button status

Anton Lundin glance at acc.umu.se
Sun Mar 2 13:37:29 PST 2014


Previous code just set the button-"status" based on what we stored on
the settings. This sets the corresponding value in our prefs-struct.

This fixes the same issue as in 63f7f3, without the side effect of
magically hiding the mean depth line.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 qt-ui/mainwindow.cpp | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 43e55ba..43f596e 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -620,6 +620,10 @@ void MainWindow::initialUiSetup()
 	settings.endGroup();
 }
 
+#define TOOLBOX_PREF_BUTTON(pref, setting, button) \
+	prefs.pref = s.value(#setting).toBool(); \
+	ui.button->setChecked(prefs.pref);
+
 void MainWindow::readSettings()
 {
 	QSettings s;
@@ -630,20 +634,22 @@ void MainWindow::readSettings()
 	s.endGroup();
 
 	s.beginGroup("TecDetails");
-	ui.profCalcAllTissues->setChecked(s.value("calcalltissues").toBool());
-	ui.profCalcCeiling->setChecked(s.value("calcceiling").toBool());
-	ui.profDcCeiling->setChecked(s.value("dcceiling").toBool());
-	ui.profEad->setChecked(s.value("ead").toBool());
-	ui.profIncrement3m->setChecked(s.value("calcceiling3m").toBool());
-	ui.profMod->setChecked(s.value("mod").toBool());
-	ui.profNdl_tts->setChecked(s.value("calcndltts").toBool());
-	ui.profPhe->setChecked(s.value("phegraph").toBool());
-	ui.profPn2->setChecked(s.value("pn2graph").toBool());
-	ui.profPO2->setChecked(s.value("po2graph").toBool());
+	TOOLBOX_PREF_BUTTON(calc_all_tissues, calcalltissues, profCalcAllTissues);
+	TOOLBOX_PREF_BUTTON(profile_calc_ceiling, calcceiling, profCalcCeiling);
+	TOOLBOX_PREF_BUTTON(profile_dc_ceiling, dcceiling, profDcCeiling);
+	TOOLBOX_PREF_BUTTON(ead, ead, profEad);
+	TOOLBOX_PREF_BUTTON(calc_ceiling_3m_incr, calcceiling3m, profIncrement3m);
+	TOOLBOX_PREF_BUTTON(mod, mod, profMod);
+	TOOLBOX_PREF_BUTTON(calc_ndl_tts, calcndltts, profNdl_tts);
+	TOOLBOX_PREF_BUTTON(pp_graphs.phe, phegraph, profPhe);
+	TOOLBOX_PREF_BUTTON(pp_graphs.pn2, pn2graph, profPn2);
+	TOOLBOX_PREF_BUTTON(pp_graphs.po2, po2graph, profPO2);
 	ui.profRuler->setChecked(s.value("rulergraph").toBool());
-	ui.profSAC->setChecked(s.value("show_sac").toBool());
+	TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC);
 }
 
+#undef TOOLBOX_PREF_BUTTON
+
 void MainWindow::writeSettings()
 {
 	QSettings settings;
-- 
1.8.3.2



More information about the subsurface mailing list