Re-implement minimize on close.
This commit is contained in:
parent
1a62af799b
commit
4ce02148e2
22
main.js
22
main.js
|
@ -8,7 +8,7 @@ let mainWindow
|
|||
// Require other app modules
|
||||
const trayService = require(__dirname+'/modules/tray-service')
|
||||
const menuService = require(__dirname+'/modules/menu-service')
|
||||
// const settingsService = require(__dirname+'/modules/settings-service')
|
||||
const settingsService = require(__dirname+'/modules/settings-service')
|
||||
|
||||
const isMac = process.platform === 'darwin'
|
||||
const isWin = process.platform === 'win32'
|
||||
|
@ -50,21 +50,17 @@ function createWindow () {
|
|||
// mainWindow.webContents.openDevTools()
|
||||
|
||||
// Before close
|
||||
// const minimizeOnClose = settingsService.get('minimizeOnClose');
|
||||
const minimizeOnClose = false; // XXX: this doesn't seem to work
|
||||
if (minimizeOnClose) {
|
||||
mainWindow.on('close', (e) => {
|
||||
if (!app.isQuitting) {
|
||||
e.preventDefault()
|
||||
mainWindow.hide()
|
||||
}
|
||||
return false;
|
||||
})
|
||||
}
|
||||
mainWindow.on('close', (e) => {
|
||||
if (!app.isQuitting && settingsService.get('minimizeOnClose')) {
|
||||
e.preventDefault()
|
||||
mainWindow.hide()
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
// Handle shutdown event on Mac with minimizeOnClose
|
||||
// to prevent shutdown interrupt
|
||||
if (isMac && minimizeOnClose) {
|
||||
if (isMac) {
|
||||
const { powerMonitor } = require('electron')
|
||||
powerMonitor.on('shutdown', () => {
|
||||
app.isQuitting = true
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* Module for Menu functions.
|
||||
*/
|
||||
const {app, Menu, BrowserWindow} = require('electron')
|
||||
const settingsService = require(__dirname + '/../modules/settings-service')
|
||||
|
||||
const menuService = {}
|
||||
|
||||
|
@ -19,6 +20,15 @@ menuService.createMenu = () => {
|
|||
activeWindow.reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Minimize on close',
|
||||
type: 'checkbox',
|
||||
checked: settingsService.get('minimizeOnClose'),
|
||||
click: () => {
|
||||
this.checked = !this.checked;
|
||||
settingsService.set('minimizeOnClose', this.checked);
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator',
|
||||
},
|
||||
|
@ -30,7 +40,7 @@ menuService.createMenu = () => {
|
|||
app.quit()
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}
|
||||
|
||||
const edit = {
|
||||
|
@ -67,7 +77,7 @@ menuService.createMenu = () => {
|
|||
accelerator: 'CmdOrCtrl+A',
|
||||
role: 'selectAll',
|
||||
},
|
||||
],
|
||||
],
|
||||
}
|
||||
|
||||
const help = {
|
||||
|
|
Loading…
Reference in New Issue