option to quit the app or minimize

This commit is contained in:
Hachi-R 2024-05-03 13:13:37 -03:00
parent f6072eeb5c
commit 8aed8f15d7
6 changed files with 33 additions and 7 deletions

View file

@ -134,7 +134,9 @@
"enable_download_notifications": "When a download is complete", "enable_download_notifications": "When a download is complete",
"enable_repack_list_notifications": "When a new repack is added", "enable_repack_list_notifications": "When a new repack is added",
"telemetry": "Telemetry", "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": { "notifications": {
"download_complete": "Download complete", "download_complete": "Download complete",

View file

@ -130,7 +130,9 @@
"enable_download_notifications": "Quando um download for concluído", "enable_download_notifications": "Quando um download for concluído",
"enable_repack_list_notifications": "Quando a lista de repacks for atualizada", "enable_repack_list_notifications": "Quando a lista de repacks for atualizada",
"telemetry": "Telemetria", "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": { "notifications": {
"download_complete": "Download concluído", "download_complete": "Download concluído",

View file

@ -26,6 +26,9 @@ export class UserPreferences {
@Column("boolean", { default: true }) @Column("boolean", { default: true })
telemetryEnabled: boolean; telemetryEnabled: boolean;
@Column("boolean", { default: false })
quitInXButtonEnabled: boolean;
@CreateDateColumn() @CreateDateColumn()
createdAt: Date; createdAt: Date;

View file

@ -4,6 +4,7 @@ import { t } from "i18next";
import path from "node:path"; import path from "node:path";
import icon from "@resources/icon.png?asset"; import icon from "@resources/icon.png?asset";
import trayIcon from "@resources/tray-icon.png?asset"; import trayIcon from "@resources/tray-icon.png?asset";
import { userPreferencesRepository } from "@main/repository";
export class WindowManager { export class WindowManager {
public static mainWindow: Electron.BrowserWindow | null = null; 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. // Create the browser window.
this.mainWindow = new BrowserWindow({ this.mainWindow = new BrowserWindow({
width: 1200, width: 1200,
@ -33,8 +34,8 @@ export class WindowManager {
minWidth: 1024, minWidth: 1024,
minHeight: 540, minHeight: 540,
titleBarStyle: "hidden", titleBarStyle: "hidden",
...(process.platform === "linux" ? { icon } : {}), ...(process.platform === "linux" ? {icon} : {}),
trafficLightPosition: { x: 16, y: 16 }, trafficLightPosition: {x: 16, y: 16},
titleBarOverlay: { titleBarOverlay: {
symbolColor: "#DADBE1", symbolColor: "#DADBE1",
color: "#151515", color: "#151515",
@ -49,8 +50,12 @@ export class WindowManager {
this.loadURL(); this.loadURL();
this.mainWindow.removeMenu(); this.mainWindow.removeMenu();
const userPreferences = await userPreferencesRepository.findOne({
where: {id: 1},
});
this.mainWindow.on("close", () => { this.mainWindow.on("close", () => {
WindowManager.mainWindow?.setProgressBar(-1); userPreferences?.quitInXButtonEnabled ? app.quit() : WindowManager.mainWindow?.setProgressBar(-1);
}); });
} }

View file

@ -11,6 +11,7 @@ export function Settings() {
downloadNotificationsEnabled: false, downloadNotificationsEnabled: false,
repackUpdatesNotificationsEnabled: false, repackUpdatesNotificationsEnabled: false,
telemetryEnabled: false, telemetryEnabled: false,
quitInXButtonEnabled: false,
}); });
const { t } = useTranslation("settings"); const { t } = useTranslation("settings");
@ -27,6 +28,7 @@ export function Settings() {
repackUpdatesNotificationsEnabled: repackUpdatesNotificationsEnabled:
userPreferences?.repackUpdatesNotificationsEnabled ?? false, userPreferences?.repackUpdatesNotificationsEnabled ?? false,
telemetryEnabled: userPreferences?.telemetryEnabled ?? false, telemetryEnabled: userPreferences?.telemetryEnabled ?? false,
quitInXButtonEnabled: userPreferences?.quitInXButtonEnabled ?? false,
}); });
}); });
}, []); }, []);
@ -66,7 +68,7 @@ export function Settings() {
/> />
<Button <Button
style={{ alignSelf: "flex-end" }} style={{alignSelf: "flex-end"}}
theme="outline" theme="outline"
onClick={handleChooseDownloadsPath} onClick={handleChooseDownloadsPath}
> >
@ -107,6 +109,17 @@ export function Settings() {
updateUserPreferences("telemetryEnabled", !form.telemetryEnabled) updateUserPreferences("telemetryEnabled", !form.telemetryEnabled)
} }
/> />
<h3>{t("behavior")}</h3>
<CheckboxField
label={t("quit_app_instead_minimizing")}
checked={form.quitInXButtonEnabled}
onChange={() =>
updateUserPreferences("quitInXButtonEnabled", !form.quitInXButtonEnabled)
}
/>
</div> </div>
</section> </section>
); );

View file

@ -105,6 +105,7 @@ export interface UserPreferences {
downloadNotificationsEnabled: boolean; downloadNotificationsEnabled: boolean;
repackUpdatesNotificationsEnabled: boolean; repackUpdatesNotificationsEnabled: boolean;
telemetryEnabled: boolean; telemetryEnabled: boolean;
quitInXButtonEnabled: boolean;
} }
export interface HowLongToBeatCategory { export interface HowLongToBeatCategory {