- moved app theme to new lib
This commit is contained in:
parent
970e37b998
commit
074fe66e57
8 changed files with 17 additions and 176 deletions
|
@ -3,7 +3,9 @@ CONFIG += ordered
|
||||||
|
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
ScStwLibraries \
|
ScStwLibraries \
|
||||||
|
ScStwStyling \
|
||||||
ScStwApp
|
ScStwApp
|
||||||
|
|
||||||
ScStwApp.file = ScStwSrc/ScStwApp.pro
|
ScStwApp.file = ScStwSrc/ScStwApp.pro
|
||||||
ScStwLibraries.file = shared-libraries/ScStwLibraries/ScStwLibraries.pro
|
ScStwLibraries.file = shared-libraries/ScStwLibraries/ScStwLibraries.pro
|
||||||
|
ScStwStyling.file = shared-libraries/ScStwStyling/ScStwStyling.pro
|
||||||
|
|
|
@ -22,20 +22,15 @@ TARGET = speedclimbing_stw
|
||||||
|
|
||||||
# include submodules
|
# include submodules
|
||||||
include($$PWD/../shared-libraries/ScStwLibraries/ScStwLibraries.pri)
|
include($$PWD/../shared-libraries/ScStwLibraries/ScStwLibraries.pri)
|
||||||
|
include($$PWD/../shared-libraries/ScStwStyling/ScStwStyling.pri)
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
sources/scstwappbackend.cpp \
|
sources/scstwappbackend.cpp \
|
||||||
sources/main.cpp \
|
sources/main.cpp \
|
||||||
sources/appsettings.cpp \
|
sources/appsettings.cpp
|
||||||
#sources/speedtimer.cpp \
|
|
||||||
#sources/climbingrace.cpp \
|
|
||||||
sources/apptheme.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
headers/appsettings.h \
|
headers/appsettings.h \
|
||||||
#headers/speedtimer.h \
|
|
||||||
#headers/climbingrace.h \
|
|
||||||
headers/apptheme.h \
|
|
||||||
headers/scstwappbackend.h
|
headers/scstwappbackend.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
#ifndef APPTHEME_H
|
|
||||||
#define APPTHEME_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QVariant>
|
|
||||||
#include "appsettings.h"
|
|
||||||
|
|
||||||
class AppTheme : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QVariant style READ getStyle NOTIFY styleChanged)
|
|
||||||
public:
|
|
||||||
explicit AppTheme(QObject *parent = nullptr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVariant lightTheme;
|
|
||||||
QVariant darkTheme;
|
|
||||||
|
|
||||||
QVariant * currentTheme;
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void styleChanged();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
QVariant getStyle();
|
|
||||||
Q_INVOKABLE void changeTheme();
|
|
||||||
Q_INVOKABLE void refreshTheme();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // APPTHEME_H
|
|
|
@ -5,6 +5,8 @@ import QtQuick.Controls 2.2
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
|
import com.itsblue.speedclimbingstopwatch 2.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@ -49,11 +51,12 @@ Column {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parentObj.delegateHeight
|
height: parentObj.delegateHeight
|
||||||
|
|
||||||
checked: speedBackend.readSetting("theme") === "Dark"
|
checked: parseInt(speedBackend.readSetting("theme")) === AppTheme.Dark
|
||||||
|
|
||||||
onCheckedChanged: {
|
onCheckedChanged: {
|
||||||
speedBackend.writeSetting("theme", checked ? "Dark":"Light")
|
var newTheme = checked ? AppTheme.Dark:AppTheme.Light
|
||||||
appTheme.refreshTheme()
|
speedBackend.writeSetting("theme", newTheme)
|
||||||
|
appTheme.setTheme(newTheme)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,10 @@ Window {
|
||||||
|
|
||||||
AppTheme {
|
AppTheme {
|
||||||
id: appTheme
|
id: appTheme
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
appTheme.setTheme(speedBackend.readSetting("theme"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------
|
/*------------------------
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
#include "headers/apptheme.h"
|
|
||||||
|
|
||||||
AppTheme::AppTheme(QObject *parent) : QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
QVariantMap tmpDarkTheme = {
|
|
||||||
{"backgroundColor", "#2d3037"},
|
|
||||||
|
|
||||||
{"buttonColor", "#202227"},
|
|
||||||
{"buttonPressedColor", "#41454f"},
|
|
||||||
{"buttonBorderColor", "grey"},
|
|
||||||
{"disabledButtonColor", "#555555"},
|
|
||||||
|
|
||||||
{"viewColor", "#202227"},
|
|
||||||
{"menuColor", "#292b32"},
|
|
||||||
|
|
||||||
{"delegate1Color", "#202227"},
|
|
||||||
{"delegate2Color", "#202227"},
|
|
||||||
{"delegateBackgroundColor", "#202227"},
|
|
||||||
{"delegatePressedColor", "#41454f"},
|
|
||||||
|
|
||||||
{"textColor", "#ffffff"},
|
|
||||||
{"textDarkColor", "#232323"},
|
|
||||||
{"disabledTextColor", "#777777"},
|
|
||||||
|
|
||||||
{"sliderColor", "#6ccaf2"},
|
|
||||||
|
|
||||||
{"successColor", "#6bd43b"},
|
|
||||||
{"errorColor", "#e03b2f"},
|
|
||||||
|
|
||||||
{"lineColor", "grey"},
|
|
||||||
|
|
||||||
{"backIcon", "qrc:/graphics/icons/back.png"},
|
|
||||||
{"settIcon", "qrc:/graphics/icons/settings.png"},
|
|
||||||
{"buzzerIcon", "qrc:/graphics/icons/buzzer.png"},
|
|
||||||
{"startpadIcon", "qrc:/graphics/icons/startpad.png"},
|
|
||||||
{"baseStationIcon", "qrc:/graphics/icons/BaseStation.png"},
|
|
||||||
{"profilesIcon", "qrc:/graphics/icons/user.png"},
|
|
||||||
{"confirmIcon", "qrc:/graphics/icons/ok.png"}
|
|
||||||
|
|
||||||
};
|
|
||||||
this->darkTheme = tmpDarkTheme;
|
|
||||||
|
|
||||||
QVariantMap tmpLightTheme = {
|
|
||||||
{"backgroundColor", "white"},
|
|
||||||
|
|
||||||
{"buttonColor", "white"},
|
|
||||||
{"buttonPressedColor", "lightgrey"},
|
|
||||||
{"buttonBorderColor", "grey"},
|
|
||||||
{"disabledButtonColor", "#d5d5d5"},
|
|
||||||
|
|
||||||
{"viewColor", "white"},
|
|
||||||
{"menuColor", "#f8f8f8"},
|
|
||||||
|
|
||||||
{"delegate1Color", "#202227"},
|
|
||||||
{"delegate2Color", "#202227"},
|
|
||||||
{"delegateBackgroundColor", "white"},
|
|
||||||
{"delegatePressedColor", "#dddedf"},
|
|
||||||
|
|
||||||
{"textColor", "black"},
|
|
||||||
{"textDarkColor", "#232323"},
|
|
||||||
{"disabledTextColor", "grey"},
|
|
||||||
|
|
||||||
{"sliderColor", "#6ccaf2"},
|
|
||||||
|
|
||||||
{"successColor", "#60de26"},
|
|
||||||
{"errorColor", "#ff0000"},
|
|
||||||
|
|
||||||
{"lineColor", "grey"},
|
|
||||||
|
|
||||||
{"backIcon", "qrc:/graphics/icons/back_black.png"},
|
|
||||||
{"settIcon", "qrc:/graphics/icons/settings_black.png"},
|
|
||||||
{"buzzerIcon", "qrc:/graphics/icons/buzzer_black.png"},
|
|
||||||
{"startpadIcon", "qrc:/graphics/icons/startpad_black.png"},
|
|
||||||
{"baseStationIcon", "qrc:/graphics/icons/BaseStation_black.png"},
|
|
||||||
{"profilesIcon", "qrc:/graphics/icons/user_black.png"},
|
|
||||||
{"confirmIcon", "qrc:/graphics/icons/ok_black.png"}
|
|
||||||
|
|
||||||
};
|
|
||||||
this->lightTheme = tmpLightTheme;
|
|
||||||
|
|
||||||
QString currentThemeString = pGlobalAppSettings->loadSetting("theme");
|
|
||||||
|
|
||||||
if(currentThemeString == "Light"){
|
|
||||||
this->currentTheme = &this->lightTheme;
|
|
||||||
}
|
|
||||||
else if (currentThemeString == "Dark") {
|
|
||||||
this->currentTheme = &this->darkTheme;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->currentTheme = &this->lightTheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant AppTheme::getStyle() {
|
|
||||||
return *this->currentTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppTheme::changeTheme() {
|
|
||||||
QString currentThemeString = pGlobalAppSettings->loadSetting("theme");
|
|
||||||
QString newThemeString = "Light";
|
|
||||||
|
|
||||||
if(currentThemeString == "Light"){
|
|
||||||
this->currentTheme = &this->darkTheme;
|
|
||||||
newThemeString = "Dark";
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (currentThemeString == "Dark") {
|
|
||||||
this->currentTheme = &this->lightTheme;
|
|
||||||
newThemeString = "Light";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this->currentTheme = &this->lightTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
pGlobalAppSettings->writeSetting("theme", newThemeString);
|
|
||||||
|
|
||||||
emit this->styleChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppTheme::refreshTheme() {
|
|
||||||
QString currentThemeString = pGlobalAppSettings->loadSetting("theme");
|
|
||||||
|
|
||||||
if(currentThemeString == "Light"){
|
|
||||||
this->currentTheme = &this->lightTheme;
|
|
||||||
}
|
|
||||||
else if (currentThemeString == "Dark") {
|
|
||||||
this->currentTheme = &this->darkTheme;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit this->styleChanged();
|
|
||||||
}
|
|
|
@ -53,12 +53,12 @@
|
||||||
#include "headers/appsettings.h"
|
#include "headers/appsettings.h"
|
||||||
//#include "headers/speedtimer.h"
|
//#include "headers/speedtimer.h"
|
||||||
//#include "headers/climbingrace.h"
|
//#include "headers/climbingrace.h"
|
||||||
#include "headers/apptheme.h"
|
|
||||||
#include "headers/scstwappbackend.h"
|
#include "headers/scstwappbackend.h"
|
||||||
#include <scstwtimer.h>
|
#include <scstwtimer.h>
|
||||||
#include <scstwrace.h>
|
#include <scstwrace.h>
|
||||||
#include <ScStw.hpp>
|
#include <ScStw.hpp>
|
||||||
#include <scstwtimer.h>
|
#include <scstwtimer.h>
|
||||||
|
#include <scstwapptheme.h>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterType<ScStwAppBackend>("com.itsblue.speedclimbingstopwatch", 2, 0, "SpeedBackend");
|
qmlRegisterType<ScStwAppBackend>("com.itsblue.speedclimbingstopwatch", 2, 0, "SpeedBackend");
|
||||||
qmlRegisterType<ScStwRace>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwRace");
|
qmlRegisterType<ScStwRace>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwRace");
|
||||||
qmlRegisterType<ScStwTimer>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwTimer");
|
qmlRegisterType<ScStwTimer>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwTimer");
|
||||||
qmlRegisterType<AppTheme>("com.itsblue.speedclimbingstopwatch", 2, 0, "AppTheme");
|
qmlRegisterType<ScStwAppTheme>("com.itsblue.speedclimbingstopwatch", 2, 0, "AppTheme");
|
||||||
//qmlRegisterUncreatableType<ScStw>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStw", "This is a static class and therefore not instantiable");
|
//qmlRegisterUncreatableType<ScStw>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStw", "This is a static class and therefore not instantiable");
|
||||||
qmlRegisterType<ScStw>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStw");
|
qmlRegisterType<ScStw>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStw");
|
||||||
qmlRegisterType<ScStwClient>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwClient");
|
qmlRegisterType<ScStwClient>("com.itsblue.speedclimbingstopwatch", 2, 0, "ScStwClient");
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3f199b151131775e572c964bd3bb64120940c153
|
Subproject commit ddc48986ad557f9e8ef1f779f9e0d42a128d81cf
|
Reference in a new issue