created styling lib

This commit is contained in:
Dorian Zedler 2020-05-18 11:27:09 +02:00
parent 3f199b1511
commit 0738195675
Signed by: dorian
GPG key ID: 989DE36109AFA354
7 changed files with 204 additions and 0 deletions

1
ScStwStyling/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build/

View file

@ -0,0 +1,20 @@
!isEmpty(SCSTWSTYLING_LIB):error("ScStwLibraries.pri already included")
SCSTWSTYLING_LIB = 1
#DEPENDS
CONFIG(release, debug|release): {
SCSTWSTYLING_LIB_OUTPUT_DIR="$$PWD/build/release"
} else {
SCSTWSTYLING_LIB_OUTPUT_DIR="$$PWD/build/debug"
}
unix:LIBS += -L$$SCSTWSTYLING_LIB_OUTPUT_DIR -lScStwStyling
win32:LIBS += -L$$SCSTWSTYLING_LIB_OUTPUT_DIR -lScStwStyling1
android {
ANDROID_EXTRA_LIBS += $$SCSTWSTYLING_LIB_OUTPUT_DIR/libScStwStyling.so
}
INCLUDEPATH += "$$PWD"
INCLUDEPATH += "$$PWD"/headers

View file

@ -0,0 +1,39 @@
QT -= gui
TEMPLATE = lib
DEFINES += SCSTWSTYLING_LIBRARY
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
sources/scstwapptheme.cpp
HEADERS += \
headers/scstwapptheme.h
RESOURCES += \
resources/ScStwStylingShared.qrc
DISTFILES +=
#DEPENDS
CONFIG(release, debug|release): {
DESTDIR="$$PWD/build/release"
} else {
DESTDIR="$$PWD/build/debug"
}
# Default rules for deployment.
target.path = $$GLOBAL_TARGET_PATH/lib
!isEmpty(target.path): INSTALLS += target

View file

@ -0,0 +1,36 @@
#ifndef APPTHEME_H
#define APPTHEME_H
#include <QObject>
#include <QVariant>
class ScStwAppTheme : public QObject
{
Q_OBJECT
Q_PROPERTY(QVariant style READ getStyle NOTIFY styleChanged)
public:
explicit ScStwAppTheme(QObject *parent = nullptr);
enum Theme {
Light,
Dark
};
Q_ENUM(Theme)
private:
QMap<Theme, QVariantMap> themes;
QVariantMap * currentTheme;
Theme currentThemeKey;
signals:
void styleChanged();
public slots:
QVariant getStyle();
Q_INVOKABLE bool setTheme(Theme theme);
Q_INVOKABLE void refreshTheme();
};
#endif // APPTHEME_H

View file

@ -0,0 +1,2 @@
<!DOCTYPE RCC>
<RCC version="1.0"/>

View file

@ -0,0 +1,104 @@
#include "headers/scstwapptheme.h"
ScStwAppTheme::ScStwAppTheme(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"}
};
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->themes = QMap<Theme, QVariantMap>({{Light, tmpLightTheme}, {Dark, tmpDarkTheme}});
this->currentThemeKey = Light;
this->currentTheme = &this->themes[this->currentThemeKey];
}
QVariant ScStwAppTheme::getStyle() {
return *this->currentTheme;
}
bool ScStwAppTheme::setTheme(Theme theme) {
if(theme > Dark || theme < Light)
return false;
this->currentThemeKey = theme;
this->refreshTheme();
return true;
}
void ScStwAppTheme::refreshTheme() {
this->currentTheme = &this->themes[this->currentThemeKey];
emit this->styleChanged();
}

2
ScStwStyling/test.qrc Normal file
View file

@ -0,0 +1,2 @@
<!DOCTYPE RCC>
<RCC version="1.0"/>