mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-24 06:05:09 +00:00
Updated Vesktop settings to include an option to select a tray icon.
This commit is contained in:
parent
0623a71271
commit
73c6633a31
6 changed files with 37 additions and 6 deletions
|
@ -121,6 +121,20 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
||||||
return dir;
|
return dir;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
handle(IpcEvents.SELECT_TRAY_ICON, async () => {
|
||||||
|
const res = await dialog.showOpenDialog(mainWin!, {
|
||||||
|
properties: ["openFile"],
|
||||||
|
filters: [{name: "Image", extensions: ["png", "jpg"]}]
|
||||||
|
});
|
||||||
|
if (!res.filePaths.length) return "cancelled";
|
||||||
|
|
||||||
|
const dir = res.filePaths[0];
|
||||||
|
const image = nativeImage.createFromPath(dir);
|
||||||
|
if(image.isEmpty()) return "invalid";
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
});
|
||||||
|
|
||||||
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
|
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
|
||||||
|
|
||||||
handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
|
handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
Menu,
|
Menu,
|
||||||
MenuItemConstructorOptions,
|
MenuItemConstructorOptions,
|
||||||
nativeTheme,
|
nativeTheme,
|
||||||
|
nativeImage,
|
||||||
Tray
|
Tray
|
||||||
} from "electron";
|
} from "electron";
|
||||||
import { rm } from "fs/promises";
|
import { rm } from "fs/promises";
|
||||||
|
@ -20,7 +21,7 @@ import { IpcEvents } from "shared/IpcEvents";
|
||||||
import { isTruthy } from "shared/utils/guards";
|
import { isTruthy } from "shared/utils/guards";
|
||||||
import { once } from "shared/utils/once";
|
import { once } from "shared/utils/once";
|
||||||
import type { SettingsStore } from "shared/utils/SettingsStore";
|
import type { SettingsStore } from "shared/utils/SettingsStore";
|
||||||
|
import { existsSync } from "fs";
|
||||||
import { ICON_PATH } from "../shared/paths";
|
import { ICON_PATH } from "../shared/paths";
|
||||||
import { createAboutWindow } from "./about";
|
import { createAboutWindow } from "./about";
|
||||||
import { initArRPC } from "./arrpc";
|
import { initArRPC } from "./arrpc";
|
||||||
|
@ -120,8 +121,15 @@ function initTray(win: BrowserWindow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
if (Settings.store.trayIconPath) {
|
||||||
tray = new Tray(ICON_PATH);
|
const trayImage = nativeImage.createFromPath(Settings.store.trayIconPath);
|
||||||
|
if (!trayImage.isEmpty()) tray = new Tray(trayImage.resize({width: 32, height: 32}));
|
||||||
|
else tray = new Tray(ICON_PATH);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tray = new Tray(ICON_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
tray.setToolTip("Vesktop");
|
tray.setToolTip("Vesktop");
|
||||||
tray.setContextMenu(trayMenu);
|
tray.setContextMenu(trayMenu);
|
||||||
tray.on("click", onTrayClick);
|
tray.on("click", onTrayClick);
|
||||||
|
@ -273,7 +281,7 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions {
|
||||||
options.x = x;
|
options.x = x;
|
||||||
options.y = y;
|
options.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.store.disableMinSize) {
|
if (!Settings.store.disableMinSize) {
|
||||||
options.minWidth = MIN_WIDTH;
|
options.minWidth = MIN_WIDTH;
|
||||||
options.minHeight = MIN_HEIGHT;
|
options.minHeight = MIN_HEIGHT;
|
||||||
|
@ -328,6 +336,10 @@ function initSettingsListeners(win: BrowserWindow) {
|
||||||
if (enable) initTray(win);
|
if (enable) initTray(win);
|
||||||
else tray?.destroy();
|
else tray?.destroy();
|
||||||
});
|
});
|
||||||
|
addSettingsListener("trayIconPath", _ => {
|
||||||
|
tray?.destroy();
|
||||||
|
initTray(win);
|
||||||
|
});
|
||||||
addSettingsListener("disableMinSize", disable => {
|
addSettingsListener("disableMinSize", disable => {
|
||||||
if (disable) {
|
if (disable) {
|
||||||
// 0 no work
|
// 0 no work
|
||||||
|
|
|
@ -33,7 +33,8 @@ export const VesktopNative = {
|
||||||
},
|
},
|
||||||
fileManager: {
|
fileManager: {
|
||||||
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
|
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
|
||||||
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR)
|
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR),
|
||||||
|
selectTrayIcon: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_TRAY_ICON)
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { AutoStartToggle } from "./AutoStartToggle";
|
||||||
import { DiscordBranchPicker } from "./DiscordBranchPicker";
|
import { DiscordBranchPicker } from "./DiscordBranchPicker";
|
||||||
import { NotificationBadgeToggle } from "./NotificationBadgeToggle";
|
import { NotificationBadgeToggle } from "./NotificationBadgeToggle";
|
||||||
import { VencordLocationPicker } from "./VencordLocationPicker";
|
import { VencordLocationPicker } from "./VencordLocationPicker";
|
||||||
|
import { TrayIconImagePicker } from "./TrayIconImagePicker";
|
||||||
import { WindowsTransparencyControls } from "./WindowsTransparencyControls";
|
import { WindowsTransparencyControls } from "./WindowsTransparencyControls";
|
||||||
|
|
||||||
interface BooleanSetting {
|
interface BooleanSetting {
|
||||||
|
@ -126,7 +127,8 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Vencord Location": [VencordLocationPicker]
|
"Tray Icon Image": [TrayIconImagePicker],
|
||||||
|
"Vencord Location": [VencordLocationPicker],
|
||||||
};
|
};
|
||||||
|
|
||||||
function SettingsSections() {
|
function SettingsSections() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ export const enum IpcEvents {
|
||||||
SET_SETTINGS = "VCD_SET_SETTINGS",
|
SET_SETTINGS = "VCD_SET_SETTINGS",
|
||||||
|
|
||||||
SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR",
|
SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR",
|
||||||
|
SELECT_TRAY_ICON = "VCD_SELECT_TRAY_ICON",
|
||||||
|
|
||||||
UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA",
|
UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA",
|
||||||
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
|
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
|
||||||
|
|
1
src/shared/settings.d.ts
vendored
1
src/shared/settings.d.ts
vendored
|
@ -24,6 +24,7 @@ export interface Settings {
|
||||||
/** @deprecated use customTitleBar */
|
/** @deprecated use customTitleBar */
|
||||||
discordWindowsTitleBar?: boolean;
|
discordWindowsTitleBar?: boolean;
|
||||||
customTitleBar?: boolean;
|
customTitleBar?: boolean;
|
||||||
|
trayIconPath?: string
|
||||||
|
|
||||||
checkUpdates?: boolean;
|
checkUpdates?: boolean;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue