Skip to content

Commit

Permalink
feat: Increase default dimensions and save window state
Browse files Browse the repository at this point in the history
Added electron-window-state to store and persist window dimensions and position.

Fixes #69
  • Loading branch information
OiNutter authored and ColinEberhardt committed Sep 26, 2021
1 parent cf04df4 commit a60efaa
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
13 changes: 11 additions & 2 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ import { autoUpdater } from "electron-updater";
import * as path from "path";
import * as url from "url";
import * as fs from "fs";
import windowStateKeeper from "electron-window-state";

import { download } from "electron-dl";

let mainWindow: Electron.BrowserWindow | null;
const iconPath = path.join(__dirname, "..", "build", "icons", "icon.png");

function createWindow() {
let mainWindowState = windowStateKeeper({
defaultWidth: 1000,
defaultHeight: 800,
});
mainWindow = new BrowserWindow({
title: "KDB Studio 2",
width: 900,
height: 700,
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
Expand All @@ -30,6 +37,8 @@ function createWindow() {
icon: iconPath,
});

mainWindowState.manage(mainWindow);

if (process.env.NODE_ENV === "development") {
mainWindow.loadURL(`http://localhost:4000`);
mainWindow.webContents.openDevTools();
Expand Down
28 changes: 24 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"electron-dl": "^3.2.1",
"electron-json-storage": "^4.5.0",
"electron-updater": "^4.3.9",
"electron-window-state": "^5.0.3",
"node-q": "2.x.x",
"office-ui-fabric-core": "^11.0.0",
"react": "^17.*",
Expand Down

0 comments on commit a60efaa

Please sign in to comment.