summaryrefslogtreecommitdiffstats
path: root/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-22 15:39:40 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-24 21:26:35 -0800
commite7412b11b99a67c4beb8841f6bca763519553f9d (patch)
tree382b9639bae09bdb361f61a24471c9b364c9f22e /subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
parentdf6eff917c351221c7c48557803f16ea5872f599 (diff)
downloadsubsurface-e7412b11b99a67c4beb8841f6bca763519553f9d.tar.gz
Added a GeneralSettingsWrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp')
-rw-r--r--subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
index ef48dfa59..4684b744a 100644
--- a/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
+++ b/subsurface-core/subsurface-qt/SettingsObjectWrapper.cpp
@@ -1226,3 +1226,108 @@ void UnitsSettings::setUnitSystem(const QString& value)
emit unitSystemChanged(value);
// TODO: emit the other values here?
}
+
+GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
+ QObject(parent),
+ group(QStringLiteral("GeneralSettings"))
+{
+}
+
+QString GeneralSettingsObjectWrapper::defaultFilename() const
+{
+ return prefs.default_filename;
+}
+
+QString GeneralSettingsObjectWrapper::defaultCylinder() const
+{
+ return prefs.default_cylinder;
+}
+
+short GeneralSettingsObjectWrapper::defaultFileBehavior() const
+{
+ return prefs.default_file_behavior;
+}
+
+bool GeneralSettingsObjectWrapper::useDefaultFile() const
+{
+ return prefs.use_default_file;
+}
+
+int GeneralSettingsObjectWrapper::defaultSetPoint() const
+{
+ return prefs.defaultsetpoint;
+}
+
+int GeneralSettingsObjectWrapper::o2Consumption() const
+{
+ return prefs.o2consumption;
+}
+
+int GeneralSettingsObjectWrapper::pscrRatio() const
+{
+ return prefs.pscr_ratio;
+}
+
+void GeneralSettingsObjectWrapper::setDefaultFilename(const QString& value)
+{
+ QSettings s;
+ s.setValue("default_filename", value);
+ prefs.default_filename = copy_string(qPrintable(value));
+ emit defaultFilenameChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultCylinder(const QString& value)
+{
+ QSettings s;
+ s.setValue("default_cylinder", value);
+ prefs.default_cylinder = copy_string(qPrintable(value));
+ emit defaultCylinderChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultFileBehavior(short value)
+{
+ QSettings s;
+ s.setValue("default_file_behavior", value);
+ prefs.default_file_behavior = value.;
+ if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE) {
+ // undefined, so check if there's a filename set and
+ // use that, otherwise go with no default file
+ if (QString(prefs.default_filename).isEmpty())
+ prefs.default_file_behavior = NO_DEFAULT_FILE;
+ else
+ prefs.default_file_behavior = LOCAL_DEFAULT_FILE;
+ }
+ emit defaultFileBehaviorChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setUseDefaultFile(bool value)
+{
+ QSettings s;
+ s.setValue("use_default_file", value);
+ prefs.use_default_file = value.;
+ emit useDefaultFileChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setDefaultSetPoint(int value)
+{
+ QSettings s;
+ s.setValue("defaultsetpoint", value);
+ prefs.defaultsetpoint = value.;
+ emit defaultSetPointChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setO2Consumption(int value)
+{
+ QSettings s;
+ s.setValue("o2consumption", value);
+ prefs.o2consumption = value.;
+ emit o2ConsumptionChanged(value);
+}
+
+void GeneralSettingsObjectWrapper::setPscrRatio(int value)
+{
+ QSettings s;
+ s.setValue("pscr_ratio", value);
+ prefs.pscr_ratio = value.;
+ emit pscrRatioChanged(value);
+}