mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
da6e8a4cd5
commit
5f4a040dd2
4 changed files with 46 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue