feat(global_menu): indicate state of zen mode

This commit is contained in:
Elian Doran 2025-02-14 14:14:13 +02:00
parent f93eef28f3
commit 5b5fd77ca8
No known key found for this signature in database

View File

@ -133,7 +133,7 @@ const TPL = `
${t("title_bar_buttons.window-on-top")} ${t("title_bar_buttons.window-on-top")}
</li> </li>
<li class="dropdown-item toggle-zen"> <li class="dropdown-item" data-trigger-command="toggleZenMode">
<span class="bx bxs-yin-yang"></span> <span class="bx bxs-yin-yang"></span>
${t("global_menu.toggle-zen-mode")} ${t("global_menu.toggle-zen-mode")}
</li> </li>
@ -256,6 +256,7 @@ export default class GlobalMenuWidget extends BasicWidget {
private $updateToLatestVersionButton!: JQuery<HTMLElement>; private $updateToLatestVersionButton!: JQuery<HTMLElement>;
private $zoomState!: JQuery<HTMLElement>; private $zoomState!: JQuery<HTMLElement>;
private $toggleZenMode!: JQuery<HTMLElement>;
constructor(isHorizontalLayout: boolean) { constructor(isHorizontalLayout: boolean) {
super(); super();
@ -363,13 +364,8 @@ export default class GlobalMenuWidget extends BasicWidget {
} }
this.$zoomState = this.$widget.find(".zoom-state"); this.$zoomState = this.$widget.find(".zoom-state");
this.$widget.on("show.bs.dropdown", () => { this.$toggleZenMode = this.$widget.find('[data-trigger-command="toggleZenMode"');
this.updateZoomState(); this.$widget.on("show.bs.dropdown", () => this.#onShown());
if (this.tooltip) {
this.tooltip.hide();
this.tooltip.disable();
}
});
if (this.tooltip) { if (this.tooltip) {
this.$widget.on("hide.bs.dropdown", () => this.tooltip.enable()); this.$widget.on("hide.bs.dropdown", () => this.tooltip.enable());
} }
@ -385,6 +381,15 @@ export default class GlobalMenuWidget extends BasicWidget {
setInterval(() => this.updateVersionStatus(), 8 * 60 * 60 * 1000); setInterval(() => this.updateVersionStatus(), 8 * 60 * 60 * 1000);
} }
#onShown() {
this.$toggleZenMode.toggleClass("active", $("body").hasClass("zen"));
this.updateZoomState();
if (this.tooltip) {
this.tooltip.hide();
this.tooltip.disable();
}
}
updateZoomState() { updateZoomState() {
if (!utils.isElectron()) { if (!utils.isElectron()) {
return; return;