diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-06-23 19:35:48 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-06-23 19:49:57 -0700 |
commit | 206df227f8cf7026af7f67a49d717ba67a51d944 (patch) | |
tree | 0bd08af223a474fa178abb9e119c3c2fe66b32b1 | |
parent | 26b206af1ffdc2c73c5f2bd5f82e6559710b480b (diff) | |
download | subsurface-206df227f8cf7026af7f67a49d717ba67a51d944.tar.gz |
QML UI: remember the theme
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qml/Preferences.qml | 1 | ||||
-rw-r--r-- | mobile-widgets/qml/main.qml | 8 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 15 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 5 |
4 files changed, 28 insertions, 1 deletions
diff --git a/mobile-widgets/qml/Preferences.qml b/mobile-widgets/qml/Preferences.qml index 7e18e29d0..4e0ac87f1 100644 --- a/mobile-widgets/qml/Preferences.qml +++ b/mobile-widgets/qml/Preferences.qml @@ -17,6 +17,7 @@ Kirigami.Page { onTriggered: { manager.distanceThreshold = distanceThreshold.text manager.timeThreshold = timeThreshold.text + manager.theme = subsurfaceTheme.currentTheme manager.savePreferences() stackView.pop() } diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 508e1edfe..fe8c58353 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -404,7 +404,13 @@ Kirigami.ApplicationWindow { Kirigami.Theme.buttonHoverColor = Qt.binding(function() { return darkerPrimaryColor }) // this needs to pick the theme from persistent preference settings - blueTheme() + var theme = manager.theme + if (theme == "Blue") + blueTheme() + else if (theme == "Pink") + pinkTheme() + else + darkTheme() } } property Item stackView: pageStack diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 9c78b2eb0..4e7310407 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1250,6 +1250,21 @@ void QMLManager::setTimeThreshold(int time) emit timeThresholdChanged(); } +void QMLManager::setTheme(QString theme) +{ + QSettings s; + s.beginGroup("Theme"); + s.setValue("currentTheme", theme); + emit themeChanged(); +} + +QString QMLManager::theme() const +{ + QSettings s; + s.beginGroup("Theme"); + return s.value("currentTheme", "Blue").toString(); +} + bool QMLManager::loadFromCloud() const { return m_loadFromCloud; diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index f1ccf6403..f37389acd 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -25,6 +25,7 @@ class QMLManager : public QObject { Q_PROPERTY(bool locationServiceAvailable READ locationServiceAvailable WRITE setLocationServiceAvailable NOTIFY locationServiceAvailableChanged) Q_PROPERTY(int distanceThreshold READ distanceThreshold WRITE setDistanceThreshold NOTIFY distanceThresholdChanged) Q_PROPERTY(int timeThreshold READ timeThreshold WRITE setTimeThreshold NOTIFY timeThresholdChanged) + Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(bool loadFromCloud READ loadFromCloud WRITE setLoadFromCloud NOTIFY loadFromCloudChanged) Q_PROPERTY(QString startPageText READ startPageText WRITE setStartPageText NOTIFY startPageTextChanged) Q_PROPERTY(bool verboseEnabled READ verboseEnabled WRITE setVerboseEnabled NOTIFY verboseEnabledChanged) @@ -79,6 +80,9 @@ public: int timeThreshold() const; void setTimeThreshold(int time); + QString theme() const; + void setTheme(QString theme); + bool loadFromCloud() const; void setLoadFromCloud(bool done); void syncLoadFromCloud(); @@ -209,6 +213,7 @@ signals: void verboseEnabledChanged(); void logTextChanged(); void timeThresholdChanged(); + void themeChanged(); void distanceThresholdChanged(); void loadFromCloudChanged(); void startPageTextChanged(); |