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;
|
||||
});
|
||||
|
||||
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.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
Menu,
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
nativeImage,
|
||||
Tray
|
||||
} from "electron";
|
||||
import { rm } from "fs/promises";
|
||||
|
@ -20,7 +21,7 @@ import { IpcEvents } from "shared/IpcEvents";
|
|||
import { isTruthy } from "shared/utils/guards";
|
||||
import { once } from "shared/utils/once";
|
||||
import type { SettingsStore } from "shared/utils/SettingsStore";
|
||||
|
||||
import { existsSync } from "fs";
|
||||
import { ICON_PATH } from "../shared/paths";
|
||||
import { createAboutWindow } from "./about";
|
||||
import { initArRPC } from "./arrpc";
|
||||
|
@ -120,8 +121,15 @@ function initTray(win: BrowserWindow) {
|
|||
}
|
||||
}
|
||||
]);
|
||||
|
||||
if (Settings.store.trayIconPath) {
|
||||
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.setContextMenu(trayMenu);
|
||||
tray.on("click", onTrayClick);
|
||||
|
@ -328,6 +336,10 @@ function initSettingsListeners(win: BrowserWindow) {
|
|||
if (enable) initTray(win);
|
||||
else tray?.destroy();
|
||||
});
|
||||
addSettingsListener("trayIconPath", _ => {
|
||||
tray?.destroy();
|
||||
initTray(win);
|
||||
});
|
||||
addSettingsListener("disableMinSize", disable => {
|
||||
if (disable) {
|
||||
// 0 no work
|
||||
|
|
|
@ -33,7 +33,8 @@ export const VesktopNative = {
|
|||
},
|
||||
fileManager: {
|
||||
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: {
|
||||
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
||||
|
|
|
@ -15,6 +15,7 @@ import { AutoStartToggle } from "./AutoStartToggle";
|
|||
import { DiscordBranchPicker } from "./DiscordBranchPicker";
|
||||
import { NotificationBadgeToggle } from "./NotificationBadgeToggle";
|
||||
import { VencordLocationPicker } from "./VencordLocationPicker";
|
||||
import { TrayIconImagePicker } from "./TrayIconImagePicker";
|
||||
import { WindowsTransparencyControls } from "./WindowsTransparencyControls";
|
||||
|
||||
interface BooleanSetting {
|
||||
|
@ -126,7 +127,8 @@ const SettingsOptions: Record<string, Array<BooleanSetting | SettingsComponent>>
|
|||
defaultValue: false
|
||||
}
|
||||
],
|
||||
"Vencord Location": [VencordLocationPicker]
|
||||
"Tray Icon Image": [TrayIconImagePicker],
|
||||
"Vencord Location": [VencordLocationPicker],
|
||||
};
|
||||
|
||||
function SettingsSections() {
|
||||
|
|
|
@ -24,6 +24,7 @@ export const enum IpcEvents {
|
|||
SET_SETTINGS = "VCD_SET_SETTINGS",
|
||||
|
||||
SELECT_VENCORD_DIR = "VCD_SELECT_VENCORD_DIR",
|
||||
SELECT_TRAY_ICON = "VCD_SELECT_TRAY_ICON",
|
||||
|
||||
UPDATER_GET_DATA = "VCD_UPDATER_GET_DATA",
|
||||
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 */
|
||||
discordWindowsTitleBar?: boolean;
|
||||
customTitleBar?: boolean;
|
||||
trayIconPath?: string
|
||||
|
||||
checkUpdates?: boolean;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue