QML UI: remember the theme

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-06-23 19:35:48 -07:00
parent 26b206af1f
commit 206df227f8
4 changed files with 28 additions and 1 deletions

View file

@ -17,6 +17,7 @@ Kirigami.Page {
onTriggered: {
manager.distanceThreshold = distanceThreshold.text
manager.timeThreshold = timeThreshold.text
manager.theme = subsurfaceTheme.currentTheme
manager.savePreferences()
stackView.pop()
}

View file

@ -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

View file

@ -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;

View file

@ -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();