Add Setting & fix other issues

This commit is contained in:
V 2023-08-07 00:20:59 +02:00
parent d8662763a2
commit 462fc4e6ff
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
5 changed files with 53 additions and 31 deletions

View file

@ -315,8 +315,11 @@ function createMainWindow() {
removeSettingsListeners(); removeSettingsListeners();
removeVencordSettingsListeners(); removeVencordSettingsListeners();
const { staticTitle, transparencyOption, enableMenu } = Settings.store; const { staticTitle, transparencyOption, enableMenu, discordWindowsTitleBar } = Settings.store;
const { frameless, macosTranslucency } = VencordSettings.store; const { frameless, macosTranslucency } = VencordSettings.store;
const noFrame = frameless === true || (process.platform === "win32" && discordWindowsTitleBar === true);
const win = (mainWin = new BrowserWindow({ const win = (mainWin = new BrowserWindow({
show: false, show: false,
webPreferences: { webPreferences: {
@ -328,7 +331,7 @@ function createMainWindow() {
spellcheck: true spellcheck: true
}, },
icon: ICON_PATH, icon: ICON_PATH,
frame: frameless !== true, frame: !noFrame,
...(transparencyOption && transparencyOption !== "none" ...(transparencyOption && transparencyOption !== "none"
? { ? {
backgroundColor: "#00000000", backgroundColor: "#00000000",

View file

@ -10,7 +10,7 @@ import { Margins } from "@vencord/types/utils";
import { Button, Forms, Select, Switch, Text, useState } from "@vencord/types/webpack/common"; import { Button, Forms, Select, Switch, Text, useState } from "@vencord/types/webpack/common";
import { setBadge } from "renderer/appBadge"; import { setBadge } from "renderer/appBadge";
import { useSettings } from "renderer/settings"; import { useSettings } from "renderer/settings";
import { isMac } from "renderer/utils"; import { isMac, isWindows } from "renderer/utils";
import { isTruthy } from "shared/utils/guards"; import { isTruthy } from "shared/utils/guards";
export default function SettingsUi() { export default function SettingsUi() {
@ -21,6 +21,11 @@ export default function SettingsUi() {
const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled()); const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());
const allSwitches: Array<false | [keyof typeof Settings, string, string, boolean?, (() => boolean)?]> = [ const allSwitches: Array<false | [keyof typeof Settings, string, string, boolean?, (() => boolean)?]> = [
isWindows && [
"discordWindowsTitleBar",
"Discord Titlebar",
"Use Discord's custom title bar instead of the Windows one. Requires a full restart."
],
!isMac && ["tray", "Tray Icon", "Add a tray icon for Vesktop", true], !isMac && ["tray", "Tray Icon", "Add a tray icon for Vesktop", true],
!isMac && [ !isMac && [
"minimizeToTray", "minimizeToTray",
@ -35,13 +40,13 @@ export default function SettingsUi() {
"Disable minimum window size", "Disable minimum window size",
"Allows you to make the window as small as your heart desires" "Allows you to make the window as small as your heart desires"
], ],
["staticTitle", "Static Title", 'Makes the window title "Vesktop" instead of changing to the current page'],
["enableMenu", "Enable Menu Bar", "Enables the application menu bar. Press ALT to toggle visibility."],
[ [
"openLinksWithElectron", "openLinksWithElectron",
"Open Links in app (experimental)", "Open Links in app (experimental)",
"Opens links in a new Vesktop window instead of your web browser" "Opens links in a new Vesktop window instead of your web browser"
], ]
["staticTitle", "Static Title", 'Makes the window title "Vesktop" instead of changing to the current page'],
["enableMenu", "Enable Menu Bar", "Enables the application menu bar. Press ALT to toggle visibility."]
]; ];
const switches = allSwitches.filter(isTruthy); const switches = allSwitches.filter(isTruthy);

View file

@ -4,6 +4,9 @@
* Copyright (c) 2023 Vendicated and Vencord contributors * Copyright (c) 2023 Vendicated and Vencord contributors
*/ */
import { Settings } from "renderer/settings";
import { isMac, isWindows } from "renderer/utils";
import { addPatch } from "./shared"; import { addPatch } from "./shared";
addPatch({ addPatch({
@ -18,5 +21,9 @@ addPatch({
} }
], ],
getPlatformClass: () => (navigator.platform.toLowerCase().startsWith("mac") ? "platform-osx" : "platform-web") getPlatformClass() {
if (isMac) return "platform-osx";
if (isWindows && Settings.store.discordWindowsTitleBar) return "platform-windows";
return "platform-web";
}
}); });

View file

@ -4,18 +4,23 @@
* Copyright (c) 2023 Vendicated and Vencord contributors * Copyright (c) 2023 Vendicated and Vencord contributors
*/ */
import { Settings } from "renderer/settings";
import { addPatch } from "./shared"; import { addPatch } from "./shared";
if (Settings.store.discordWindowsTitleBar)
addPatch({ addPatch({
patches: [ patches: [
{ {
find: ".wordmarkWindows", find: ".wordmarkWindows",
replacement: [ replacement: [
{ {
// TODO: Fix eslint rule
// eslint-disable-next-line no-useless-escape
match: /case \i\.\i\.WINDOWS:/, match: /case \i\.\i\.WINDOWS:/,
replace: 'case "WEB":' replace: 'case "WEB":'
}, },
...["close", "minimize", "fullscreen", "maximize"].map(op => ({ ...["close", "minimize", "maximize"].map(op => ({
match: new RegExp(String.raw`\i\.default\.${op}\b`), match: new RegExp(String.raw`\i\.default\.${op}\b`),
replace: `VesktopNative.win.${op}` replace: `VesktopNative.win.${op}`
})) }))

View file

@ -7,21 +7,23 @@
import type { Rectangle } from "electron"; import type { Rectangle } from "electron";
export interface Settings { export interface Settings {
transparencyOption?: "none" | "mica" | "tabbed" | "acrylic";
maximized?: boolean;
minimized?: boolean;
windowBounds?: Rectangle;
discordBranch?: "stable" | "canary" | "ptb"; discordBranch?: "stable" | "canary" | "ptb";
openLinksWithElectron?: boolean;
vencordDir?: string; vencordDir?: string;
disableMinSize?: boolean; transparencyOption?: "none" | "mica" | "tabbed" | "acrylic";
tray?: boolean; tray?: boolean;
minimizeToTray?: boolean; minimizeToTray?: boolean;
skippedUpdate?: string; openLinksWithElectron?: boolean;
staticTitle?: boolean; staticTitle?: boolean;
enableMenu?: boolean; enableMenu?: boolean;
arRPC?: boolean; arRPC?: boolean;
appBadge?: boolean; appBadge?: boolean;
discordWindowsTitleBar?: boolean;
maximized?: boolean;
minimized?: boolean;
windowBounds?: Rectangle;
disableMinSize?: boolean;
skippedUpdate?: string;
firstLaunch?: boolean; firstLaunch?: boolean;
} }