finished up new theme engine

This commit is contained in:
Dorian Zedler 2020-05-19 12:43:02 +02:00
parent 0fe9bc24b0
commit c027fa242a
Signed by: dorian
GPG key ID: 989DE36109AFA354
3 changed files with 74 additions and 46 deletions

View file

@ -8,28 +8,36 @@
class ScStwAppTheme : public QObject class ScStwAppTheme : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QVariant colors READ getColors) Q_PROPERTY(QVariant colors READ getColors NOTIFY colorsChanged)
Q_PROPERTY(QVariant icons READ getIcons) Q_PROPERTY(QVariant icons READ getIcons NOTIFY iconsChanged)
Q_PROPERTY(QVariant fonts READ getFonts) Q_PROPERTY(QVariant fonts READ getFonts NOTIFY fontsChanged)
Q_PROPERTY(QVariant images READ getImages) Q_PROPERTY(QVariant images READ getImages NOTIFY imagesChanged)
public: public:
explicit ScStwAppTheme(QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent = nullptr); explicit ScStwAppTheme(QString name, QVariantMap colors = {}, QVariantMap icons = {}, QVariantMap fonts = {}, QVariantMap images = {}, QObject *parent = nullptr);
private: private:
QString name;
QVariantMap colors; QVariantMap colors;
QVariantMap icons; QVariantMap icons;
QVariantMap fonts; QVariantMap fonts;
QVariantMap images; QVariantMap images;
signals: signals:
void colorsChanged();
void iconsChanged();
void fontsChanged();
void imagesChanged();
public slots: public slots:
QString getName();
QVariant getColors(); QVariant getColors();
QVariant getIcons(); QVariant getIcons();
QVariant getFonts(); QVariant getFonts();
QVariant getImages(); QVariant getImages();
}; };
#endif // APPTHEME_H #endif // APPTHEME_H

View file

@ -1,13 +1,17 @@
#include "headers/scstwapptheme.h" #include "headers/scstwapptheme.h"
ScStwAppTheme::ScStwAppTheme(QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent) : QObject(parent) ScStwAppTheme::ScStwAppTheme(QString name, QVariantMap colors, QVariantMap icons, QVariantMap fonts, QVariantMap images, QObject *parent) : QObject(parent)
{ {
this->name = name;
this->colors = colors; this->colors = colors;
this->icons = icons; this->icons = icons;
this->fonts = fonts; this->fonts = fonts;
this->images = images; this->images = images;
} }
QString ScStwAppTheme::getName() {
return this->name;
}
QVariant ScStwAppTheme::getColors() { QVariant ScStwAppTheme::getColors() {
return this->colors; return this->colors;

View file

@ -14,70 +14,77 @@ ScStwAppThemeManager::ScStwAppThemeManager(QObject *parent) : QObject(parent)
}; };
ScStwAppTheme * lightTheme = new ScStwAppTheme ( ScStwAppTheme * lightTheme = new ScStwAppTheme (
"Light",
{ {
{"backgroundColor", "white"}, {"background", "white"},
{"buttonColor", "white"}, {"button", "white"},
{"buttonPressedColor", "lightgrey"}, {"buttonPressed", "lightgrey"},
{"buttonBorderColor", "grey"}, {"buttonBorder", "grey"},
{"disabledButtonColor", "#d5d5d5"}, {"disabledButton", "#d5d5d5"},
{"viewColor", "white"}, {"view", "white"},
{"menuColor", "#f8f8f8"}, {"menu", "#f8f8f8"},
{"delegate1Color", "#202227"}, {"delegate1", "#202227"},
{"delegate2Color", "#202227"}, {"delegate2", "#202227"},
{"delegateBackgroundColor", "white"}, {"delegateBackground", "white"},
{"delegatePressedColor", "#dddedf"}, {"delegatePressed", "#dddedf"},
{"textColor", "black"}, {"text", "black"},
{"textDarkColor", "#232323"}, {"textDark", "#232323"},
{"disabledTextColor", "grey"}, {"disabledText", "grey"},
{"sliderColor", "#6ccaf2"}, {"slider", "#6ccaf2"},
{"successColor", "#60de26"}, {"success", "#60de26"},
{"errorColor", "#ff0000"}, {"error", "#ff0000"},
{"lineColor", "grey"}, {"line", "grey"},
}, },
{
icons icons
}, ,
{ {
{"icons", "Font Awesome 5 Free"} {"icons", "Font Awesome 5 Free"}
}, },
{ {
{"baseStationIcon", "qrc:/graphics/icons/BaseStation.png"} {"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"}
}); });
ScStwAppTheme *darkTheme = new ScStwAppTheme( ScStwAppTheme *darkTheme = new ScStwAppTheme(
"Dark",
{ {
{"backgroundColor", "#2d3037"}, {"background", "#2d3037"},
{"buttonColor", "#202227"}, {"button", "#202227"},
{"buttonPressedColor", "#41454f"}, {"buttonPressed", "#41454f"},
{"buttonBorderColor", "grey"}, {"buttonBorder", "grey"},
{"disabledButtonColor", "#555555"}, {"disabledButton", "#555555"},
{"viewColor", "#202227"}, {"view", "#202227"},
{"menuColor", "#292b32"}, {"menu", "#292b32"},
{"delegate1Color", "#202227"}, {"delegate1", "#202227"},
{"delegate2Color", "#202227"}, {"delegate2", "#202227"},
{"delegateBackgroundColor", "#202227"}, {"delegateBackground", "#202227"},
{"delegatePressedColor", "#41454f"}, {"delegatePressed", "#41454f"},
{"textColor", "#ffffff"}, {"text", "#ffffff"},
{"textDarkColor", "#232323"}, {"textDark", "#232323"},
{"disabledTextColor", "#777777"}, {"disabledText", "#777777"},
{"sliderColor", "#6ccaf2"}, {"slider", "#6ccaf2"},
{"successColor", "#6bd43b"}, {"success", "#6bd43b"},
{"errorColor", "#e03b2f"}, {"error", "#e03b2f"},
{"lineColor", "grey"}, {"line", "grey"},
{"iconFontName", "Font Awesome 5 Free"}, {"iconFontName", "Font Awesome 5 Free"},
}, },
@ -118,3 +125,12 @@ bool ScStwAppThemeManager::setTheme(QString themeName) {
return true; return true;
} }
ScStwAppTheme * ScStwAppThemeManager::findThemeByName(QString themeName) {
foreach (ScStwAppTheme *theme, this->themes) {
if(theme->getName() == themeName)
return theme;
}
return nullptr;
}