feat: minimise-to-tray-on-startup (#126)
* feat: minimise-to-tray-on-startup Signed-off-by: Mihai <cristian@mihaimuresan.com> * feat: minimise-to-tray-on-startup Signed-off-by: Mihai <cristian@mihaimuresan.com> * fix: redundant call Signed-off-by: Mihai <cristian@mihaimuresan.com> * fix: redundant call Signed-off-by: Mihai <cristian@mihaimuresan.com> --------- Signed-off-by: Mihai <cristian@mihaimuresan.com> Co-authored-by: Mihai <cristian@mihaimuresan.com>
This commit is contained in:
+24
-4
@@ -16,6 +16,9 @@ const schema = {
|
|||||||
minimiseToTray: {
|
minimiseToTray: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
} as JSONSchema.Boolean,
|
} as JSONSchema.Boolean,
|
||||||
|
startMinimisedToTray: {
|
||||||
|
type: "boolean",
|
||||||
|
} as JSONSchema.Boolean,
|
||||||
spellchecker: {
|
spellchecker: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
} as JSONSchema.Boolean,
|
} as JSONSchema.Boolean,
|
||||||
@@ -29,16 +32,16 @@ const schema = {
|
|||||||
type: "object",
|
type: "object",
|
||||||
properties: {
|
properties: {
|
||||||
x: {
|
x: {
|
||||||
type: 'number'
|
type: "number",
|
||||||
} as JSONSchema.Number,
|
} as JSONSchema.Number,
|
||||||
y: {
|
y: {
|
||||||
type: 'number'
|
type: "number",
|
||||||
} as JSONSchema.Number,
|
} as JSONSchema.Number,
|
||||||
width: {
|
width: {
|
||||||
type: 'number'
|
type: "number",
|
||||||
} as JSONSchema.Number,
|
} as JSONSchema.Number,
|
||||||
height: {
|
height: {
|
||||||
type: 'number'
|
type: "number",
|
||||||
} as JSONSchema.Number,
|
} as JSONSchema.Number,
|
||||||
isMaximised: {
|
isMaximised: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
@@ -53,6 +56,7 @@ const store = new Store({
|
|||||||
firstLaunch: true,
|
firstLaunch: true,
|
||||||
customFrame: true,
|
customFrame: true,
|
||||||
minimiseToTray: true,
|
minimiseToTray: true,
|
||||||
|
startMinimisedToTray: false,
|
||||||
spellchecker: true,
|
spellchecker: true,
|
||||||
hardwareAcceleration: true,
|
hardwareAcceleration: true,
|
||||||
discordRpc: true,
|
discordRpc: true,
|
||||||
@@ -75,6 +79,7 @@ class Config {
|
|||||||
firstLaunch: this.firstLaunch,
|
firstLaunch: this.firstLaunch,
|
||||||
customFrame: this.customFrame,
|
customFrame: this.customFrame,
|
||||||
minimiseToTray: this.minimiseToTray,
|
minimiseToTray: this.minimiseToTray,
|
||||||
|
startMinimisedToTray: this.startMinimisedToTray,
|
||||||
spellchecker: this.spellchecker,
|
spellchecker: this.spellchecker,
|
||||||
hardwareAcceleration: this.hardwareAcceleration,
|
hardwareAcceleration: this.hardwareAcceleration,
|
||||||
discordRpc: this.discordRpc,
|
discordRpc: this.discordRpc,
|
||||||
@@ -123,6 +128,21 @@ class Config {
|
|||||||
this.sync();
|
this.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get startMinimisedToTray() {
|
||||||
|
return (store as never as { get(k: string): boolean }).get(
|
||||||
|
"startMinimisedToTray",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
set startMinimisedToTray(value: boolean) {
|
||||||
|
(store as never as { set(k: string, value: boolean): void }).set(
|
||||||
|
"startMinimisedToTray",
|
||||||
|
value,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.sync();
|
||||||
|
}
|
||||||
|
|
||||||
get spellchecker() {
|
get spellchecker() {
|
||||||
return (store as never as { get(k: string): boolean }).get("spellchecker");
|
return (store as never as { get(k: string): boolean }).get("spellchecker");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ const windowIcon = nativeImage.createFromDataURL(windowIconAsset);
|
|||||||
* Create the main application window
|
* Create the main application window
|
||||||
*/
|
*/
|
||||||
export function createMainWindow() {
|
export function createMainWindow() {
|
||||||
|
// (CLI arg --hidden or config)
|
||||||
|
const startHidden =
|
||||||
|
app.commandLine.hasSwitch("hidden") || config.startMinimisedToTray;
|
||||||
|
|
||||||
// create the window
|
// create the window
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
minWidth: 300,
|
minWidth: 300,
|
||||||
@@ -45,6 +49,7 @@ export function createMainWindow() {
|
|||||||
backgroundColor: "#191919",
|
backgroundColor: "#191919",
|
||||||
frame: !config.customFrame,
|
frame: !config.customFrame,
|
||||||
icon: windowIcon,
|
icon: windowIcon,
|
||||||
|
show: !startHidden,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
// relative to `.vite/build`
|
// relative to `.vite/build`
|
||||||
preload: join(__dirname, "preload.js"),
|
preload: join(__dirname, "preload.js"),
|
||||||
|
|||||||
Reference in New Issue
Block a user