[desktop] event on show 'quick print' button

This commit is contained in:
Maxim Kadushkin 2022-11-22 00:28:55 +03:00
parent 4fa78dad3a
commit 8e25f9c027

View file

@ -45,7 +45,8 @@ define([
version: '{{PRODUCT_VERSION}}', version: '{{PRODUCT_VERSION}}',
eventloading: true, eventloading: true,
titlebuttons: true, titlebuttons: true,
uithemes: true uithemes: true,
quickprint: true,
}; };
var native = window.desktop || window.AscDesktopEditor; var native = window.desktop || window.AscDesktopEditor;
@ -166,7 +167,8 @@ define([
action: action, action: action,
icon: config.icon || undefined, icon: config.icon || undefined,
hint: config.btn.options.hint, hint: config.btn.options.hint,
disabled: config.btn.isDisabled() disabled: config.btn.isDisabled(),
visible: config.visible,
}; };
}; };
@ -217,6 +219,19 @@ define([
} }
} }
const _onApplySettings = function (menu) {
if ( !!titlebuttons.printquick ) {
if ( titlebuttons.printquick.visible != titlebuttons.printquick.btn.isVisible() ) {
const obj = {
visible: {
quickprint: titlebuttons.printquick.btn.isVisible(),
}
};
native.execCommand('title:button', JSON.stringify(obj));
}
}
}
return { return {
init: function (opts) { init: function (opts) {
_.extend(config, opts); _.extend(config, opts);
@ -283,8 +298,12 @@ define([
if (!!header.btnPrint) if (!!header.btnPrint)
titlebuttons['print'] = {btn: header.btnPrint}; titlebuttons['print'] = {btn: header.btnPrint};
if (!!header.btnPrintQuick) if (!!header.btnPrintQuick) {
titlebuttons['printquick'] = {btn: header.btnPrintQuick}; titlebuttons['printquick'] = {
btn: header.btnPrintQuick,
visible: header.btnPrintQuick.isVisible(),
};
}
if (!!header.btnUndo) if (!!header.btnUndo)
titlebuttons['undo'] = {btn: header.btnUndo}; titlebuttons['undo'] = {btn: header.btnUndo};
@ -340,6 +359,7 @@ define([
menu.hide(); menu.hide();
} }
}, },
'settings:apply': _onApplySettings.bind(this),
}, },
}, {id: 'desktop'}); }, {id: 'desktop'});