mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-02-11 17:55:51 +00:00
Restore window size and position
This commit is contained in:
parent
e15a68f180
commit
17a06b4863
29
electron.js
29
electron.js
@ -1018,10 +1018,13 @@ Menu.setApplicationMenu(editMenu)
|
|||||||
let myWindow = null
|
let myWindow = null
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
|
// Get saved window config, or default to empty object
|
||||||
|
let windowConfig = store.get('winBounds', {})
|
||||||
myWindow = new BrowserWindow({
|
myWindow = new BrowserWindow({
|
||||||
backgroundColor: '#eee',
|
backgroundColor: '#eee',
|
||||||
width: 1280,
|
// Use saved size, or default values if config is empty
|
||||||
height: 720,
|
width: windowConfig.width || 1280,
|
||||||
|
height: windowConfig.height || 720,
|
||||||
minWidth: 700,
|
minWidth: 700,
|
||||||
minHeight: 640,
|
minHeight: 640,
|
||||||
icon: path.join(__dirname + '/img/icons/png/256x256.png'),
|
icon: path.join(__dirname + '/img/icons/png/256x256.png'),
|
||||||
@ -1038,9 +1041,27 @@ function createWindow() {
|
|||||||
},
|
},
|
||||||
show: false
|
show: false
|
||||||
})
|
})
|
||||||
myWindow.maximize()
|
// Maximize window if saved config was maximized
|
||||||
myWindow.show()
|
if (store.get('isMaximized', false)) {
|
||||||
|
myWindow.maximize()
|
||||||
|
// Apply saved window position if config is not empty
|
||||||
|
} else if (windowConfig.x !== undefined && windowConfig.y !== undefined) {
|
||||||
|
myWindow.setPosition(windowConfig.x, windowConfig.y)
|
||||||
|
// Electron centers windows by default if position is not set
|
||||||
|
}
|
||||||
|
// Wait until window is ready before showing
|
||||||
|
myWindow.once('ready-to-show', myWindow.show)
|
||||||
myWindow.loadURL('http://localhost:12388/app')
|
myWindow.loadURL('http://localhost:12388/app')
|
||||||
|
// Save current window config when closing
|
||||||
|
myWindow.on('close', () => {
|
||||||
|
// Save current maximized state
|
||||||
|
const isMaximized = myWindow.isMaximized()
|
||||||
|
store.set('isMaximized', isMaximized)
|
||||||
|
// Save current size and position if not maximized
|
||||||
|
if (!isMaximized) {
|
||||||
|
store.set('winBounds', myWindow.getBounds())
|
||||||
|
}
|
||||||
|
})
|
||||||
myWindow.on('closed', function () {
|
myWindow.on('closed', function () {
|
||||||
myWindow = null
|
myWindow = null
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user