mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
Merge pull request #1177 from hydralauncher/feature/quality-of-life
feature/add-start-minimized-option
This commit is contained in:
commit
760030841a
@ -253,7 +253,8 @@
|
|||||||
"must_be_valid_url": "The source must be a valid URL",
|
"must_be_valid_url": "The source must be a valid URL",
|
||||||
"blocked_users": "Blocked users",
|
"blocked_users": "Blocked users",
|
||||||
"user_unblocked": "User has been unblocked",
|
"user_unblocked": "User has been unblocked",
|
||||||
"enable_achievement_notifications": "When an achievement in unlocked"
|
"enable_achievement_notifications": "When an achievement in unlocked",
|
||||||
|
"launch_minimized": "Launch Hydra minimized"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download complete",
|
"download_complete": "Download complete",
|
||||||
|
@ -249,7 +249,8 @@
|
|||||||
"must_be_valid_url": "A fonte deve ser uma URL válida",
|
"must_be_valid_url": "A fonte deve ser uma URL válida",
|
||||||
"blocked_users": "Usuários bloqueados",
|
"blocked_users": "Usuários bloqueados",
|
||||||
"user_unblocked": "Usuário desbloqueado",
|
"user_unblocked": "Usuário desbloqueado",
|
||||||
"enable_achievement_notifications": "Quando uma conquista é desbloqueada"
|
"enable_achievement_notifications": "Quando uma conquista é desbloqueada",
|
||||||
|
"launch_minimized": "Iniciar o Hydra minimizado"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"download_complete": "Download concluído",
|
"download_complete": "Download concluído",
|
||||||
|
@ -35,6 +35,9 @@ export class UserPreferences {
|
|||||||
@Column("boolean", { default: false })
|
@Column("boolean", { default: false })
|
||||||
runAtStartup: boolean;
|
runAtStartup: boolean;
|
||||||
|
|
||||||
|
@Column("boolean", { default: false })
|
||||||
|
startMinimized: boolean;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
|
@ -16,15 +16,16 @@ const windowsStartupPath = path.join(
|
|||||||
|
|
||||||
const autoLaunch = async (
|
const autoLaunch = async (
|
||||||
_event: Electron.IpcMainInvokeEvent,
|
_event: Electron.IpcMainInvokeEvent,
|
||||||
enabled: boolean
|
autoLaunchProps: { enabled: boolean; minimized: boolean }
|
||||||
) => {
|
) => {
|
||||||
if (!app.isPackaged) return;
|
if (!app.isPackaged) return;
|
||||||
|
|
||||||
const appLauncher = new AutoLaunch({
|
const appLauncher = new AutoLaunch({
|
||||||
name: app.getName(),
|
name: app.getName(),
|
||||||
|
isHidden: autoLaunchProps.minimized,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (enabled) {
|
if (autoLaunchProps.enabled) {
|
||||||
appLauncher.enable().catch((err) => {
|
appLauncher.enable().catch((err) => {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
});
|
});
|
||||||
|
@ -101,7 +101,10 @@ app.whenReady().then(async () => {
|
|||||||
i18n.changeLanguage(userPreferences.language);
|
i18n.changeLanguage(userPreferences.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!process.argv.includes("--hidden")) {
|
||||||
WindowManager.createMainWindow();
|
WindowManager.createMainWindow();
|
||||||
|
}
|
||||||
|
|
||||||
WindowManager.createNotificationWindow();
|
WindowManager.createNotificationWindow();
|
||||||
WindowManager.createSystemTray(userPreferences?.language || "en");
|
WindowManager.createSystemTray(userPreferences?.language || "en");
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ import { AddAchievementNotificationPreference } from "./migrations/2024101301290
|
|||||||
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
|
import { CreateUserSubscription } from "./migrations/20241015235142_create_user_subscription";
|
||||||
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
|
import { AddBackgroundImageUrl } from "./migrations/20241016100249_add_background_image_url";
|
||||||
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
|
import { AddWinePrefixToGame } from "./migrations/20241019081648_add_wine_prefix_to_game";
|
||||||
|
import { AddStartMinimizedColumn } from "./migrations/20241030171454_add_start_minimized_column";
|
||||||
export type HydraMigration = Knex.Migration & { name: string };
|
export type HydraMigration = Knex.Migration & { name: string };
|
||||||
|
|
||||||
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
||||||
@ -27,6 +27,7 @@ class MigrationSource implements Knex.MigrationSource<HydraMigration> {
|
|||||||
CreateUserSubscription,
|
CreateUserSubscription,
|
||||||
AddBackgroundImageUrl,
|
AddBackgroundImageUrl,
|
||||||
AddWinePrefixToGame,
|
AddWinePrefixToGame,
|
||||||
|
AddStartMinimizedColumn,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
getMigrationName(migration: HydraMigration): string {
|
getMigrationName(migration: HydraMigration): string {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
import type { HydraMigration } from "@main/knex-client";
|
||||||
|
import type { Knex } from "knex";
|
||||||
|
|
||||||
|
export const AddStartMinimizedColumn: HydraMigration = {
|
||||||
|
name: "AddStartMinimizedColumn",
|
||||||
|
up: (knex: Knex) => {
|
||||||
|
return knex.schema.alterTable("user_preferences", (table) => {
|
||||||
|
return table.boolean("startMinimized").notNullable().defaultTo(0);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
down: async (knex: Knex) => {
|
||||||
|
return knex.schema.alterTable("user_preferences", (table) => {
|
||||||
|
return table.dropColumn("startMinimized");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
@ -310,14 +310,15 @@ export class WindowManager {
|
|||||||
if (process.platform !== "darwin") {
|
if (process.platform !== "darwin") {
|
||||||
tray.addListener("click", () => {
|
tray.addListener("click", () => {
|
||||||
if (this.mainWindow) {
|
if (this.mainWindow) {
|
||||||
if (WindowManager.mainWindow?.isMinimized())
|
if (
|
||||||
WindowManager.mainWindow.restore();
|
WindowManager.mainWindow?.isMinimized() ||
|
||||||
|
!WindowManager.mainWindow?.isVisible()
|
||||||
WindowManager.mainWindow?.focus();
|
) {
|
||||||
return;
|
WindowManager.mainWindow?.show();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
this.createMainWindow();
|
this.createMainWindow();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tray.addListener("right-click", showContextMenu);
|
tray.addListener("right-click", showContextMenu);
|
||||||
|
@ -101,7 +101,8 @@ contextBridge.exposeInMainWorld("electron", {
|
|||||||
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
getUserPreferences: () => ipcRenderer.invoke("getUserPreferences"),
|
||||||
updateUserPreferences: (preferences: UserPreferences) =>
|
updateUserPreferences: (preferences: UserPreferences) =>
|
||||||
ipcRenderer.invoke("updateUserPreferences", preferences),
|
ipcRenderer.invoke("updateUserPreferences", preferences),
|
||||||
autoLaunch: (enabled: boolean) => ipcRenderer.invoke("autoLaunch", enabled),
|
autoLaunch: (autoLaunchProps: { enabled: boolean; minimized: boolean }) =>
|
||||||
|
ipcRenderer.invoke("autoLaunch", autoLaunchProps),
|
||||||
authenticateRealDebrid: (apiToken: string) =>
|
authenticateRealDebrid: (apiToken: string) =>
|
||||||
ipcRenderer.invoke("authenticateRealDebrid", apiToken),
|
ipcRenderer.invoke("authenticateRealDebrid", apiToken),
|
||||||
|
|
||||||
|
5
src/renderer/src/declaration.d.ts
vendored
5
src/renderer/src/declaration.d.ts
vendored
@ -114,7 +114,10 @@ declare global {
|
|||||||
updateUserPreferences: (
|
updateUserPreferences: (
|
||||||
preferences: Partial<UserPreferences>
|
preferences: Partial<UserPreferences>
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
autoLaunch: (enabled: boolean) => Promise<void>;
|
autoLaunch: (autoLaunchProps: {
|
||||||
|
enabled: boolean;
|
||||||
|
minimized: boolean;
|
||||||
|
}) => Promise<void>;
|
||||||
authenticateRealDebrid: (apiToken: string) => Promise<RealDebridUser>;
|
authenticateRealDebrid: (apiToken: string) => Promise<RealDebridUser>;
|
||||||
|
|
||||||
/* Download sources */
|
/* Download sources */
|
||||||
|
@ -17,6 +17,7 @@ export function SettingsBehavior() {
|
|||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
preferQuitInsteadOfHiding: false,
|
preferQuitInsteadOfHiding: false,
|
||||||
runAtStartup: false,
|
runAtStartup: false,
|
||||||
|
startMinimized: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useTranslation("settings");
|
const { t } = useTranslation("settings");
|
||||||
@ -26,6 +27,7 @@ export function SettingsBehavior() {
|
|||||||
setForm({
|
setForm({
|
||||||
preferQuitInsteadOfHiding: userPreferences.preferQuitInsteadOfHiding,
|
preferQuitInsteadOfHiding: userPreferences.preferQuitInsteadOfHiding,
|
||||||
runAtStartup: userPreferences.runAtStartup,
|
runAtStartup: userPreferences.runAtStartup,
|
||||||
|
startMinimized: userPreferences.startMinimized,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [userPreferences]);
|
}, [userPreferences]);
|
||||||
@ -58,11 +60,32 @@ export function SettingsBehavior() {
|
|||||||
label={t("launch_with_system")}
|
label={t("launch_with_system")}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
handleChange({ runAtStartup: !form.runAtStartup });
|
handleChange({ runAtStartup: !form.runAtStartup });
|
||||||
window.electron.autoLaunch(!form.runAtStartup);
|
window.electron.autoLaunch({
|
||||||
|
enabled: !form.runAtStartup,
|
||||||
|
minimized: form.startMinimized,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
checked={form.runAtStartup}
|
checked={form.runAtStartup}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showRunAtStartup && (
|
||||||
|
<div style={{ opacity: form.runAtStartup ? 1 : 0.5 }}>
|
||||||
|
<CheckboxField
|
||||||
|
label={t("launch_minimized")}
|
||||||
|
style={{ cursor: form.runAtStartup ? "pointer" : "not-allowed" }}
|
||||||
|
checked={form.runAtStartup && form.startMinimized}
|
||||||
|
disabled={!form.runAtStartup}
|
||||||
|
onChange={() => {
|
||||||
|
handleChange({ startMinimized: !form.startMinimized });
|
||||||
|
window.electron.autoLaunch({
|
||||||
|
minimized: !form.startMinimized,
|
||||||
|
enabled: form.runAtStartup,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,7 @@ export interface UserPreferences {
|
|||||||
realDebridApiToken: string | null;
|
realDebridApiToken: string | null;
|
||||||
preferQuitInsteadOfHiding: boolean;
|
preferQuitInsteadOfHiding: boolean;
|
||||||
runAtStartup: boolean;
|
runAtStartup: boolean;
|
||||||
|
startMinimized: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Steam250Game {
|
export interface Steam250Game {
|
||||||
|
Loading…
Reference in New Issue
Block a user