diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json index 03dd4b6d..40909c1a 100644 --- a/src/locales/en/translation.json +++ b/src/locales/en/translation.json @@ -134,7 +134,9 @@ "enable_download_notifications": "When a download is complete", "enable_repack_list_notifications": "When a new repack is added", "telemetry": "Telemetry", - "telemetry_description": "Enable anonymous usage statistics" + "telemetry_description": "Enable anonymous usage statistics", + "behavior": "Behavior", + "quit_app_instead_minimizing": "Close app instead of minimizing to tray" }, "notifications": { "download_complete": "Download complete", diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.json index 3d967736..cc61e75f 100644 --- a/src/locales/pt/translation.json +++ b/src/locales/pt/translation.json @@ -130,7 +130,9 @@ "enable_download_notifications": "Quando um download for concluído", "enable_repack_list_notifications": "Quando a lista de repacks for atualizada", "telemetry": "Telemetria", - "telemetry_description": "Habilitar estatísticas de uso anônimas" + "telemetry_description": "Habilitar estatísticas de uso anônimas", + "behavior": "Comportamento", + "quit_app_instead_minimizing": "Fechar o aplicativo em vez de minimizá-lo" }, "notifications": { "download_complete": "Download concluído", diff --git a/src/main/entity/user-preferences.entity.ts b/src/main/entity/user-preferences.entity.ts index 40f1a26a..d4c37104 100644 --- a/src/main/entity/user-preferences.entity.ts +++ b/src/main/entity/user-preferences.entity.ts @@ -26,6 +26,9 @@ export class UserPreferences { @Column("boolean", { default: true }) telemetryEnabled: boolean; + @Column("boolean", { default: false }) + quitInXButtonEnabled: boolean; + @CreateDateColumn() createdAt: Date; diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index 05cb95d6..27c39903 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -4,6 +4,7 @@ import { t } from "i18next"; import path from "node:path"; import icon from "@resources/icon.png?asset"; import trayIcon from "@resources/tray-icon.png?asset"; +import { userPreferencesRepository } from "@main/repository"; export class WindowManager { public static mainWindow: Electron.BrowserWindow | null = null; @@ -25,7 +26,7 @@ export class WindowManager { } } - public static createMainWindow() { + public static async createMainWindow() { // Create the browser window. this.mainWindow = new BrowserWindow({ width: 1200, @@ -33,8 +34,8 @@ export class WindowManager { minWidth: 1024, minHeight: 540, titleBarStyle: "hidden", - ...(process.platform === "linux" ? { icon } : {}), - trafficLightPosition: { x: 16, y: 16 }, + ...(process.platform === "linux" ? {icon} : {}), + trafficLightPosition: {x: 16, y: 16}, titleBarOverlay: { symbolColor: "#DADBE1", color: "#151515", @@ -49,8 +50,12 @@ export class WindowManager { this.loadURL(); this.mainWindow.removeMenu(); + const userPreferences = await userPreferencesRepository.findOne({ + where: {id: 1}, + }); + this.mainWindow.on("close", () => { - WindowManager.mainWindow?.setProgressBar(-1); + userPreferences?.quitInXButtonEnabled ? app.quit() : WindowManager.mainWindow?.setProgressBar(-1); }); } diff --git a/src/renderer/src/pages/settings/settings.tsx b/src/renderer/src/pages/settings/settings.tsx index c7fe14cc..a15ed3ad 100644 --- a/src/renderer/src/pages/settings/settings.tsx +++ b/src/renderer/src/pages/settings/settings.tsx @@ -11,6 +11,7 @@ export function Settings() { downloadNotificationsEnabled: false, repackUpdatesNotificationsEnabled: false, telemetryEnabled: false, + quitInXButtonEnabled: false, }); const { t } = useTranslation("settings"); @@ -27,6 +28,7 @@ export function Settings() { repackUpdatesNotificationsEnabled: userPreferences?.repackUpdatesNotificationsEnabled ?? false, telemetryEnabled: userPreferences?.telemetryEnabled ?? false, + quitInXButtonEnabled: userPreferences?.quitInXButtonEnabled ?? false, }); }); }, []); @@ -66,7 +68,7 @@ export function Settings() { />