[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,20 +157,28 @@ define([
});
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
toggleGroup: 'interface-theme'
});
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()) {
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
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,20 +177,27 @@ define([
});
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
toggleGroup: 'interface-theme'
});
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()) {
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
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,18 +401,27 @@ define([
}
}
if (Common.UI.Themes.available()) {
var menuItems = [],
currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId();
for (var t in Common.UI.Themes.map()) {
menuItems.push({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
toggleGroup: 'interface-theme'
});
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()) {
btn.menu.addItem({
value: t,
caption: Common.UI.Themes.get(t).text,
checked: t === currentTheme,
checkable: true,
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;