diff --git a/src/main/index.ts b/src/main/index.ts index f68b077..73fc1e8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -116,6 +116,25 @@ function createWindow(): void { { role: "togglefullscreen" }, ], }, + { + label: "Application", + submenu: [ + { + label: "Open on Startup", + checked: store.get("app.openOnStartup") as boolean, + type: "checkbox", + click: (): void => { + const currentSetting = store.get("app.openOnStartup") as boolean; + store.set("app.openOnStartup", !currentSetting); + log.info("Open on startup set to", !currentSetting); + app.setLoginItemSettings({ + enabled: true, //This is a windows only command. Updates the task manager and registry. + openAtLogin: !currentSetting, + }); + }, + }, + ], + }, // { role: 'windowMenu' } { label: "Window", @@ -132,17 +151,6 @@ function createWindow(): void { : [{ role: "close" }]), ], }, - { - role: "help", - submenu: [ - { - label: "Learn More", - click: async (): Promise => { - await shell.openExternal("https://electronjs.org"); - }, - }, - ], - }, { label: "Development", @@ -219,6 +227,13 @@ function createWindow(): void { mainWindow.on("ready-to-show", () => { mainWindow.show(); + //Start the HTTP server. + // Start the local HTTP server + try { + localServer.start(); + } catch (error) { + log.error("Failed to start HTTP server:", errorTypeCheck(error)); + } }); mainWindow.on("close", (event: Electron.Event) => { @@ -274,15 +289,6 @@ app.whenReady().then(async () => { }); } - //Start the HTTP server. - // Start the local HTTP server - try { - localServer.start(); - log.info("HTTP server initialized on port 1337"); - } catch (error) { - log.error("Failed to start HTTP server:", errorTypeCheck(error)); - } - //Create Tray const trayicon = nativeImage.createFromPath(appIcon); const tray = new Tray(trayicon.resize({ width: 16 })); diff --git a/src/main/store/store.ts b/src/main/store/store.ts index 553e060..0f99b46 100644 --- a/src/main/store/store.ts +++ b/src/main/store/store.ts @@ -3,6 +3,7 @@ import Store from "electron-store"; const store = new Store({ defaults: { settings: { + runOnStartup: true, filepaths: [], qbFilePath: "", runWatcherOnStartup: true,