parent
d1acb0490b
commit
de3aae1d95
3 changed files with 23 additions and 7 deletions
|
@ -15,6 +15,7 @@ import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally";
|
||||||
import { downloadVencordFiles } from "./utils/vencordLoader";
|
import { downloadVencordFiles } from "./utils/vencordLoader";
|
||||||
|
|
||||||
let isQuitting = false;
|
let isQuitting = false;
|
||||||
|
let tray: Tray;
|
||||||
|
|
||||||
app.on("before-quit", () => {
|
app.on("before-quit", () => {
|
||||||
isQuitting = true;
|
isQuitting = true;
|
||||||
|
@ -62,7 +63,7 @@ function initTray(win: BrowserWindow) {
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const tray = new Tray(ICON_PATH);
|
tray = new Tray(ICON_PATH);
|
||||||
tray.setToolTip("Vencord Desktop");
|
tray.setToolTip("Vencord Desktop");
|
||||||
tray.setContextMenu(trayMenu);
|
tray.setContextMenu(trayMenu);
|
||||||
tray.on("click", () => win.show());
|
tray.on("click", () => win.show());
|
||||||
|
@ -213,6 +214,12 @@ function initWindowBoundsListeners(win: BrowserWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initSettingsListeners(win: BrowserWindow) {
|
function initSettingsListeners(win: BrowserWindow) {
|
||||||
|
Settings.addChangeListener("tray", enable => {
|
||||||
|
if (enable)
|
||||||
|
initTray(win);
|
||||||
|
else
|
||||||
|
tray?.destroy();
|
||||||
|
});
|
||||||
Settings.addChangeListener("disableMinSize", disable => {
|
Settings.addChangeListener("disableMinSize", disable => {
|
||||||
if (disable) {
|
if (disable) {
|
||||||
// 0 no work
|
// 0 no work
|
||||||
|
@ -246,7 +253,7 @@ export function createMainWindow() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
win.on("close", e => {
|
win.on("close", e => {
|
||||||
if (isQuitting || Settings.store.minimizeToTray === false) return;
|
if (isQuitting || Settings.store.minimizeToTray === false || Settings.store.tray === false) return;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
win.hide();
|
win.hide();
|
||||||
|
@ -255,7 +262,7 @@ export function createMainWindow() {
|
||||||
});
|
});
|
||||||
|
|
||||||
initWindowBoundsListeners(win);
|
initWindowBoundsListeners(win);
|
||||||
initTray(win);
|
if (Settings.store.tray ?? true) initTray(win);
|
||||||
initMenuBar(win);
|
initMenuBar(win);
|
||||||
makeLinksOpenExternally(win);
|
makeLinksOpenExternally(win);
|
||||||
initSettingsListeners(win);
|
initSettingsListeners(win);
|
||||||
|
|
|
@ -21,12 +21,19 @@ export default function SettingsUi() {
|
||||||
Button
|
Button
|
||||||
} = Common;
|
} = Common;
|
||||||
|
|
||||||
const switches: [keyof typeof Settings, string, string, boolean?][] = [
|
const switches: [keyof typeof Settings, string, string, boolean?, (() => boolean)?][] = [
|
||||||
|
[
|
||||||
|
"tray",
|
||||||
|
"Tray Icon",
|
||||||
|
"Add a tray icon for Vencord Desktop",
|
||||||
|
true
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"minimizeToTray",
|
"minimizeToTray",
|
||||||
"Minimize to tray",
|
"Minimize to tray",
|
||||||
"Hitting X will make Vencord Desktop minimize to the tray instead of closing",
|
"Hitting X will make Vencord Desktop minimize to the tray instead of closing",
|
||||||
true
|
true,
|
||||||
|
() => Settings["tray"] ?? true
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"disableMinSize",
|
"disableMinSize",
|
||||||
|
@ -62,9 +69,10 @@ export default function SettingsUi() {
|
||||||
|
|
||||||
<FormDivider className={Margins.top16 + " " + Margins.bottom16} />
|
<FormDivider className={Margins.top16 + " " + Margins.bottom16} />
|
||||||
|
|
||||||
{switches.map(([key, text, note, def]) => (
|
{switches.map(([key, text, note, def, predicate]) => (
|
||||||
<FormSwitch
|
<FormSwitch
|
||||||
value={Settings[key] ?? def ?? false}
|
value={(Settings[key] ?? def ?? false) && (!predicate || predicate())}
|
||||||
|
disabled={predicate && !predicate()}
|
||||||
onChange={v => (Settings[key] = v)}
|
onChange={v => (Settings[key] = v)}
|
||||||
note={note}
|
note={note}
|
||||||
key={key}
|
key={key}
|
||||||
|
|
1
src/shared/settings.d.ts
vendored
1
src/shared/settings.d.ts
vendored
|
@ -14,5 +14,6 @@ export interface Settings {
|
||||||
openLinksWithElectron?: boolean;
|
openLinksWithElectron?: boolean;
|
||||||
vencordDir?: string;
|
vencordDir?: string;
|
||||||
disableMinSize?: boolean;
|
disableMinSize?: boolean;
|
||||||
|
tray?: boolean;
|
||||||
minimizeToTray?: boolean;
|
minimizeToTray?: boolean;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue