diff options
author | Grigorii Zimin <gzimin@luxoft.com> | 2020-02-17 14:20:54 +0300 |
---|---|---|
committer | Grigorii Zimin <gzimin@luxoft.com> | 2020-02-19 09:38:47 +0000 |
commit | 4ea370f96765562e8eba888be081270c1c8941dd (patch) | |
tree | 05216c1c065a80d6ce881b8295723c6512cfd1af | |
parent | 1212d532a7cdf397e3fcdb12ae6b698553eb8b0e (diff) |
[colors] restore transparent color change mechanism
-- the settings app should not use any "smart" updates on theme/color
change
-- system UI is only one place that should set the right color pallete
for the selected theme
-- this patch removes all buggy code related to color selection save steps
-- there will be another patch which uses QSettings for color settings save
Task-number: AUTOSUITE-1479
Change-Id: I6ebb4c54f46aa306b373e60ed9d0f90dd7ef7cfd
Reviewed-by: Egor Nemtsev <enemtsev@luxoft.com>
-rw-r--r-- | apps/com.pelagicore.apps.settings/store/RootStore.qml | 30 | ||||
-rw-r--r-- | sysui/stores/RootStore.qml | 48 |
2 files changed, 14 insertions, 64 deletions
diff --git a/apps/com.pelagicore.apps.settings/store/RootStore.qml b/apps/com.pelagicore.apps.settings/store/RootStore.qml index 09b8cd18..94b77053 100644 --- a/apps/com.pelagicore.apps.settings/store/RootStore.qml +++ b/apps/com.pelagicore.apps.settings/store/RootStore.qml @@ -90,11 +90,7 @@ QtObject { } // Accent Colors & themes segment - property bool startupAccentColor: true property var accentColorsModel: Config._initAccentColors(uiSettings.theme) - property string lighThemeLastAccColor: "#d35756" - property string darkThemeLastAccColor: "#087559" - readonly property ListModel themeModel: ListModel { // TODO: This data will be populated from settings server later // the server stores the "theme" as an integer @@ -107,18 +103,6 @@ QtObject { root.accentColorsModel.forEach(function(element) { element.selected = Qt.colorEqual(element.color, accentColor); }); - if (startupAccentColor) { - //Prevent setting back light theme's last accent color in cases when the UI - //was closed with light theme set. If this is the case, reset dark theme's - //default accent color. - var accColorInPalette = root.accentColorsModel.find(function(color) { - return (color.color === accentColor); - }); - if (accColorInPalette === undefined) { - uiSettings.accentColor = accentColorsModel[0].color; - } - startupAccentColor = false; - } } } @@ -143,21 +127,9 @@ QtObject { uiSettings.accentColor = value; } + //value: 1 -- dark, 0 -- light function updateTheme(value) { - if (value === 1 && (root.lighThemeLastAccColor !== uiSettings.accentColor)) { - root.lighThemeLastAccColor = uiSettings.accentColor; - } else if (value === 0 && (root.darkThemeLastAccColor !== uiSettings.accentColor)) { - root.darkThemeLastAccColor = uiSettings.accentColor; - } uiSettings.setTheme(value); - //set previous to theme accentColor - if (lighThemeLastAccColor !== "" && value === 0) { - updateAccentColor(root.lighThemeLastAccColor); - } else if (darkThemeLastAccColor !== "" && value === 1) { - updateAccentColor(root.darkThemeLastAccColor); - } else { - updateAccentColor(root.accentColorsModel[0].color); - } } readonly property IntentHandler intentHandler: IntentHandler { diff --git a/sysui/stores/RootStore.qml b/sysui/stores/RootStore.qml index df7ace6e..c4eb549d 100644 --- a/sysui/stores/RootStore.qml +++ b/sysui/stores/RootStore.qml @@ -115,9 +115,6 @@ Store { } readonly property SystemInfo sysInfo: SystemInfo { id: sysInfo } - property var accentColorsModel - property string lighThemeLastAccColor: "#d35756" - property string darkThemeLastAccColor: "#b75034" readonly property UISettings uiSettings: UISettings { onLanguageChanged: { if (language !== Config.languageLocale) { @@ -125,22 +122,18 @@ Store { uiSettings.setRtlMode(Qt.locale(language).textDirection === Qt.RightToLeft) } } - onThemeChanged: root.updateThemeRequested(uiSettings.theme) - onAccentColorChanged: { - root.accentColorChanged(accentColor); - if (startupAccentColor) { - //Prevent setting back light theme's last accent color in cases when the UI - //was closed with light theme set. If this is the case, reset dark theme's - //default accent color. - var accColorInPalette = root.accentColorsModel.find(function(color) { - return (color.color === accentColor); - }); - if (accColorInPalette === undefined) { - uiSettings.accentColor = root.accentColorsModel[0].color; - } - startupAccentColor = false; + onThemeChanged: { + // since different themes have different color pallets we update colors on theme change + if (uiSettings.theme === 0 /*light*/) { + uiSettings.accentColor = (Config._initAccentColors(0))[1].color; + } else { /*dark*/ + uiSettings.accentColor = (Config._initAccentColors(1))[4].color; } + + root.updateThemeRequested(uiSettings.theme); } + + onAccentColorChanged: { root.accentColorChanged(accentColor); } onRtlModeChanged: Config.rtlMode = uiSettings.rtlMode Component.onCompleted: { Qt.callLater(function() { @@ -273,21 +266,10 @@ Store { root.triggerNotificationInfo(tempDirPath); } + //value: 1 -- dark, 0 -- light function updateTheme(value) { - if ((value === 1) && (root.lighThemeLastAccColor !== uiSettings.accentColor)) { - root.lighThemeLastAccColor = uiSettings.accentColor; - } else if ((value === 0) && (root.darkThemeLastAccColor !== uiSettings.accentColor)) { - root.darkThemeLastAccColor = uiSettings.accentColor; - } - uiSettings.setTheme(value); - root.accentColorsModel = Config._initAccentColors(value); - //set previous to theme accentColor - if ((lighThemeLastAccColor !== "") && (value === 0)) { - uiSettings.accentColor = root.lighThemeLastAccColor; - } else if ((darkThemeLastAccColor !== "") && (value === 1)) { - uiSettings.accentColor = root.darkThemeLastAccColor; - } else { - uiSettings.accentColor = root.accentColorsModel[0].color; + if (value !== uiSettings.theme) { + uiSettings.setTheme(value); } } @@ -300,8 +282,4 @@ Store { console.log("Intent request failed: " + request.errorMessage); }) } - - Component.onCompleted: { - root.accentColorsModel = Config._initAccentColors(Style.theme); - } } |