diff options
author | jan Iversen <jan@casacondor.com> | 2019-02-11 16:13:01 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-26 16:42:35 -0800 |
commit | 9de296f3dd6fc93ad4cfa68528cfa733e585e352 (patch) | |
tree | e26517b46429c8737b2c906f5884d89bdccf4df2 /mobile-widgets/themeinterface.cpp | |
parent | 49616c1842f3cf2848606b25e204b25610ce928e (diff) | |
download | subsurface-9de296f3dd6fc93ad4cfa68528cfa733e585e352.tar.gz |
mobile-widgets: add themeInterface
Currently subsurfaceTheme resides in main.qml, where it does not naturally
belong.
Add C++ class that will replace subsurfaceTheme in main.qml in a 1-1 manner.
This opens future posibilities
- on top of the 3 themes, allow users to select colors/fonts
- add stylesheets to Template* components
- make day/night shift automatically.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/themeinterface.cpp')
-rw-r--r-- | mobile-widgets/themeinterface.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/mobile-widgets/themeinterface.cpp b/mobile-widgets/themeinterface.cpp new file mode 100644 index 000000000..9f2e842ee --- /dev/null +++ b/mobile-widgets/themeinterface.cpp @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "themeinterface.h" +#include "core/settings/qPrefDisplay.h" + +themeInterface *themeInterface::instance() +{ + static themeInterface *self = new themeInterface; + return self; +} + +void themeInterface::setup() +{ + // get current theme + m_currentTheme = qPrefDisplay::theme(); + update_theme(); +} + +void themeInterface::set_currentTheme(const QString &theme) +{ + m_currentTheme = theme; + qPrefDisplay::set_theme(m_currentTheme); + update_theme(); + emit currentThemeChanged(theme); +} + +void themeInterface::update_theme() +{ + if (m_currentTheme == "Blue") { + m_backgroundColor = m_blueBackgroundColor; + m_contrastAccentColor = m_blueContrastAccentColor; + m_darkerPrimaryColor = m_blueDarkerPrimaryColor; + m_darkerPrimaryTextColor = m_blueDarkerPrimaryTextColor; + m_drawerColor = m_blueDrawerColor; + m_lightDrawerColor = m_blueDrawerColor; + m_lightPrimaryColor = m_blueLightPrimaryColor; + m_lightPrimaryTextColor = m_blueLightPrimaryTextColor; + m_primaryColor = m_bluePrimaryColor; + m_primaryTextColor = m_bluePrimaryTextColor; + m_secondaryTextColor = m_blueSecondaryTextColor; + m_textColor = m_blueTextColor; + m_iconStyle = ":/icons"; + } else if (m_currentTheme == "Pink") { + m_backgroundColor = m_pinkBackgroundColor; + m_contrastAccentColor = m_pinkContrastAccentColor; + m_darkerPrimaryColor = m_pinkDarkerPrimaryColor; + m_darkerPrimaryTextColor = m_pinkDarkerPrimaryTextColor; + m_drawerColor = m_pinkDrawerColor; + m_lightDrawerColor = m_pinkDrawerColor; + m_lightPrimaryColor = m_pinkLightPrimaryColor; + m_lightPrimaryTextColor = m_pinkLightPrimaryTextColor; + m_primaryColor = m_pinkPrimaryColor; + m_primaryTextColor = m_pinkPrimaryTextColor; + m_secondaryTextColor = m_pinkSecondaryTextColor; + m_textColor = m_pinkTextColor; + m_iconStyle = ":/icons"; + } else { + m_backgroundColor = m_darkBackgroundColor; + m_contrastAccentColor = m_darkContrastAccentColor; + m_darkerPrimaryColor = m_darkDarkerPrimaryColor; + m_darkerPrimaryTextColor = m_darkDarkerPrimaryTextColor; + m_drawerColor = m_darkDrawerColor; + m_lightDrawerColor = m_darkDrawerColor; + m_lightPrimaryColor = m_darkLightPrimaryColor; + m_lightPrimaryTextColor = m_darkLightPrimaryTextColor; + m_primaryColor = m_darkPrimaryColor; + m_primaryTextColor = m_darkPrimaryTextColor; + m_secondaryTextColor = m_darkSecondaryTextColor; + m_textColor = m_darkTextColor; + m_iconStyle = ":/icons-dark"; + } +} + + |