Add left click hide/show feature

This commit adds the option to click on the tray to hide or show the
window, it is optional and is disabled by default.
This commit is contained in:
Diego Parra 2024-02-23 01:20:57 +01:00
parent 612d35c96f
commit f4f268a7ef
3 changed files with 15 additions and 2 deletions

View file

@ -73,6 +73,13 @@ const [addSettingsListener, removeSettingsListeners] = makeSettingsListenerHelpe
const [addVencordSettingsListener, removeVencordSettingsListeners] = makeSettingsListenerHelpers(VencordSettings);
function initTray(win: BrowserWindow) {
const trayClickHandler = Settings.store.clickTrayToShowHide
? () => {
win.isVisible() ? win.hide() : win.show();
}
: () => {
win.show();
};
const trayMenu = Menu.buildFromTemplate([
{
label: "Open",
@ -120,7 +127,7 @@ function initTray(win: BrowserWindow) {
tray = new Tray(ICON_PATH);
tray.setToolTip("Vesktop");
tray.setContextMenu(trayMenu);
tray.on("click", () => win.show());
tray.on("click", trayClickHandler);
}
async function clearData(win: BrowserWindow) {

View file

@ -83,6 +83,12 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
invisible: () => isMac,
disabled: () => Settings.store.tray === false
},
{
key: "clickTrayToShowHide",
title: "Hide/Show on tray left click",
description: "Left clicking on tray will hide or show the vesktop window. Requires a full restart.",
defaultValue: false
},
{
key: "disableMinSize",
title: "Disable minimum window size",

View file

@ -20,7 +20,7 @@ export interface Settings {
arRPC?: boolean;
appBadge?: boolean;
disableMinSize?: boolean;
clickTrayToShowHide?: boolean;
/** @deprecated use customTitleBar */
discordWindowsTitleBar?: boolean;
customTitleBar?: boolean;