feat: Add start as minimized toggle to settings (#248)

Co-authored-by: TheKodeToad <TheKodeToad@proton.me>
Co-authored-by: V <vendicated@riseup.net>
Co-authored-by: Lewis Crichton <lewi@lewisakura.moe>
This commit is contained in:
Michal Vaniš 2023-12-09 14:42:44 +01:00 committed by GitHub
parent 4974848a56
commit 40b952d8bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 8 deletions

View file

@ -442,7 +442,8 @@ function createMainWindow() {
const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js")));
export async function createWindows() { export async function createWindows() {
const splash = createSplashWindow(); const { startMinimized } = Settings.store;
const splash = createSplashWindow(startMinimized);
// SteamOS letterboxes and scales it terribly, so just full screen it // SteamOS letterboxes and scales it terribly, so just full screen it
if (isDeckGameMode) splash.setFullScreen(true); if (isDeckGameMode) splash.setFullScreen(true);
await ensureVencordFiles(); await ensureVencordFiles();
@ -452,11 +453,8 @@ export async function createWindows() {
mainWin.webContents.on("did-finish-load", () => { mainWin.webContents.on("did-finish-load", () => {
splash.destroy(); splash.destroy();
mainWin!.show();
if (Settings.store.maximized && !isDeckGameMode) { if (!startMinimized || isDeckGameMode) mainWin!.show();
mainWin!.maximize();
}
if (isDeckGameMode) { if (isDeckGameMode) {
// always use entire display // always use entire display
@ -466,5 +464,11 @@ export async function createWindows() {
} }
}); });
mainWin.once("show", () => {
if (Settings.store.maximized && !mainWin!.isMaximized() && !isDeckGameMode) {
mainWin!.maximize();
}
});
initArRPC(); initArRPC();
} }

View file

@ -11,10 +11,11 @@ import { ICON_PATH, VIEW_DIR } from "shared/paths";
import { Settings } from "./settings"; import { Settings } from "./settings";
export function createSplashWindow() { export function createSplashWindow(startMinimized = false) {
const splash = new BrowserWindow({ const splash = new BrowserWindow({
...SplashProps, ...SplashProps,
icon: ICON_PATH icon: ICON_PATH,
show: !startMinimized
}); });
splash.loadFile(join(VIEW_DIR, "splash.html")); splash.loadFile(join(VIEW_DIR, "splash.html"));

View file

@ -49,7 +49,8 @@ export default function SettingsUi() {
"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"
], ],
["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true] ["checkUpdates", "Check for updates", "Automatically check for Vesktop updates", true],
["startMinimized", "Start minimized", "Vesktop remains in minimized mode on start", false]
]; ];
const switches = allSwitches.filter(isTruthy); const switches = allSwitches.filter(isTruthy);

View file

@ -19,6 +19,7 @@ export interface Settings {
arRPC?: boolean; arRPC?: boolean;
appBadge?: boolean; appBadge?: boolean;
discordWindowsTitleBar?: boolean; discordWindowsTitleBar?: boolean;
startMinimized?: boolean;
maximized?: boolean; maximized?: boolean;
minimized?: boolean; minimized?: boolean;