diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-03-30 21:01:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-30 13:54:12 -0700 |
commit | 79bf243ec0055f546efa2b4dee20424f291f968d (patch) | |
tree | 2590d350fd66a53e7faac222ff4c3807b586ae22 /mobile-widgets | |
parent | 7f2eaba5743e8efe9850075ebd911347dd9b3a85 (diff) | |
download | subsurface-79bf243ec0055f546efa2b4dee20424f291f968d.tar.gz |
cleanup: make members of ThemeInterface non-static
We have a singleton class ThemeInterface, which means that it
is global and exists only once. It's members are static, i.e.
also global. A message from the department of redundancy department?
In any case, that makes no sense. Let's just make these members
local to the class.
I would even rip out the whole singleton thing, since the object
is not accessed anywhere outside from QML. Let's keep it for now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/themeinterface.cpp | 61 | ||||
-rw-r--r-- | mobile-widgets/themeinterface.h | 46 |
2 files changed, 43 insertions, 64 deletions
diff --git a/mobile-widgets/themeinterface.cpp b/mobile-widgets/themeinterface.cpp index e3ebbe5a2..3ce0203b4 100644 --- a/mobile-widgets/themeinterface.cpp +++ b/mobile-widgets/themeinterface.cpp @@ -5,27 +5,6 @@ #include "core/settings/qPrefDisplay.h" #include <QFontInfo> -QColor themeInterface::m_backgroundColor; -QColor themeInterface::m_contrastAccentColor; -QColor themeInterface::m_darkerPrimaryColor; -QColor themeInterface::m_darkerPrimaryTextColor; -QColor themeInterface::m_drawerColor; -QColor themeInterface::m_lightDrawerColor; -QColor themeInterface::m_lightPrimaryColor; -QColor themeInterface::m_lightPrimaryTextColor; -QColor themeInterface::m_primaryColor; -QColor themeInterface::m_primaryTextColor; -QColor themeInterface::m_secondaryTextColor; -QColor themeInterface::m_textColor; - -double themeInterface::m_basePointSize; -double themeInterface::m_headingPointSize; -double themeInterface::m_regularPointSize; -double themeInterface::m_smallPointSize; -double themeInterface::m_titlePointSize; - -QString themeInterface::m_currentTheme; - const QColor BLUE_BACKGROUND_COLOR = "#eff0f1"; const QColor BLUE_CONTRAST_ACCENT_COLOR = "#FF5722"; const QColor BLUE_DARKER_PRIMARY_COLOR = "#303F9f"; @@ -74,7 +53,7 @@ themeInterface *themeInterface::instance() void themeInterface::setup(QQmlContext *ct) { // Register interface class - ct->setContextProperty("subsurfaceTheme", instance()); + ct->setContextProperty("subsurfaceTheme", this); // get current theme m_currentTheme = qPrefDisplay::theme(); @@ -92,8 +71,8 @@ void themeInterface::set_currentTheme(const QString &theme) { m_currentTheme = theme; qPrefDisplay::set_theme(m_currentTheme); - instance()->update_theme(); - emit instance()->currentThemeChanged(theme); + update_theme(); + emit currentThemeChanged(theme); } double themeInterface::currentScale() @@ -104,7 +83,7 @@ void themeInterface::set_currentScale(double newScale) { if (newScale != qPrefDisplay::mobile_scale()) { qPrefDisplay::set_mobile_scale(newScale); - emit instance()->currentScaleChanged(qPrefDisplay::mobile_scale()); + emit currentScaleChanged(qPrefDisplay::mobile_scale()); } // Set current font size @@ -112,16 +91,16 @@ void themeInterface::set_currentScale(double newScale) // adjust all used font sizes m_regularPointSize = m_basePointSize * qPrefDisplay::mobile_scale(); - emit instance()->regularPointSizeChanged(m_regularPointSize); + emit regularPointSizeChanged(m_regularPointSize); m_headingPointSize = m_regularPointSize * 1.2; - emit instance()->headingPointSizeChanged(m_headingPointSize); + emit headingPointSizeChanged(m_headingPointSize); m_smallPointSize = m_regularPointSize * 0.8; - emit instance()->smallPointSizeChanged(m_smallPointSize); + emit smallPointSizeChanged(m_smallPointSize); m_titlePointSize = m_regularPointSize * 1.5; - emit instance()->titlePointSizeChanged(m_titlePointSize); + emit titlePointSizeChanged(m_titlePointSize); } void themeInterface::update_theme() @@ -166,16 +145,16 @@ void themeInterface::update_theme() m_secondaryTextColor = DARK_SECONDARY_TEXT_COLOR; m_textColor = DARK_TEXT_COLOR; } - emit instance()->backgroundColorChanged(m_backgroundColor); - emit instance()->contrastAccentColorChanged(m_contrastAccentColor); - emit instance()->darkerPrimaryColorChanged(m_darkerPrimaryColor); - emit instance()->darkerPrimaryTextColorChanged(m_darkerPrimaryTextColor); - emit instance()->drawerColorChanged(m_drawerColor); - emit instance()->lightDrawerColorChanged(m_lightDrawerColor); - emit instance()->lightPrimaryColorChanged(m_lightPrimaryColor); - emit instance()->lightPrimaryTextColorChanged(m_lightPrimaryTextColor); - emit instance()->primaryColorChanged(m_primaryColor); - emit instance()->primaryTextColorChanged(m_primaryTextColor); - emit instance()->secondaryTextColorChanged(m_secondaryTextColor); - emit instance()->textColorChanged(m_textColor); + emit backgroundColorChanged(m_backgroundColor); + emit contrastAccentColorChanged(m_contrastAccentColor); + emit darkerPrimaryColorChanged(m_darkerPrimaryColor); + emit darkerPrimaryTextColorChanged(m_darkerPrimaryTextColor); + emit drawerColorChanged(m_drawerColor); + emit lightDrawerColorChanged(m_lightDrawerColor); + emit lightPrimaryColorChanged(m_lightPrimaryColor); + emit lightPrimaryTextColorChanged(m_lightPrimaryTextColor); + emit primaryColorChanged(m_primaryColor); + emit primaryTextColorChanged(m_primaryTextColor); + emit secondaryTextColorChanged(m_secondaryTextColor); + emit textColorChanged(m_textColor); } diff --git a/mobile-widgets/themeinterface.h b/mobile-widgets/themeinterface.h index 35bb251a8..622ce5eaa 100644 --- a/mobile-widgets/themeinterface.h +++ b/mobile-widgets/themeinterface.h @@ -36,12 +36,12 @@ class themeInterface : public QObject { public: static themeInterface *instance(); - static void setup(QQmlContext *ct); - static double currentScale(); + void setup(QQmlContext *ct); + double currentScale(); public slots: - static void set_currentTheme(const QString &theme); - static void set_currentScale(double); + void set_currentTheme(const QString &theme); + void set_currentScale(double); signals: void backgroundColorChanged(QColor); @@ -67,27 +67,27 @@ signals: private: themeInterface() {} - static void update_theme(); + void update_theme(); - static QColor m_backgroundColor; - static QColor m_contrastAccentColor; - static QColor m_darkerPrimaryColor; - static QColor m_darkerPrimaryTextColor; - static QColor m_drawerColor; - static QColor m_lightDrawerColor; - static QColor m_lightPrimaryColor; - static QColor m_lightPrimaryTextColor; - static QColor m_primaryColor; - static QColor m_primaryTextColor; - static QColor m_secondaryTextColor; - static QColor m_textColor; + QColor m_backgroundColor; + QColor m_contrastAccentColor; + QColor m_darkerPrimaryColor; + QColor m_darkerPrimaryTextColor; + QColor m_drawerColor; + QColor m_lightDrawerColor; + QColor m_lightPrimaryColor; + QColor m_lightPrimaryTextColor; + QColor m_primaryColor; + QColor m_primaryTextColor; + QColor m_secondaryTextColor; + QColor m_textColor; - static double m_basePointSize; - static double m_headingPointSize; - static double m_regularPointSize; - static double m_smallPointSize; - static double m_titlePointSize; + double m_basePointSize; + double m_headingPointSize; + double m_regularPointSize; + double m_smallPointSize; + double m_titlePointSize; - static QString m_currentTheme; + QString m_currentTheme; }; #endif |