summaryrefslogtreecommitdiffstats
path: root/core/settings
diff options
context:
space:
mode:
Diffstat (limited to 'core/settings')
-rw-r--r--core/settings/qPref.cpp3
-rw-r--r--core/settings/qPrefGeneral.cpp40
-rw-r--r--core/settings/qPrefGeneral.h21
-rw-r--r--core/settings/qPrefLog.cpp59
-rw-r--r--core/settings/qPrefLog.h57
-rw-r--r--core/settings/qPrefTechnicalDetails.cpp3
-rw-r--r--core/settings/qPrefTechnicalDetails.h5
7 files changed, 119 insertions, 69 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp
index 6b18d1915..4138b0c82 100644
--- a/core/settings/qPref.cpp
+++ b/core/settings/qPref.cpp
@@ -16,6 +16,7 @@
#include "qPrefUpdateManager.h"
#include "qPrefEquipment.h"
#include "qPrefMedia.h"
+#include "qPrefLog.h"
#include <QtQml>
#include <QQmlContext>
@@ -42,6 +43,7 @@ void qPref::loadSync(bool doSync)
qPrefUpdateManager::loadSync(doSync);
qPrefEquipment::loadSync(doSync);
qPrefMedia::loadSync(doSync);
+ qPrefLog::loadSync(doSync);
}
Q_DECLARE_METATYPE(deco_mode);
@@ -68,6 +70,7 @@ void qPref::registerQML(QQmlEngine *engine)
ct->setContextProperty("PrefEquipment", qPrefUpdateManager::instance());
ct->setContextProperty("PrefMedia", qPrefUpdateManager::instance());
ct->setContextProperty("PrefClearDc", qPrefUpdateManager::instance());
+ ct->setContextProperty("PrefLog", qPrefUpdateManager::instance());
}
// Register special types
diff --git a/core/settings/qPrefGeneral.cpp b/core/settings/qPrefGeneral.cpp
index e3d3e6e0a..25ed835f0 100644
--- a/core/settings/qPrefGeneral.cpp
+++ b/core/settings/qPrefGeneral.cpp
@@ -20,15 +20,11 @@ qPrefGeneral *qPrefGeneral::instance()
void qPrefGeneral::loadSync(bool doSync)
{
- disk_default_filename(doSync);
- disk_default_file_behavior(doSync);
disk_defaultsetpoint(doSync);
disk_o2consumption(doSync);
disk_pscr_ratio(doSync);
- disk_use_default_file(doSync);
disk_filterFullTextNotes(doSync);
disk_filterCaseSensitive(doSync);
- disk_extraEnvironmentalDefault(doSync);
if (!doSync) {
load_diveshareExport_uid();
@@ -36,48 +32,12 @@ void qPrefGeneral::loadSync(bool doSync)
}
}
-HANDLE_PREFERENCE_TXT(General, "default_filename", default_filename);
-
-
-void qPrefGeneral::set_default_file_behavior(enum def_file_behavior value)
-{
- if (value != prefs.default_file_behavior ||
- prefs.default_file_behavior != UNDEFINED_DEFAULT_FILE) {
-
- if (value == UNDEFINED_DEFAULT_FILE) {
- // undefined, so check if there's a filename set and
- // use that, otherwise go with no default file
- prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
- } else {
- prefs.default_file_behavior = value;
- }
- disk_default_file_behavior(true);
- emit instance()->default_file_behaviorChanged(value);
- }
-}
-void qPrefGeneral::disk_default_file_behavior(bool doSync)
-{
- if (doSync) {
- qPrefPrivate::propSetValue(keyFromGroupAndName(group, "default_file_behavior"), prefs.default_file_behavior, default_prefs.default_file_behavior);
- } else {
- prefs.default_file_behavior = (enum def_file_behavior)qPrefPrivate::propValue(keyFromGroupAndName(group, "default_file_behavior"), default_prefs.default_file_behavior).toInt();
- 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
- prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
- }
-}
-
HANDLE_PREFERENCE_INT(General, "defaultsetpoint", defaultsetpoint);
HANDLE_PREFERENCE_INT(General, "o2consumption", o2consumption);
HANDLE_PREFERENCE_INT(General, "pscr_ratio", pscr_ratio);
-HANDLE_PREFERENCE_BOOL(General, "extraEnvironmentalDefault", extraEnvironmentalDefault);
-
-HANDLE_PREFERENCE_BOOL(General, "use_default_file", use_default_file);
-
HANDLE_PROP_QSTRING(General, "diveshareExport/uid", diveshareExport_uid);
HANDLE_PROP_BOOL(General, "diveshareExport/private", diveshareExport_private);
diff --git a/core/settings/qPrefGeneral.h b/core/settings/qPrefGeneral.h
index bb91d6501..236dc5b21 100644
--- a/core/settings/qPrefGeneral.h
+++ b/core/settings/qPrefGeneral.h
@@ -7,18 +7,13 @@
class qPrefGeneral : public QObject {
Q_OBJECT
- Q_PROPERTY(QString default_filename READ default_filename WRITE set_default_filename NOTIFY default_filenameChanged)
- Q_PROPERTY(enum def_file_behavior default_file_behavior READ default_file_behavior WRITE set_default_file_behavior NOTIFY default_file_behaviorChanged)
Q_PROPERTY(int defaultsetpoint READ defaultsetpoint WRITE set_defaultsetpoint NOTIFY defaultsetpointChanged)
Q_PROPERTY(int o2consumption READ o2consumption WRITE set_o2consumption NOTIFY o2consumptionChanged)
Q_PROPERTY(int pscr_ratio READ pscr_ratio WRITE set_pscr_ratio NOTIFY pscr_ratioChanged)
- Q_PROPERTY(bool use_default_file READ use_default_file WRITE set_use_default_file NOTIFY use_default_fileChanged)
Q_PROPERTY(QString diveshareExport_uid READ diveshareExport_uid WRITE set_diveshareExport_uid NOTIFY diveshareExport_uidChanged)
Q_PROPERTY(bool diveshareExport_private READ diveshareExport_private WRITE set_diveshareExport_private NOTIFY diveshareExport_privateChanged)
Q_PROPERTY(bool filterFullTextNotes READ filterFullTextNotes WRITE set_filterFullTextNotes NOTIFY filterFullTextNotesChanged)
Q_PROPERTY(bool filterCaseSensitive READ filterCaseSensitive WRITE set_filterCaseSensitive NOTIFY filterCaseSensitiveChanged)
- Q_PROPERTY(bool extraEnvironmentalDefault READ extraEnvironmentalDefault WRITE set_extraEnvironmentalDefault NOTIFY extraEnvironmentalDefaultChanged);
-
public:
static qPrefGeneral *instance();
@@ -29,57 +24,41 @@ public:
static void sync() { return loadSync(true); }
public:
- static QString default_filename() { return prefs.default_filename; }
- static enum def_file_behavior default_file_behavior() { return prefs.default_file_behavior; }
static int defaultsetpoint() { return prefs.defaultsetpoint; }
static int o2consumption() { return prefs.o2consumption; }
static int pscr_ratio() { return prefs.pscr_ratio; }
- static bool use_default_file() { return prefs.use_default_file; }
static QString diveshareExport_uid() { return st_diveshareExport_uid; }
static bool diveshareExport_private() { return st_diveshareExport_private; }
static bool filterFullTextNotes() { return prefs.filterFullTextNotes; }
static bool filterCaseSensitive() { return prefs.filterCaseSensitive; }
- static bool extraEnvironmentalDefault() { return prefs.extraEnvironmentalDefault; }
public slots:
- static void set_default_filename(const QString& value);
- static void set_default_file_behavior(enum def_file_behavior value);
static void set_defaultsetpoint(int value);
static void set_o2consumption(int value);
static void set_pscr_ratio(int value);
- static void set_use_default_file(bool value);
static void set_diveshareExport_uid(const QString& value);
static void set_diveshareExport_private(bool value);
static void set_filterFullTextNotes(bool value);
static void set_filterCaseSensitive(bool value);
- static void set_extraEnvironmentalDefault(bool value);
signals:
- void default_filenameChanged(const QString& value);
- void default_file_behaviorChanged(enum def_file_behavior value);
void defaultsetpointChanged(int value);
void o2consumptionChanged(int value);
void pscr_ratioChanged(int value);
- void use_default_fileChanged(bool value);
void diveshareExport_uidChanged(const QString& value);
void diveshareExport_privateChanged(bool value);
void filterFullTextNotesChanged(bool value);
void salinityEditDefaultChanged(bool value);
void filterCaseSensitiveChanged(bool value);
- void extraEnvironmentalDefaultChanged(bool value);
private:
qPrefGeneral() {}
- static void disk_default_filename(bool doSync);
- static void disk_default_file_behavior(bool doSync);
static void disk_defaultsetpoint(bool doSync);
static void disk_o2consumption(bool doSync);
static void disk_pscr_ratio(bool doSync);
- static void disk_use_default_file(bool doSync);
static void disk_filterFullTextNotes(bool doSync);
static void disk_filterCaseSensitive(bool doSync);
- static void disk_extraEnvironmentalDefault(bool doSync);
// class variables are load only
static void load_diveshareExport_uid();
diff --git a/core/settings/qPrefLog.cpp b/core/settings/qPrefLog.cpp
new file mode 100644
index 000000000..2ce9ae550
--- /dev/null
+++ b/core/settings/qPrefLog.cpp
@@ -0,0 +1,59 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "qPrefLog.h"
+#include "qPrefPrivate.h"
+
+static const QString group = QStringLiteral("LogSettings");
+
+qPrefLog *qPrefLog::instance()
+{
+ static qPrefLog *self = new qPrefLog;
+ return self;
+}
+
+void qPrefLog::loadSync(bool doSync)
+{
+ disk_default_filename(doSync);
+ disk_default_file_behavior(doSync);
+ disk_use_default_file(doSync);
+ disk_extraEnvironmentalDefault(doSync);
+ disk_show_average_depth(doSync);
+}
+
+HANDLE_PREFERENCE_TXT(Log, "default_filename", default_filename);
+
+void qPrefLog::set_default_file_behavior(enum def_file_behavior value)
+{
+ if (value != prefs.default_file_behavior ||
+ prefs.default_file_behavior != UNDEFINED_DEFAULT_FILE) {
+
+ if (value == UNDEFINED_DEFAULT_FILE) {
+ // undefined, so check if there's a filename set and
+ // use that, otherwise go with no default file
+ prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
+ } else {
+ prefs.default_file_behavior = value;
+ }
+ disk_default_file_behavior(true);
+ emit instance()->default_file_behaviorChanged(value);
+ }
+}
+void qPrefLog::disk_default_file_behavior(bool doSync)
+{
+ if (doSync) {
+ qPrefPrivate::propSetValue(keyFromGroupAndName(group, "default_file_behavior"), prefs.default_file_behavior, default_prefs.default_file_behavior);
+ } else {
+ prefs.default_file_behavior = (enum def_file_behavior)qPrefPrivate::propValue(keyFromGroupAndName(group, "default_file_behavior"), default_prefs.default_file_behavior).toInt();
+ 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
+ prefs.default_file_behavior = QString(prefs.default_filename).isEmpty() ? NO_DEFAULT_FILE : LOCAL_DEFAULT_FILE;
+ }
+}
+
+
+HANDLE_PREFERENCE_BOOL(Log, "extraEnvironmentalDefault", extraEnvironmentalDefault);
+
+HANDLE_PREFERENCE_BOOL(Log, "use_default_file", use_default_file);
+
+HANDLE_PREFERENCE_BOOL(Log, "show_average_depth", show_average_depth);
+
diff --git a/core/settings/qPrefLog.h b/core/settings/qPrefLog.h
new file mode 100644
index 000000000..ee40bc9e7
--- /dev/null
+++ b/core/settings/qPrefLog.h
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef QPREFLOG_H
+#define QPREFLOG_H
+#include "core/pref.h"
+
+#include <QObject>
+
+class qPrefLog : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString default_filename READ default_filename WRITE set_default_filename NOTIFY default_filenameChanged)
+ Q_PROPERTY(enum def_file_behavior default_file_behavior READ default_file_behavior WRITE set_default_file_behavior NOTIFY default_file_behaviorChanged)
+ Q_PROPERTY(bool use_default_file READ use_default_file WRITE set_use_default_file NOTIFY use_default_fileChanged)
+ Q_PROPERTY(bool extraEnvironmentalDefault READ extraEnvironmentalDefault WRITE set_extraEnvironmentalDefault NOTIFY extraEnvironmentalDefaultChanged);
+ Q_PROPERTY(bool show_average_depth READ show_average_depth WRITE set_show_average_depth NOTIFY show_average_depthChanged)
+
+
+public:
+ static qPrefLog *instance();
+
+ // Load/Sync local settings (disk) and struct preference
+ static void loadSync(bool doSync);
+ static void load() { return loadSync(false); }
+ static void sync() { return loadSync(true); }
+
+public:
+ static QString default_filename() { return prefs.default_filename; }
+ static enum def_file_behavior default_file_behavior() { return prefs.default_file_behavior; }
+ static bool use_default_file() { return prefs.use_default_file; }
+ static bool extraEnvironmentalDefault() { return prefs.extraEnvironmentalDefault; }
+ static bool show_average_depth() { return prefs.show_average_depth; }
+
+public slots:
+ static void set_default_filename(const QString& value);
+ static void set_default_file_behavior(enum def_file_behavior value);
+ static void set_use_default_file(bool value);
+ static void set_extraEnvironmentalDefault(bool value);
+ static void set_show_average_depth(bool value);
+
+signals:
+ void default_filenameChanged(const QString& value);
+ void default_file_behaviorChanged(enum def_file_behavior value);
+ void use_default_fileChanged(bool value);
+ void extraEnvironmentalDefaultChanged(bool value);
+ void show_average_depthChanged(bool value);
+
+private:
+ qPrefLog() {}
+
+ static void disk_default_filename(bool doSync);
+ static void disk_default_file_behavior(bool doSync);
+ static void disk_use_default_file(bool doSync);
+ static void disk_extraEnvironmentalDefault(bool doSync);
+ static void disk_show_average_depth(bool doSync);
+
+};
+
+#endif
diff --git a/core/settings/qPrefTechnicalDetails.cpp b/core/settings/qPrefTechnicalDetails.cpp
index 1d0e30c0c..2db4898ae 100644
--- a/core/settings/qPrefTechnicalDetails.cpp
+++ b/core/settings/qPrefTechnicalDetails.cpp
@@ -30,7 +30,6 @@ void qPrefTechnicalDetails::loadSync(bool doSync)
disk_percentagegraph(doSync);
disk_redceiling(doSync);
disk_rulergraph(doSync);
- disk_show_average_depth(doSync);
disk_show_ccr_sensors(doSync);
disk_show_ccr_setpoint(doSync);
disk_show_icd(doSync);
@@ -112,8 +111,6 @@ HANDLE_PREFERENCE_BOOL(TechnicalDetails, "redceiling", redceiling);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "RulerBar", rulergraph);
-HANDLE_PREFERENCE_BOOL(TechnicalDetails, "show_average_depth", show_average_depth);
-
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "show_ccr_sensors", show_ccr_sensors);
HANDLE_PREFERENCE_BOOL(TechnicalDetails, "show_ccr_setpoint", show_ccr_setpoint);
diff --git a/core/settings/qPrefTechnicalDetails.h b/core/settings/qPrefTechnicalDetails.h
index dfd477320..5b62aa7ea 100644
--- a/core/settings/qPrefTechnicalDetails.h
+++ b/core/settings/qPrefTechnicalDetails.h
@@ -25,7 +25,6 @@ class qPrefTechnicalDetails : public QObject {
Q_PROPERTY(bool percentagegraph READ percentagegraph WRITE set_percentagegraph NOTIFY percentagegraphChanged)
Q_PROPERTY(bool redceiling READ redceiling WRITE set_redceiling NOTIFY redceilingChanged)
Q_PROPERTY(bool rulergraph READ rulergraph WRITE set_rulergraph NOTIFY rulergraphChanged)
- Q_PROPERTY(bool show_average_depth READ show_average_depth WRITE set_show_average_depth NOTIFY show_average_depthChanged)
Q_PROPERTY(bool show_ccr_sensors READ show_ccr_sensors WRITE set_show_ccr_sensors NOTIFY show_ccr_sensorsChanged)
Q_PROPERTY(bool show_ccr_setpoint READ show_ccr_setpoint WRITE set_show_ccr_setpoint NOTIFY show_ccr_setpointChanged)
Q_PROPERTY(bool show_icd READ show_icd WRITE set_show_icd NOTIFY show_icdChanged)
@@ -62,7 +61,6 @@ public:
static bool percentagegraph() { return prefs.percentagegraph; }
static bool redceiling() { return prefs.redceiling; }
static bool rulergraph() { return prefs.rulergraph; }
- static bool show_average_depth() { return prefs.show_average_depth; }
static bool show_ccr_sensors() { return prefs.show_ccr_sensors; }
static bool show_ccr_setpoint() { return prefs.show_ccr_setpoint; }
static bool show_icd() { return prefs.show_icd; }
@@ -91,7 +89,6 @@ public slots:
static void set_percentagegraph(bool value);
static void set_redceiling(bool value);
static void set_rulergraph(bool value);
- static void set_show_average_depth(bool value);
static void set_show_ccr_sensors(bool value);
static void set_show_ccr_setpoint(bool value);
static void set_show_icd(bool value);
@@ -120,7 +117,6 @@ signals:
void percentagegraphChanged(bool value);
void redceilingChanged(bool value);
void rulergraphChanged(bool value);
- void show_average_depthChanged(bool value);
void show_ccr_sensorsChanged(bool value);
void show_ccr_setpointChanged(bool value);
void show_icdChanged(bool value);
@@ -151,7 +147,6 @@ private:
static void disk_percentagegraph(bool doSync);
static void disk_redceiling(bool doSync);
static void disk_rulergraph(bool doSync);
- static void disk_show_average_depth(bool doSync);
static void disk_show_ccr_sensors(bool doSync);
static void disk_show_ccr_setpoint(bool doSync);
static void disk_show_icd(bool doSync);