From ca5564fcc5bf3443986331615965f50bacaac2a5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 May 2024 23:20:07 +0300 Subject: [PATCH 1/4] Fix bug 68174 --- apps/documenteditor/main/app/controller/ViewTab.js | 9 ++++++++- apps/pdfeditor/main/app/controller/ViewTab.js | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 623eae7f55..692d9c6923 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -298,7 +298,14 @@ define([ }, onChangeDarkMode: function () { - Common.UI.Themes.toggleContentTheme(); + if (!this._darkModeTimer) { + var me = this; + me._darkModeTimer = setTimeout(function() { + me._darkModeTimer = undefined; + }, 500); + Common.UI.Themes.toggleContentTheme(); + } else + this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); }, onContentThemeChangedToDark: function (isdark) { diff --git a/apps/pdfeditor/main/app/controller/ViewTab.js b/apps/pdfeditor/main/app/controller/ViewTab.js index 7b80efabcc..f278df9e57 100644 --- a/apps/pdfeditor/main/app/controller/ViewTab.js +++ b/apps/pdfeditor/main/app/controller/ViewTab.js @@ -283,7 +283,14 @@ define([ }, onChangeDarkMode: function () { - Common.UI.Themes.toggleContentTheme(); + if (!this._darkModeTimer) { + var me = this; + me._darkModeTimer = setTimeout(function() { + me._darkModeTimer = undefined; + }, 500); + Common.UI.Themes.toggleContentTheme(); + } else + this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); }, onContentThemeChangedToDark: function (isdark) { From 08dbdcfc4f2e0a2bfd4fa016e47b8ec0ee40ad0c Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 24 May 2024 14:06:48 +0300 Subject: [PATCH 2/4] [DE] debug --- apps/common/main/lib/controller/Themes.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index ebcdf57d44..f580f1fdef 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -482,10 +482,11 @@ define([ setContentTheme: function (mode, force) { var set_dark = mode == 'dark'; if ( set_dark != window.uitheme.iscontentdark || force ) { + window.uitheme.iscontentdark = set_dark; + if ( this.isDarkTheme() ) this.api.asc_setContentDarkMode(set_dark); - window.uitheme.iscontentdark = mode; if ( Common.localStorage.getItem('content-theme') != mode ) Common.localStorage.setItem('content-theme', mode); From 54bbb7b81683039932a0abaf5f8078cf44de42f3 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 24 May 2024 15:26:41 +0300 Subject: [PATCH 3/4] [DE] add argument to prevent 'mode' to keep in local storage --- apps/common/main/lib/controller/Themes.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index f580f1fdef..0f77e71c5c 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -408,7 +408,7 @@ define([ } } else if ( e.key == 'content-theme' ) { - this.setContentTheme(e.originalEvent.newValue, true); + this.setContentTheme(e.originalEvent.newValue, true, false); } }.bind(this)) @@ -479,7 +479,7 @@ define([ return window.uitheme.iscontentdark; }, - setContentTheme: function (mode, force) { + setContentTheme: function (mode, force, keep) { var set_dark = mode == 'dark'; if ( set_dark != window.uitheme.iscontentdark || force ) { window.uitheme.iscontentdark = set_dark; @@ -487,7 +487,7 @@ define([ if ( this.isDarkTheme() ) this.api.asc_setContentDarkMode(set_dark); - if ( Common.localStorage.getItem('content-theme') != mode ) + if ( !(keep === false) && Common.localStorage.getItem('content-theme') != mode ) Common.localStorage.setItem('content-theme', mode); Common.NotificationCenter.trigger('contenttheme:dark', set_dark); From c15ddca95fb53e3cf0200a9d254726065f95d303 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 24 May 2024 16:19:31 +0300 Subject: [PATCH 4/4] [DE PDFE] correct changing of document mode --- apps/documenteditor/main/app/controller/ViewTab.js | 4 ++-- apps/documenteditor/main/app/view/ViewTab.js | 4 ++-- apps/pdfeditor/main/app/controller/ViewTab.js | 4 ++-- apps/pdfeditor/main/app/view/ViewTab.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 692d9c6923..2a0a7472f3 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -297,13 +297,13 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, - onChangeDarkMode: function () { + onChangeDarkMode: function (isdarkmode) { if (!this._darkModeTimer) { var me = this; me._darkModeTimer = setTimeout(function() { me._darkModeTimer = undefined; }, 500); - Common.UI.Themes.toggleContentTheme(); + Common.UI.Themes.setContentTheme(isdarkmode?'dark':'light'); } else this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); }, diff --git a/apps/documenteditor/main/app/view/ViewTab.js b/apps/documenteditor/main/app/view/ViewTab.js index 841bc6008f..d142f7ec34 100644 --- a/apps/documenteditor/main/app/view/ViewTab.js +++ b/apps/documenteditor/main/app/view/ViewTab.js @@ -131,8 +131,8 @@ define([ me.chRightMenu.on('change', _.bind(function (checkbox, state) { me.fireEvent('rightmenu:hide', [me.chRightMenu, state === 'checked']); }, me)); - me.btnDarkDocument.on('click', _.bind(function () { - me.fireEvent('darkmode:change'); + me.btnDarkDocument.on('click', _.bind(function (e) { + me.fireEvent('darkmode:change', [e.pressed]); }, me)); me.cmbsZoom.forEach(function (cmb) { cmb.on('combo:focusin', _.bind(me.onComboOpen, this, false)); diff --git a/apps/pdfeditor/main/app/controller/ViewTab.js b/apps/pdfeditor/main/app/controller/ViewTab.js index f278df9e57..552a99cdb5 100644 --- a/apps/pdfeditor/main/app/controller/ViewTab.js +++ b/apps/pdfeditor/main/app/controller/ViewTab.js @@ -282,13 +282,13 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.view); }, - onChangeDarkMode: function () { + onChangeDarkMode: function (isdarkmode) { if (!this._darkModeTimer) { var me = this; me._darkModeTimer = setTimeout(function() { me._darkModeTimer = undefined; }, 500); - Common.UI.Themes.toggleContentTheme(); + Common.UI.Themes.setContentTheme(isdarkmode?'dark':'light'); } else this.onContentThemeChangedToDark(Common.UI.Themes.isContentThemeDark()); }, diff --git a/apps/pdfeditor/main/app/view/ViewTab.js b/apps/pdfeditor/main/app/view/ViewTab.js index ca4de10152..456eb159d8 100644 --- a/apps/pdfeditor/main/app/view/ViewTab.js +++ b/apps/pdfeditor/main/app/view/ViewTab.js @@ -119,8 +119,8 @@ define([ me.chLeftMenu.on('change', _.bind(function (checkbox, state) { me.fireEvent('leftmenu:hide', [me.chLeftMenu, state === 'checked']); }, me)); - me.btnDarkDocument.on('click', _.bind(function () { - me.fireEvent('darkmode:change'); + me.btnDarkDocument.on('click', _.bind(function (e) { + me.fireEvent('darkmode:change', [e.pressed]); }, me)); me.cmbsZoom.forEach(function (cmb) { cmb.on('combo:focusin', _.bind(me.onComboOpen, this, false));