Port Discord's windows title bar (#86)
This commit is contained in:
@@ -10,7 +10,7 @@ import { Margins } from "@vencord/types/utils";
|
||||
import { Button, Forms, Select, Switch, Text, useState } from "@vencord/types/webpack/common";
|
||||
import { setBadge } from "renderer/appBadge";
|
||||
import { useSettings } from "renderer/settings";
|
||||
import { isMac } from "renderer/utils";
|
||||
import { isMac, isWindows } from "renderer/utils";
|
||||
import { isTruthy } from "shared/utils/guards";
|
||||
|
||||
export default function SettingsUi() {
|
||||
@@ -21,6 +21,11 @@ export default function SettingsUi() {
|
||||
const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled());
|
||||
|
||||
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 && [
|
||||
"minimizeToTray",
|
||||
@@ -35,13 +40,13 @@ export default function SettingsUi() {
|
||||
"Disable minimum window size",
|
||||
"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",
|
||||
"Open Links in app (experimental)",
|
||||
"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);
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
// TODO: Possibly auto generate glob if we have more patches in the future
|
||||
import "./spellCheck";
|
||||
import "./platformClass";
|
||||
import "./windowsTitleBar";
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import { Settings } from "renderer/settings";
|
||||
import { isMac, isWindows } from "renderer/utils";
|
||||
|
||||
import { addPatch } from "./shared";
|
||||
|
||||
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";
|
||||
}
|
||||
});
|
||||
|
||||
30
src/renderer/patches/windowsTitleBar.tsx
Normal file
30
src/renderer/patches/windowsTitleBar.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-3.0
|
||||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import { Settings } from "renderer/settings";
|
||||
|
||||
import { addPatch } from "./shared";
|
||||
|
||||
if (Settings.store.discordWindowsTitleBar)
|
||||
addPatch({
|
||||
patches: [
|
||||
{
|
||||
find: ".wordmarkWindows",
|
||||
replacement: [
|
||||
{
|
||||
// TODO: Fix eslint rule
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
match: /case \i\.\i\.WINDOWS:/,
|
||||
replace: 'case "WEB":'
|
||||
},
|
||||
...["close", "minimize", "maximize"].map(op => ({
|
||||
match: new RegExp(String.raw`\i\.default\.${op}\b`),
|
||||
replace: `VesktopNative.win.${op}`
|
||||
}))
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user