diff options
author | jan Iversen <jani@apache.org> | 2018-08-20 11:51:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-25 11:49:47 -0700 |
commit | ebc0e6d3f3edb90851295399dd22e081fe00a0c8 (patch) | |
tree | 5d08f827e6ed92eb26a778b540e132dbfad5742a /core/settings | |
parent | 82b626b3fdd82bbe251d56a9972941ed207825a3 (diff) | |
download | subsurface-ebc0e6d3f3edb90851295399dd22e081fe00a0c8.tar.gz |
core/tests: merge Animations and add vars. to qPrefDisplay
Add class variable tooltip_position to qPrefDisplay
Add class variable lastDir to qPrefDisplay
qPrefDisplay is updated to use new qPrefPrivate functions
Adjust test cases incl. qml tests
qPrefAnimations only has 1 variable, that really is a display variable
Merge the variable into qPrefDisplay, to simplify setup (and avoid loading
extra page in qml).
correct theme to save in correct place, and make it a static
class variable
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'core/settings')
-rw-r--r-- | core/settings/qPref.cpp | 1 | ||||
-rw-r--r-- | core/settings/qPref.h | 1 | ||||
-rw-r--r-- | core/settings/qPrefAnimations.cpp | 21 | ||||
-rw-r--r-- | core/settings/qPrefAnimations.h | 35 | ||||
-rw-r--r-- | core/settings/qPrefDisplay.cpp | 68 | ||||
-rw-r--r-- | core/settings/qPrefDisplay.h | 75 |
6 files changed, 137 insertions, 64 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp index e5f662470..90aedd925 100644 --- a/core/settings/qPref.cpp +++ b/core/settings/qPref.cpp @@ -16,7 +16,6 @@ void qPref::loadSync(bool doSync) if (!doSync) uiLanguage(NULL); - qPrefAnimations::instance()->loadSync(doSync); qPrefCloudStorage::instance()->loadSync(doSync); qPrefDisplay::instance()->loadSync(doSync); qPrefDiveComputer::instance()->loadSync(doSync); diff --git a/core/settings/qPref.h b/core/settings/qPref.h index 36fd9d09a..036b3c6b2 100644 --- a/core/settings/qPref.h +++ b/core/settings/qPref.h @@ -6,7 +6,6 @@ #include <QObject> -#include "qPrefAnimations.h" #include "qPrefCloudStorage.h" #include "qPrefDisplay.h" #include "qPrefDiveComputer.h" diff --git a/core/settings/qPrefAnimations.cpp b/core/settings/qPrefAnimations.cpp deleted file mode 100644 index ca1980210..000000000 --- a/core/settings/qPrefAnimations.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "qPrefAnimations.h" -#include "qPrefPrivate.h" - -static const QString group = QStringLiteral("Animations"); - -qPrefAnimations::qPrefAnimations(QObject *parent) : QObject(parent) -{ -} -qPrefAnimations *qPrefAnimations::instance() -{ - static qPrefAnimations *self = new qPrefAnimations; - return self; -} - -void qPrefAnimations::loadSync(bool doSync) -{ - disk_animation_speed(doSync); -} - -HANDLE_PREFERENCE_INT(Animations, "/animation_speed", animation_speed); diff --git a/core/settings/qPrefAnimations.h b/core/settings/qPrefAnimations.h deleted file mode 100644 index 450e854f9..000000000 --- a/core/settings/qPrefAnimations.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#ifndef QPREFANIMATIONS_H -#define QPREFANIMATIONS_H -#include "core/pref.h" - -#include <QObject> - -class qPrefAnimations : public QObject { - Q_OBJECT - Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speed_changed); - -public: - qPrefAnimations(QObject *parent = NULL); - static qPrefAnimations *instance(); - - // Load/Sync local settings (disk) and struct preference - static void loadSync(bool doSync); - static void load() { loadSync(false); } - static void sync() { loadSync(true); } - -public: - static int animation_speed() { return prefs.animation_speed; } - -public slots: - static void set_animation_speed(int value); - -signals: - void animation_speed_changed(int value); - -private: - // functions to load/sync variable with disk - static void disk_animation_speed(bool doSync); -}; - -#endif diff --git a/core/settings/qPrefDisplay.cpp b/core/settings/qPrefDisplay.cpp index a75d1f48b..680fdc923 100644 --- a/core/settings/qPrefDisplay.cpp +++ b/core/settings/qPrefDisplay.cpp @@ -8,6 +8,39 @@ static const QString group = QStringLiteral("Display"); +QPointF qPrefDisplay::st_tooltip_position; +static const QPointF st_tooltip_position_default = QPointF(0,0); + +QString qPrefDisplay::st_lastDir; +static const QString st_lastDir_default = ""; + +QString qPrefDisplay::st_theme; +static const QString st_theme_default = "Blue"; + +QString qPrefDisplay::st_UserSurvey; +static const QString st_UserSurvey_default = ""; + +QByteArray qPrefDisplay::st_mainSplitter; +static const QByteArray st_mainSplitter_default = ""; + +QByteArray qPrefDisplay::st_topSplitter; +static const QByteArray st_topSplitter_default = ""; + +QByteArray qPrefDisplay::st_bottomSplitter; +static const QByteArray st_bottomSplitter_default = ""; + +bool qPrefDisplay::st_maximized; +static bool st_maximized_default = false; + +QByteArray qPrefDisplay::st_geometry; +static const QByteArray st_geometry_default = 0; + +QByteArray qPrefDisplay::st_windowState; +static const QByteArray st_windowState_default = 0; + +int qPrefDisplay::st_lastState; +static int st_lastState_default = false; + qPrefDisplay::qPrefDisplay(QObject *parent) : QObject(parent) { } @@ -19,11 +52,16 @@ qPrefDisplay *qPrefDisplay::instance() void qPrefDisplay::loadSync(bool doSync) { + disk_animation_speed(doSync); disk_divelist_font(doSync); disk_font_size(doSync); disk_display_invalid_dives(doSync); disk_show_developer(doSync); - disk_theme(doSync); + if (!doSync) { + load_tooltip_position(); + load_theme(); + load_UserSurvey(); + } } void qPrefDisplay::set_divelist_font(const QString &value) @@ -69,13 +107,13 @@ void qPrefDisplay::disk_font_size(bool doSync) setCorrectFont(); } +//JAN static const QString group = QStringLiteral("Animations"); +HANDLE_PREFERENCE_INT(Display, "/animation_speed", animation_speed); + HANDLE_PREFERENCE_BOOL(Display, "/displayinvalid", display_invalid_dives); HANDLE_PREFERENCE_BOOL(Display, "/show_developer", show_developer); -HANDLE_PREFERENCE_TXT(Display, "/theme", theme); - - void qPrefDisplay::setCorrectFont() { // get the font from the settings or our defaults @@ -102,3 +140,25 @@ void qPrefDisplay::setCorrectFont() prefs.display_invalid_dives = qPrefPrivate::propValue(group + "/displayinvalid", default_prefs.display_invalid_dives).toBool(); } + +HANDLE_PROP_QSTRING(Display, "FileDialog/LastDir", lastDir); + +HANDLE_PROP_QSTRING(Display, "Theme/currentTheme", theme); + +HANDLE_PROP_QPOINTF(Display, "ProfileMap/tooltip_position", tooltip_position); + +HANDLE_PROP_QSTRING(Display, "UserSurvey/SurveyDone", UserSurvey); + +HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/mainSplitter", mainSplitter); + +HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/topSplitter", topSplitter); + +HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/bottomSplitter", bottomSplitter); + +HANDLE_PROP_BOOL(Display, "MainWindow/maximized", maximized); + +HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/geometry", geometry); + +HANDLE_PROP_QBYTEARRAY(Display, "MainWindow/windowState", windowState); + +HANDLE_PROP_INT(Display, "MainWindow/lastState", lastState); diff --git a/core/settings/qPrefDisplay.h b/core/settings/qPrefDisplay.h index ba7be7200..5a7eb7aac 100644 --- a/core/settings/qPrefDisplay.h +++ b/core/settings/qPrefDisplay.h @@ -4,14 +4,26 @@ #include "core/pref.h" #include <QObject> +#include <QPointF> class qPrefDisplay : public QObject { Q_OBJECT + Q_PROPERTY(int animation_speed READ animation_speed WRITE set_animation_speed NOTIFY animation_speed_changed); Q_PROPERTY(QString divelist_font READ divelist_font WRITE set_divelist_font NOTIFY divelist_font_changed); Q_PROPERTY(double font_size READ font_size WRITE set_font_size NOTIFY font_size_changed); Q_PROPERTY(bool display_invalid_dives READ display_invalid_dives WRITE set_display_invalid_dives NOTIFY display_invalid_dives_changed); + Q_PROPERTY(QString lastDir READ lastDir WRITE set_lastDir NOTIFY lastDir_changed); Q_PROPERTY(bool show_developer READ show_developer WRITE set_show_developer NOTIFY show_developer_changed); Q_PROPERTY(QString theme READ theme WRITE set_theme NOTIFY theme_changed); + Q_PROPERTY(QPointF tooltip_position READ tooltip_position WRITE set_tooltip_position NOTIFY tooltip_position_changed); + Q_PROPERTY(QString UserSurvey READ UserSurvey WRITE set_UserSurvey NOTIFY UserSurvey_changed); + Q_PROPERTY(QByteArray mainSplitter READ mainSplitter WRITE set_mainSplitter NOTIFY mainSplitter_changed); + Q_PROPERTY(QByteArray topSplitter READ topSplitter WRITE set_topSplitter NOTIFY topSplitter_changed); + Q_PROPERTY(QByteArray bottomSplitter READ bottomSplitter WRITE set_bottomSplitter NOTIFY bottomSplitter_changed); + Q_PROPERTY(bool maximized READ maximized WRITE set_maximized NOTIFY maximized_changed); + Q_PROPERTY(QByteArray geometry READ geometry WRITE set_geometry NOTIFY geometry_changed); + Q_PROPERTY(QByteArray windowState READ windowState WRITE set_windowState NOTIFY windowState_changed); + Q_PROPERTY(int lastState READ lastState WRITE set_lastState NOTIFY lastState_changed); public: qPrefDisplay(QObject *parent = NULL); @@ -23,35 +35,94 @@ public: static void sync() { loadSync(true); } public: + static int animation_speed() { return prefs.animation_speed; } static QString divelist_font() { return prefs.divelist_font; } static double font_size() { return prefs.font_size; } static bool display_invalid_dives() { return prefs.display_invalid_dives; } + static QString lastDir() { return st_lastDir; ; } static bool show_developer() { return prefs.show_developer; } - static QString theme() { return prefs.theme; } + static QString theme() { return st_theme; } + static QPointF tooltip_position() { return st_tooltip_position; } + static QString UserSurvey() { return st_UserSurvey; } + static QByteArray mainSplitter() { return st_mainSplitter; } + static QByteArray topSplitter() { return st_topSplitter; } + static QByteArray bottomSplitter() { return st_bottomSplitter; } + static bool maximized() { return st_maximized; } + static QByteArray geometry() { return st_geometry; } + static QByteArray windowState() { return st_windowState; } + static int lastState() { return st_lastState; } public slots: + static void set_animation_speed(int value); static void set_divelist_font(const QString &value); static void set_font_size(double value); static void set_display_invalid_dives(bool value); + static void set_lastDir(const QString &value); static void set_show_developer(bool value); static void set_theme(const QString &value); + static void set_tooltip_position(const QPointF &value); + static void set_UserSurvey(const QString &value); + static void set_mainSplitter(const QByteArray &value); + static void set_topSplitter(const QByteArray &value); + static void set_bottomSplitter(const QByteArray &value); + static void set_maximized(bool value); + static void set_geometry(const QByteArray& value); + static void set_windowState(const QByteArray& value); + static void set_lastState(int value); signals: + void animation_speed_changed(int value); void divelist_font_changed(const QString &value); void font_size_changed(double value); void display_invalid_dives_changed(bool value); + void lastDir_changed(const QString &value); void show_developer_changed(bool value); void theme_changed(const QString &value); + void tooltip_position_changed(const QPointF &value); + void UserSurvey_changed(const QString &value); + void mainSplitter_changed(const QByteArray &value); + void topSplitter_changed(const QByteArray &value); + void bottomSplitter_changed(const QByteArray &value); + void maximized_changed(bool value); + void geometry_changed(const QByteArray& value); + void windowState_changed(const QByteArray& value); + void lastState_changed(int value); private: // functions to load/sync variable with disk + static void disk_animation_speed(bool doSync); static void disk_divelist_font(bool doSync); static void disk_font_size(bool doSync); static void disk_display_invalid_dives(bool doSync); static void disk_show_developer(bool doSync); - static void disk_theme(bool doSync); + + // functions to handle class variables + static void load_lastDir(); + static void load_theme(); + static void load_tooltip_position(); + static void load_UserSurvey(); + static void load_mainSplitter(); + static void load_topSplitter(); + static void load_bottomSplitter(); + static void load_maximized(); + static void load_geometry(); + static void load_windowState(); + static void load_lastState(); // font helper function static void setCorrectFont(); + + // Class variables not present in structure preferences + static QString st_lastDir; + static QString st_theme; + static QPointF st_tooltip_position; + static QString st_UserSurvey; + static QByteArray st_mainSplitter; + static QByteArray st_topSplitter; + static QByteArray st_bottomSplitter; + static bool st_maximized; + static QByteArray st_geometry; + static QByteArray st_windowState; + static int st_lastState; }; #endif |