Allow configuration of whether closing window closes or minimizes to tray
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
588030141b
commit
714570443d
4 changed files with 25 additions and 15 deletions
|
@ -35,6 +35,7 @@ const updater = require('./updater');
|
|||
const { migrateFromOldOrigin } = require('./originMigrator');
|
||||
|
||||
const windowStateKeeper = require('electron-window-state');
|
||||
const Store = require('electron-store');
|
||||
|
||||
// boolean flag set whilst we are doing one-time origin migration
|
||||
// We only serve the origin migration script while we're actually
|
||||
|
@ -55,8 +56,11 @@ try {
|
|||
// Continue with the defaults (ie. an empty config)
|
||||
}
|
||||
|
||||
const store = new Store();
|
||||
|
||||
let mainWindow = null;
|
||||
global.appQuitting = false;
|
||||
global.minimizeToTray = store.get('minimizeToTray', true);
|
||||
|
||||
|
||||
// handle uncaught errors otherwise it displays
|
||||
|
@ -136,6 +140,12 @@ ipcMain.on('ipcCall', async function(ev, payload) {
|
|||
launcher.disable();
|
||||
}
|
||||
break;
|
||||
case 'getMinimizeToTrayEnabled':
|
||||
ret = global.minimizeToTray;
|
||||
break;
|
||||
case 'setMinimizeToTrayEnabled':
|
||||
store.set('minimizeToTray', global.minimizeToTray = args[0]);
|
||||
break;
|
||||
case 'getAppVersion':
|
||||
ret = app.getVersion();
|
||||
break;
|
||||
|
@ -331,7 +341,7 @@ app.on('ready', () => {
|
|||
mainWindow = global.mainWindow = null;
|
||||
});
|
||||
mainWindow.on('close', (e) => {
|
||||
if (!global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
|
||||
if (global.minimizeToTray && !global.appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
|
||||
// On Mac, closing the window just hides it
|
||||
// (this is generally how single-window Mac apps
|
||||
// behave, eg. Mail.app)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue