From 612d35c96f98deb8224ed590f61652de08141746 Mon Sep 17 00:00:00 2001 From: Justin Chung <20733699+justin13888@users.noreply.github.com> Date: Sun, 18 Feb 2024 07:49:42 -0800 Subject: [PATCH] Add categories to Vesktop settings to reduce visual clutter (#379) Co-authored-by: Vendicated --- src/renderer/components/Settings.tsx | 205 ------------------ src/renderer/components/index.ts | 1 - .../components/settings/AutoStartToggle.tsx | 26 +++ .../settings/DiscordBranchPicker.tsx | 26 +++ .../settings/NotificationBadgeToggle.tsx | 26 +++ src/renderer/components/settings/Settings.tsx | 170 +++++++++++++++ .../settings/VencordLocationPicker.tsx | 62 ++++++ .../settings/WindowsTransparencyControls.tsx | 49 +++++ .../components/{ => settings}/settings.css | 8 + src/renderer/index.ts | 2 +- 10 files changed, 368 insertions(+), 207 deletions(-) delete mode 100644 src/renderer/components/Settings.tsx create mode 100644 src/renderer/components/settings/AutoStartToggle.tsx create mode 100644 src/renderer/components/settings/DiscordBranchPicker.tsx create mode 100644 src/renderer/components/settings/NotificationBadgeToggle.tsx create mode 100644 src/renderer/components/settings/Settings.tsx create mode 100644 src/renderer/components/settings/VencordLocationPicker.tsx create mode 100644 src/renderer/components/settings/WindowsTransparencyControls.tsx rename src/renderer/components/{ => settings}/settings.css (53%) diff --git a/src/renderer/components/Settings.tsx b/src/renderer/components/Settings.tsx deleted file mode 100644 index eb0387f..0000000 --- a/src/renderer/components/Settings.tsx +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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.css"; - -import { Margins } from "@vencord/types/utils"; -import { Button, Forms, Select, Switch, Text, Toasts, useState } from "@vencord/types/webpack/common"; -import { setBadge } from "renderer/appBadge"; -import { useSettings } from "renderer/settings"; -import { isMac } from "renderer/utils"; -import { isTruthy } from "shared/utils/guards"; - -export default function SettingsUi() { - const Settings = useSettings(); - const supportsWindowsTransparency = VesktopNative.app.supportsWindowsTransparency(); - - const { autostart } = VesktopNative; - const [autoStartEnabled, setAutoStartEnabled] = useState(autostart.isEnabled()); - - const allSwitches: Array boolean)?]> = [ - [ - "customTitleBar", - "Discord Titlebar", - "Use Discord's custom title bar instead of the native system one. Requires a full restart." - ], - !isMac && ["tray", "Tray Icon", "Add a tray icon for Vesktop", true], - !isMac && [ - "minimizeToTray", - "Minimize to tray", - "Hitting X will make Vesktop minimize to the tray instead of closing", - true, - () => Settings.tray ?? true - ], - ["arRPC", "Rich Presence", "Enables Rich Presence via arRPC", false], - [ - "disableMinSize", - "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. Incompatible with 'Discord Titlebar'" - ], - ["disableSmoothScroll", "Disable smooth scrolling", "Disables smooth scrolling in Vesktop", false], - ["hardwareAcceleration", "Hardware Acceleration", "Enable hardware acceleration", true], - ["splashTheming", "Splash theming", "Adapt the splash window colors to your custom theme", false], - [ - "openLinksWithElectron", - "Open Links in app (experimental)", - "Opens links in a new Vesktop window instead of your web browser" - ], - ["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true] - ]; - - const switches = allSwitches.filter(isTruthy); - - return ( - - - Vesktop Settings - - - Discord Branch - (Settings.transparencyOption = v)} - isSelected={v => v === Settings.transparencyOption} - serialize={s => s} - /> - - - - )} - - Vencord Location - - Vencord files are loaded from{" "} - {Settings.vencordDir ? ( - { - e.preventDefault(); - VesktopNative.fileManager.showItemInFolder(Settings.vencordDir!); - }} - > - {Settings.vencordDir} - - ) : ( - "the default location" - )} - -
- - -
-
- ); -} diff --git a/src/renderer/components/index.ts b/src/renderer/components/index.ts index a6ab091..97ca03e 100644 --- a/src/renderer/components/index.ts +++ b/src/renderer/components/index.ts @@ -5,4 +5,3 @@ */ export * as ScreenShare from "./ScreenSharePicker"; -export { default as Settings } from "./Settings"; diff --git a/src/renderer/components/settings/AutoStartToggle.tsx b/src/renderer/components/settings/AutoStartToggle.tsx new file mode 100644 index 0000000..e0350d6 --- /dev/null +++ b/src/renderer/components/settings/AutoStartToggle.tsx @@ -0,0 +1,26 @@ +/* + * 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 { Switch, useState } from "@vencord/types/webpack/common"; + +import { SettingsComponent } from "./Settings"; + +export const AutoStartToggle: SettingsComponent = () => { + const [autoStartEnabled, setAutoStartEnabled] = useState(VesktopNative.autostart.isEnabled()); + + return ( + { + await VesktopNative.autostart[v ? "enable" : "disable"](); + setAutoStartEnabled(v); + }} + note="Automatically start Vesktop on computer start-up" + > + Start With System + + ); +}; diff --git a/src/renderer/components/settings/DiscordBranchPicker.tsx b/src/renderer/components/settings/DiscordBranchPicker.tsx new file mode 100644 index 0000000..c0b840d --- /dev/null +++ b/src/renderer/components/settings/DiscordBranchPicker.tsx @@ -0,0 +1,26 @@ +/* + * 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 { Select } from "@vencord/types/webpack/common"; + +import { SettingsComponent } from "./Settings"; + +export const DiscordBranchPicker: SettingsComponent = ({ settings }) => { + return ( + (settings.transparencyOption = v)} + isSelected={v => v === settings.transparencyOption} + serialize={s => s} + /> + + + + ); +}; diff --git a/src/renderer/components/settings.css b/src/renderer/components/settings/settings.css similarity index 53% rename from src/renderer/components/settings.css rename to src/renderer/components/settings/settings.css index d82cec9..d55ff50 100644 --- a/src/renderer/components/settings.css +++ b/src/renderer/components/settings/settings.css @@ -4,3 +4,11 @@ gap: 0.5em; margin-top: 0.5em; } + +.vcd-settings-section { + margin-top: 1.5rem; +} + +.vcd-settings-title { + margin-bottom: 0.5rem; +} \ No newline at end of file diff --git a/src/renderer/index.ts b/src/renderer/index.ts index ebe6bc6..1ccc2e4 100644 --- a/src/renderer/index.ts +++ b/src/renderer/index.ts @@ -15,7 +15,7 @@ export * as Components from "./components"; import { findByPropsLazy } from "@vencord/types/webpack"; import { FluxDispatcher } from "@vencord/types/webpack/common"; -import SettingsUi from "./components/Settings"; +import SettingsUi from "./components/settings/Settings"; import { Settings } from "./settings"; export { Settings };