[themes] fix for View tab

This commit is contained in:
Maxim Kadushkin 2022-06-03 22:03:29 +03:00
parent 66dc610faf
commit 730ea07cc6
3 changed files with 59 additions and 35 deletions

View file

@ -157,10 +157,14 @@ define([
});
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
function _fill_themes() {
var btn = this.view.btnInterfaceTheme;
if ( typeof(btn.menu) == 'object' ) btn.menu.removeAll();
else btn.setMenu(new Common.UI.Menu());
var currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
@ -168,9 +172,13 @@ define([
toggleGroup: 'interface-theme'
});
}
}
if (menuItems.length) {
me.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems}));
Common.NotificationCenter.on('uitheme:countchanged', _fill_themes.bind(me));
_fill_themes.call(me);
if (me.view.btnInterfaceTheme.menu.items.length) {
// me.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems}));
me.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) {
var value = item.value;
Common.UI.Themes.setTheme(value);

View file

@ -177,10 +177,14 @@ define([
});
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
function _fill_themes() {
var btn = this.view.btnInterfaceTheme;
if ( typeof(btn.menu) == 'object' ) btn.menu.removeAll();
else btn.setMenu(new Common.UI.Menu());
var currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
@ -188,9 +192,12 @@ define([
toggleGroup: 'interface-theme'
});
}
}
if (menuItems.length) {
this.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems}));
Common.NotificationCenter.on('uitheme:countchanged', _fill_themes.bind(me));
_fill_themes.call(me);
if (me.view.btnInterfaceTheme.menu.items.length) {
this.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) {
var value = item.value;
Common.UI.Themes.setTheme(value);

View file

@ -401,10 +401,14 @@ define([
}
}
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
function _fill_themes() {
var btn = this.btnInterfaceTheme;
if ( typeof(btn.menu) == 'object' ) btn.menu.removeAll();
else btn.setMenu(new Common.UI.Menu());
var currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
@ -412,7 +416,12 @@ define([
toggleGroup: 'interface-theme'
});
}
if (menuItems.length) {
}
Common.NotificationCenter.on('uitheme:countchanged', _fill_themes.bind(me));
_fill_themes.call(me);
if (me.view.btnInterfaceTheme.menu.items.length) {
me.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems}));
me.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) {
var value = item.value;