diff options
author | jan Iversen <jani@apache.org> | 2018-08-11 19:55:41 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-14 07:12:41 -0700 |
commit | 9d005888fb4578b894414323981a30d7c8f98d79 (patch) | |
tree | cf531a6e5ea9975a686a5fbf7ed807460efcac32 | |
parent | 881395318c6960acc59ed1dbb4eb3de5de473cfd (diff) | |
download | subsurface-9d005888fb4578b894414323981a30d7c8f98d79.tar.gz |
core: activate qPrefPartialPressureGas
remove PartialPressureGas from SettingsObjectWrapper and reference qPrefPartialPressureGas
update files using SettingsObjectWrapper/PartialPressureGas to use qPrefPartialPressureGas
this activated qPrefPartialPressureGas and removed the similar class from
SettingsObjectWrapper.
Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r-- | core/settings/qPref.cpp | 1 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 161 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.h | 47 | ||||
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 19 | ||||
-rw-r--r-- | desktop-widgets/preferences/preferences_graph.cpp | 10 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 6 | ||||
-rw-r--r-- | subsurface-helper.cpp | 1 | ||||
-rw-r--r-- | tests/testpreferences.cpp | 58 |
8 files changed, 85 insertions, 218 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp index 299432d96..0649cddc8 100644 --- a/core/settings/qPref.cpp +++ b/core/settings/qPref.cpp @@ -23,6 +23,7 @@ void qPref::loadSync(bool doSync) qPrefGeocoding::instance()->loadSync(doSync); qPrefLanguage::instance()->loadSync(doSync); qPrefLocationService::instance()->loadSync(doSync); + qPrefPartialPressureGas::instance()->loadSync(doSync); qPrefProxy::instance()->loadSync(doSync); qPrefTechnicalDetails::instance()->loadSync(doSync); qPrefUnits::instance()->loadSync(doSync); diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index ba03fc336..d1a8ba27e 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -8,131 +8,6 @@ #include "core/qthelper.h" #include "core/prefs-macros.h" -PartialPressureGasSettings::PartialPressureGasSettings(QObject* parent): - QObject(parent) -{ - -} - -bool PartialPressureGasSettings::showPo2() const -{ - return prefs.pp_graphs.po2; -} - -bool PartialPressureGasSettings::showPn2() const -{ - return prefs.pp_graphs.pn2; -} - -bool PartialPressureGasSettings::showPhe() const -{ - return prefs.pp_graphs.phe; -} - -double PartialPressureGasSettings::po2ThresholdMin() const -{ - return prefs.pp_graphs.po2_threshold_min; -} - -double PartialPressureGasSettings::po2ThresholdMax() const -{ - return prefs.pp_graphs.po2_threshold_max; -} - - -double PartialPressureGasSettings::pn2Threshold() const -{ - return prefs.pp_graphs.pn2_threshold; -} - -double PartialPressureGasSettings::pheThreshold() const -{ - return prefs.pp_graphs.phe_threshold; -} - -void PartialPressureGasSettings::setShowPo2(bool value) -{ - if (value == prefs.pp_graphs.po2) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("po2graph", value); - prefs.pp_graphs.po2 = value; - emit showPo2Changed(value); -} - -void PartialPressureGasSettings::setShowPn2(bool value) -{ - if (value == prefs.pp_graphs.pn2) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("pn2graph", value); - prefs.pp_graphs.pn2 = value; - emit showPn2Changed(value); -} - -void PartialPressureGasSettings::setShowPhe(bool value) -{ - if (value == prefs.pp_graphs.phe) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("phegraph", value); - prefs.pp_graphs.phe = value; - emit showPheChanged(value); -} - -void PartialPressureGasSettings::setPo2ThresholdMin(double value) -{ - if (value == prefs.pp_graphs.po2_threshold_min) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("po2thresholdmin", value); - prefs.pp_graphs.po2_threshold_min = value; - emit po2ThresholdMinChanged(value); -} - -void PartialPressureGasSettings::setPo2ThresholdMax(double value) -{ - if (value == prefs.pp_graphs.po2_threshold_max) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("po2thresholdmax", value); - prefs.pp_graphs.po2_threshold_max = value; - emit po2ThresholdMaxChanged(value); -} - -void PartialPressureGasSettings::setPn2Threshold(double value) -{ - if (value == prefs.pp_graphs.pn2_threshold) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("pn2threshold", value); - prefs.pp_graphs.pn2_threshold = value; - emit pn2ThresholdChanged(value); -} - -void PartialPressureGasSettings::setPheThreshold(double value) -{ - if (value == prefs.pp_graphs.phe_threshold) - return; - - QSettings s; - s.beginGroup(group); - s.setValue("phethreshold", value); - prefs.pp_graphs.phe_threshold = value; - emit pheThresholdChanged(value); -} GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) : QObject(parent) @@ -339,7 +214,7 @@ void GeneralSettingsObjectWrapper::setFfmpegExecutable(const QString &value) SettingsObjectWrapper::SettingsObjectWrapper(QObject* parent): QObject(parent), techDetails(new qPrefTechnicalDetails(this)), - pp_gas(new PartialPressureGasSettings(this)), + pp_gas(new qPrefPartialPressureGas(this)), facebook(new qPrefFacebook(this)), geocoding(new qPrefGeocoding(this)), proxy(new qPrefProxy(this)), @@ -364,7 +239,39 @@ void SettingsObjectWrapper::load() uiLanguage(NULL); qPrefUnits::instance()->load(); - qPrefTechnicalDetails::instance()->load(); + qPrefPartialPressureGas::instance()->load(); + + s.beginGroup("TecDetails"); + GET_BOOL("mod", mod); + GET_DOUBLE("modpO2", modpO2); + GET_BOOL("ead", ead); + GET_BOOL("redceiling", redceiling); + GET_BOOL("dcceiling", dcceiling); + GET_BOOL("calcceiling", calcceiling); + GET_BOOL("calcceiling3m", calcceiling3m); + GET_BOOL("calcndltts", calcndltts); + GET_BOOL("calcalltissues", calcalltissues); + GET_BOOL("hrgraph", hrgraph); + GET_BOOL("tankbar", tankbar); + GET_BOOL("RulerBar", rulergraph); + GET_BOOL("percentagegraph", percentagegraph); + GET_INT("gflow", gflow); + GET_INT("gfhigh", gfhigh); + GET_INT("vpmb_conservatism", vpmb_conservatism); + GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth); + GET_BOOL("show_ccr_setpoint",show_ccr_setpoint); + GET_BOOL("show_ccr_sensors",show_ccr_sensors); + GET_BOOL("show_scr_ocpo2",show_scr_ocpo2); + GET_BOOL("zoomed_plot", zoomed_plot); + set_gf(prefs.gflow, prefs.gfhigh); + set_vpmb_conservatism(prefs.vpmb_conservatism); + GET_BOOL("show_sac", show_sac); + GET_BOOL("display_unused_tanks", display_unused_tanks); + GET_BOOL("show_average_depth", show_average_depth); + GET_BOOL("show_icd", show_icd); + GET_BOOL("show_pictures_in_profile", show_pictures_in_profile); + prefs.display_deco_mode = (deco_mode) s.value("display_deco_mode").toInt(); + s.endGroup(); s.beginGroup("GeneralSettings"); GET_TXT("default_filename", default_filename); diff --git a/core/subsurface-qt/SettingsObjectWrapper.h b/core/subsurface-qt/SettingsObjectWrapper.h index a34025da8..22429f9db 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.h +++ b/core/subsurface-qt/SettingsObjectWrapper.h @@ -13,49 +13,6 @@ * and QWidget frontends. This class will be huge, since * I need tons of properties, one for each option. */ -/* Control the state of the Partial Pressure Graphs preferences */ -class PartialPressureGasSettings : public QObject { - Q_OBJECT - Q_PROPERTY(bool show_po2 READ showPo2 WRITE setShowPo2 NOTIFY showPo2Changed) - Q_PROPERTY(bool show_pn2 READ showPn2 WRITE setShowPn2 NOTIFY showPn2Changed) - Q_PROPERTY(bool show_phe READ showPhe WRITE setShowPhe NOTIFY showPheChanged) - Q_PROPERTY(double po2_threshold_min READ po2ThresholdMin WRITE setPo2ThresholdMin NOTIFY po2ThresholdMinChanged) - Q_PROPERTY(double po2_threshold_max READ po2ThresholdMax WRITE setPo2ThresholdMax NOTIFY po2ThresholdMaxChanged) - Q_PROPERTY(double pn2_threshold READ pn2Threshold WRITE setPn2Threshold NOTIFY pn2ThresholdChanged) - Q_PROPERTY(double phe_threshold READ pheThreshold WRITE setPheThreshold NOTIFY pheThresholdChanged) - -public: - PartialPressureGasSettings(QObject *parent); - bool showPo2() const; - bool showPn2() const; - bool showPhe() const; - double po2ThresholdMin() const; - double po2ThresholdMax() const; - double pn2Threshold() const; - double pheThreshold() const; - -public slots: - void setShowPo2(bool value); - void setShowPn2(bool value); - void setShowPhe(bool value); - void setPo2ThresholdMin(double value); - void setPo2ThresholdMax(double value); - void setPn2Threshold(double value); - void setPheThreshold(double value); - -signals: - void showPo2Changed(bool value); - void showPn2Changed(bool value); - void showPheChanged(bool value); - void po2ThresholdMaxChanged(double value); - void po2ThresholdMinChanged(double value); - void pn2ThresholdChanged(double value); - void pheThresholdChanged(double value); - -private: - const QString group = QStringLiteral("TecDetails"); -}; - class GeneralSettingsObjectWrapper : public QObject { Q_OBJECT Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged) @@ -117,7 +74,7 @@ class SettingsObjectWrapper : public QObject { Q_OBJECT Q_PROPERTY(qPrefTechnicalDetails* techical_details MEMBER techDetails CONSTANT) - Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT) + Q_PROPERTY(qPrefPartialPressureGas* pp_gas MEMBER pp_gas CONSTANT) Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT) Q_PROPERTY(qPrefGeocoding* geocoding MEMBER geocoding CONSTANT) Q_PROPERTY(qPrefProxy* proxy MEMBER proxy CONSTANT) @@ -136,7 +93,7 @@ public: static SettingsObjectWrapper *instance(); qPrefTechnicalDetails *techDetails; - PartialPressureGasSettings *pp_gas; + qPrefPartialPressureGas *pp_gas; qPrefFacebook *facebook; qPrefGeocoding *geocoding; qPrefProxy *proxy; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index cc3bc7c54..e91e315f6 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -303,9 +303,10 @@ MainWindow::MainWindow() : QMainWindow(), connect(ui.profTissues, &QAction::triggered, this, &MainWindow::unsetProfHR); connect(ui.profHR, &QAction::triggered, this, &MainWindow::unsetProfTissues); - connect(ui.profPhe, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPhe); - connect(ui.profPn2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPn2); - connect(ui.profPO2, &QAction::triggered, sWrapper->pp_gas, &PartialPressureGasSettings::setShowPo2); + auto pp_gas = qPrefPartialPressureGas::instance(); + connect(ui.profPhe, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_phe); + connect(ui.profPn2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_pn2); + connect(ui.profPO2, &QAction::triggered, pp_gas, &qPrefPartialPressureGas::set_po2); connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcalltissues_changed , graphics(), &ProfileWidget2::actionRequestedReplot); connect(sWrapper->techDetails, &qPrefTechnicalDetails::calcceiling_changed , graphics(), &ProfileWidget2::actionRequestedReplot); @@ -322,9 +323,9 @@ MainWindow::MainWindow() : QMainWindow(), connect(sWrapper->techDetails, &qPrefTechnicalDetails::tankbar_changed , graphics(), &ProfileWidget2::actionRequestedReplot); connect(sWrapper->techDetails, &qPrefTechnicalDetails::percentagegraph_changed , graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPheChanged, graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPn2Changed, graphics(), &ProfileWidget2::actionRequestedReplot); - connect(sWrapper->pp_gas, &PartialPressureGasSettings::showPo2Changed, graphics(), &ProfileWidget2::actionRequestedReplot); + connect(sWrapper->pp_gas, &qPrefPartialPressureGas::phe_changed, graphics(), &ProfileWidget2::actionRequestedReplot); + connect(sWrapper->pp_gas, &qPrefPartialPressureGas::pn2_changed, graphics(), &ProfileWidget2::actionRequestedReplot); + connect(sWrapper->pp_gas, &qPrefPartialPressureGas::po2_changed, graphics(), &ProfileWidget2::actionRequestedReplot); // now let's set up some connections connect(graphics(), &ProfileWidget2::enableToolbar ,this, &MainWindow::setEnabledToolbar); @@ -343,9 +344,9 @@ MainWindow::MainWindow() : QMainWindow(), ui.profIncrement3m->setChecked(sWrapper->techDetails->calcceiling3m()); ui.profMod->setChecked(sWrapper->techDetails->mod()); ui.profNdl_tts->setChecked(sWrapper->techDetails->calcndltts()); - ui.profPhe->setChecked(sWrapper->pp_gas->showPhe()); - ui.profPn2->setChecked(sWrapper->pp_gas->showPn2()); - ui.profPO2->setChecked(sWrapper->pp_gas->showPo2()); + ui.profPhe->setChecked(pp_gas->phe()); + ui.profPn2->setChecked(pp_gas->pn2()); + ui.profPO2->setChecked(pp_gas->po2()); ui.profHR->setChecked(sWrapper->techDetails->hrgraph()); ui.profRuler->setChecked(sWrapper->techDetails->rulergraph()); ui.profSAC->setChecked(sWrapper->techDetails->show_sac()); diff --git a/desktop-widgets/preferences/preferences_graph.cpp b/desktop-widgets/preferences/preferences_graph.cpp index 6ddd7250a..a25f818c7 100644 --- a/desktop-widgets/preferences/preferences_graph.cpp +++ b/desktop-widgets/preferences/preferences_graph.cpp @@ -58,11 +58,11 @@ void PreferencesGraph::syncSettings() general->setPscrRatio(lrint(1000.0 / ui->pscrfactor->value())); general->setAutoRecalculateThumbnails(ui->auto_recalculate_thumbnails->isChecked()); - auto pp_gas = SettingsObjectWrapper::instance()->pp_gas; - pp_gas->setPheThreshold(ui->pheThreshold->value()); - pp_gas->setPo2ThresholdMax(ui->po2ThresholdMax->value()); - pp_gas->setPo2ThresholdMin(ui->po2ThresholdMin->value()); - pp_gas->setPn2Threshold(ui->pn2Threshold->value()); + auto pp_gas = qPrefPartialPressureGas::instance(); + pp_gas->set_phe_threshold(ui->pheThreshold->value()); + pp_gas->set_po2_threshold_max(ui->po2ThresholdMax->value()); + pp_gas->set_po2_threshold_min(ui->po2ThresholdMin->value()); + pp_gas->set_pn2_threshold(ui->pn2Threshold->value()); auto tech = qPrefTechnicalDetails::instance(); tech->set_modpO2(ui->maxpo2->value()); diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 7c70b15f9..5eb40b69e 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -341,9 +341,9 @@ void ProfileWidget2::setupItemOnScene() #ifndef SUBSURFACE_MOBILE // Visibility Connections - connect(SettingsObjectWrapper::instance()->pp_gas, &PartialPressureGasSettings::showPheChanged, pheGasItem, &PartialPressureGasItem::setVisible); - connect(SettingsObjectWrapper::instance()->pp_gas, &PartialPressureGasSettings::showPo2Changed, po2GasItem, &PartialPressureGasItem::setVisible); - connect(SettingsObjectWrapper::instance()->pp_gas, &PartialPressureGasSettings::showPn2Changed, pn2GasItem, &PartialPressureGasItem::setVisible); + connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::phe_changed, pheGasItem, &PartialPressureGasItem::setVisible); + connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::po2_changed, po2GasItem, &PartialPressureGasItem::setVisible); + connect(qPrefPartialPressureGas::instance(), &qPrefPartialPressureGas::pn2_changed, pn2GasItem, &PartialPressureGasItem::setVisible); //WARNING: The old code was broken, I'm not sure what should trigger the visibility of those graphs, since the old code didn't triggered them // because it was using a wrong settings. diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index faf0d2502..ea7a6f0c4 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -165,6 +165,7 @@ void register_qml_types() REGISTER_TYPE(qPrefGeocoding, "SsrfGeocodingPrefs"); REGISTER_TYPE(qPrefLanguage, "SsrfLanguagePrefs"); REGISTER_TYPE(qPrefLocationService, "SsrfLocationServicePrefs"); + REGISTER_TYPE(qPrefPartialPressureGas, "SsrfPartialPressureGasPrefs"); REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs"); REGISTER_TYPE(qPrefTechnicalDetails, "SsrfTechnicalDetailsPrefs"); REGISTER_TYPE(qPrefUnits, "SsrfUnitPrefs"); diff --git a/tests/testpreferences.cpp b/tests/testpreferences.cpp index d5ea72095..7171a6202 100644 --- a/tests/testpreferences.cpp +++ b/tests/testpreferences.cpp @@ -24,38 +24,38 @@ void TestPreferences::testPreferences() auto pref = SettingsObjectWrapper::instance(); pref->load(); - auto pp = pref->pp_gas; - pp->setShowPn2(false); - pp->setShowPhe(false); - pp->setShowPo2(false); - pp->setPo2ThresholdMin(1.0); - pp->setPo2ThresholdMax(2.0); - pp->setPn2Threshold(3.0); - pp->setPheThreshold(4.0); + auto pp = qPrefPartialPressureGas::instance(); + pp->set_pn2(false); + pp->set_phe(false); + pp->set_po2(false); + pp->set_po2_threshold_min(1.0); + pp->set_po2_threshold_max(2.0); + pp->set_pn2_threshold(3.0); + pp->set_phe_threshold(4.0); - TEST(pp->showPn2(), false); - TEST(pp->showPhe(), false); - TEST(pp->showPo2(), false); - TEST(pp->pn2Threshold(), 3.0); - TEST(pp->pheThreshold(), 4.0); - TEST(pp->po2ThresholdMin(), 1.0); - TEST(pp->po2ThresholdMax(), 2.0); + TEST(pp->pn2(), false); + TEST(pp->phe(), false); + TEST(pp->po2(), false); + TEST(pp->pn2_threshold(), 3.0); + TEST(pp->phe_threshold(), 4.0); + TEST(pp->po2_threshold_min(), 1.0); + TEST(pp->po2_threshold_max(), 2.0); - pp->setShowPn2(true); - pp->setShowPhe(true); - pp->setShowPo2(true); - pp->setPo2ThresholdMin(4.0); - pp->setPo2ThresholdMax(5.0); - pp->setPn2Threshold(6.0); - pp->setPheThreshold(7.0); + pp->set_pn2(true); + pp->set_phe(true); + pp->set_po2(true); + pp->set_po2_threshold_min(4.0); + pp->set_po2_threshold_max(5.0); + pp->set_pn2_threshold(6.0); + pp->set_phe_threshold(7.0); - TEST(pp->showPn2(), true); - TEST(pp->showPhe(), true); - TEST(pp->showPo2(), true); - TEST(pp->pn2Threshold(), 6.0); - TEST(pp->pheThreshold(), 7.0); - TEST(pp->po2ThresholdMin(), 4.0); - TEST(pp->po2ThresholdMax(), 5.0); + TEST(pp->pn2(), true); + TEST(pp->phe(), true); + TEST(pp->po2(), true); + TEST(pp->pn2_threshold(), 6.0); + TEST(pp->phe_threshold(), 7.0); + TEST(pp->po2_threshold_min(), 4.0); + TEST(pp->po2_threshold_max(), 5.0); auto general = pref->general_settings; general->setDefaultFilename("filename"); |