diff options
author | jan Iversen <jani@apache.org> | 2018-08-20 12:50:21 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-25 11:49:47 -0700 |
commit | 5f4a040dd217c07a341bd03fe80fe19747d1541e (patch) | |
tree | 6c8d480dabf65ff15a721c3dccfc152b946b1cd8 | |
parent | da6e8a4cd5d80a4288129bf44b1efad69de1704f (diff) | |
download | subsurface-5f4a040dd217c07a341bd03fe80fe19747d1541e.tar.gz |
core/tests: add class var to qPrefGeneral
Add static class variables to qPrefGeneral
(and remove QSettings from desktop-widgets)
Signed-off-by: Jan Iversen <jani@apache.org>
-rw-r--r-- | core/settings/qPrefGeneral.cpp | 14 | ||||
-rw-r--r-- | core/settings/qPrefGeneral.h | 16 | ||||
-rw-r--r-- | tests/testqPrefGeneral.cpp | 8 | ||||
-rw-r--r-- | tests/tst_qPrefGeneral.qml | 8 |
4 files changed, 46 insertions, 0 deletions
diff --git a/core/settings/qPrefGeneral.cpp b/core/settings/qPrefGeneral.cpp index b092232f5..8dfe67668 100644 --- a/core/settings/qPrefGeneral.cpp +++ b/core/settings/qPrefGeneral.cpp @@ -5,6 +5,12 @@ static const QString group = QStringLiteral("GeneralSettings"); +QString qPrefGeneral::st_diveshareExport_uid; +static const QString st_diveshareExport_uid_default = ""; + +bool qPrefGeneral::st_diveshareExport_private; +static const bool st_diveshareExport_private_default = false; + qPrefGeneral::qPrefGeneral(QObject *parent) : QObject(parent) { } @@ -29,6 +35,10 @@ void qPrefGeneral::loadSync(bool doSync) disk_o2consumption(doSync); disk_pscr_ratio(doSync); disk_use_default_file(doSync); + if (!doSync) { + load_diveshareExport_uid(); + load_diveshareExport_private(); + } } HANDLE_PREFERENCE_BOOL(General, "/auto_recalculate_thumbnails", auto_recalculate_thumbnails); @@ -80,3 +90,7 @@ HANDLE_PREFERENCE_INT(General, "/o2consumption", o2consumption); HANDLE_PREFERENCE_INT(General, "/pscr_ratio", pscr_ratio); 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 983e4eca0..4d35c3817 100644 --- a/core/settings/qPrefGeneral.h +++ b/core/settings/qPrefGeneral.h @@ -18,6 +18,8 @@ class qPrefGeneral : public QObject { Q_PROPERTY(int o2consumption READ o2consumption WRITE set_o2consumption NOTIFY o2consumption_changed); Q_PROPERTY(int pscr_ratio READ pscr_ratio WRITE set_pscr_ratio NOTIFY pscr_ratio_changed); Q_PROPERTY(bool use_default_file READ use_default_file WRITE set_use_default_file NOTIFY use_default_file_changed); + Q_PROPERTY(QString diveshareExport_uid READ diveshareExport_uid WRITE set_diveshareExport_uid NOTIFY diveshareExport_uid_changed); + Q_PROPERTY(bool diveshareExport_private READ diveshareExport_private WRITE set_diveshareExport_private NOTIFY diveshareExport_private_changed); public: qPrefGeneral(QObject *parent = NULL); @@ -40,6 +42,8 @@ public: 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; } public slots: static void set_auto_recalculate_thumbnails(bool value); @@ -53,6 +57,8 @@ public slots: 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); signals: void auto_recalculate_thumbnails_changed(bool value); @@ -66,6 +72,8 @@ signals: void o2consumption_changed(int value); void pscr_ratio_changed(int value); void use_default_file_changed(bool value); + void diveshareExport_uid_changed(const QString& value); + void diveshareExport_private_changed(bool value); private: static void disk_auto_recalculate_thumbnails(bool doSync); @@ -79,6 +87,14 @@ private: static void disk_o2consumption(bool doSync); static void disk_pscr_ratio(bool doSync); static void disk_use_default_file(bool doSync); + + // class variables are load only + static void load_diveshareExport_uid(); + static void load_diveshareExport_private(); + + // class variables + static QString st_diveshareExport_uid; + static bool st_diveshareExport_private; }; #endif diff --git a/tests/testqPrefGeneral.cpp b/tests/testqPrefGeneral.cpp index 2e6ec76c0..c26616e90 100644 --- a/tests/testqPrefGeneral.cpp +++ b/tests/testqPrefGeneral.cpp @@ -62,6 +62,8 @@ void TestQPrefGeneral::test_set_struct() tst->set_o2consumption(27); tst->set_pscr_ratio(28); tst->set_use_default_file(false); + tst->set_diveshareExport_uid("uid1"); + tst->set_diveshareExport_private(false); QCOMPARE(prefs.auto_recalculate_thumbnails, false); QCOMPARE(QString(prefs.default_cylinder), QString("new base21")); @@ -74,6 +76,8 @@ void TestQPrefGeneral::test_set_struct() QCOMPARE(prefs.o2consumption, 27); QCOMPARE(prefs.pscr_ratio, 28); QCOMPARE(prefs.use_default_file, false); + QCOMPARE(tst->diveshareExport_uid(), QString("uid1")); + QCOMPARE(tst->diveshareExport_private(), false); } void TestQPrefGeneral::test_set_load_struct() @@ -93,6 +97,8 @@ void TestQPrefGeneral::test_set_load_struct() tst->set_o2consumption(37); tst->set_pscr_ratio(38); tst->set_use_default_file(true); + tst->set_diveshareExport_uid("uid2"); + tst->set_diveshareExport_private(true); prefs.auto_recalculate_thumbnails = false; prefs.default_cylinder = copy_qstring("error"); @@ -118,6 +124,8 @@ void TestQPrefGeneral::test_set_load_struct() QCOMPARE(prefs.o2consumption, 37); QCOMPARE(prefs.pscr_ratio, 38); QCOMPARE(prefs.use_default_file, true); + QCOMPARE(tst->diveshareExport_uid(), QString("uid2")); + QCOMPARE(tst->diveshareExport_private(), true); } void TestQPrefGeneral::test_struct_disk() diff --git a/tests/tst_qPrefGeneral.qml b/tests/tst_qPrefGeneral.qml index eb66383af..5c1669056 100644 --- a/tests/tst_qPrefGeneral.qml +++ b/tests/tst_qPrefGeneral.qml @@ -58,5 +58,13 @@ TestCase { var x11 = tst.use_default_file tst.use_default_file = true compare(tst.use_default_file, true) + + var x12 = tst.diveshareExport_uid + tst.diveshareExport_uid = "myUid" + compare(tst.diveshareExport_uid, "myUid") + + var x13 = tst.diveshareExport_private + tst.diveshareExport_private = true + compare(tst.diveshareExport_private, true) } } |