From e9c2445afeebaf36141c72e109d1df1af84d85cd Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 9 Aug 2022 18:26:01 +0300 Subject: [PATCH] [desktop] fix system theme applying --- apps/common/main/lib/controller/Desktop.js | 10 +++++++--- apps/common/main/lib/controller/Themes.js | 4 +++- apps/common/main/lib/util/htmlutils.js | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index 4f42f14ddd..5869dd68be 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -291,9 +291,13 @@ define([ 'modal:show': _onModalDialog.bind(this, 'open'), 'modal:close': _onModalDialog.bind(this, 'close'), 'uitheme:changed' : function (name) { - var theme = Common.UI.Themes.get(name); - if ( theme ) - native.execCommand("uitheme:changed", JSON.stringify({name:name, type:theme.type})); + if (Common.localStorage.getBool('ui-theme-use-system', false)) { + native.execCommand("system:changed", JSON.stringify({'colorscheme':name})); + } else { + var theme = Common.UI.Themes.get(name); + if ( theme ) + native.execCommand("uitheme:changed", JSON.stringify({name:name, type:theme.type})); + } }, 'hints:show': _onHintsShow.bind(this), }); diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index 86e1d4ec5b..62efa4b511 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -302,7 +302,9 @@ define([ $(window).on('storage', function (e) { if ( e.key == 'ui-theme' || e.key == 'ui-theme-id' ) { if ( !!e.originalEvent.newValue ) { - me.setTheme(e.originalEvent.newValue, true); + if (Common.localStorage.getBool('ui-theme-use-system', false)) { + me.setTheme('theme-system'); + } else me.setTheme(e.originalEvent.newValue, true); } } else if ( e.key == 'content-theme' ) { diff --git a/apps/common/main/lib/util/htmlutils.js b/apps/common/main/lib/util/htmlutils.js index 037922ab02..e2c1329ed1 100644 --- a/apps/common/main/lib/util/htmlutils.js +++ b/apps/common/main/lib/util/htmlutils.js @@ -65,6 +65,7 @@ if ( window.desktop ) { if ( theme.id == 'theme-system' ) { localStorage.setItem("ui-theme-use-system", "1"); localStorage.removeItem("ui-theme-id"); + delete params.uitheme; } else { localStorage.setItem("ui-theme-id", theme.id); }