mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:00:44 +02:00
Add prompt dialog before shutting down
This commit is contained in:
parent
8a4855c411
commit
ef7d60687b
1 changed files with 19 additions and 12 deletions
|
@ -4,7 +4,7 @@ var electron = require('electron');
|
||||||
var app = electron.app; // Module to control application life.
|
var app = electron.app; // Module to control application life.
|
||||||
var BrowserWindow = electron.BrowserWindow;
|
var BrowserWindow = electron.BrowserWindow;
|
||||||
|
|
||||||
|
var dialog = electron.dialog;
|
||||||
var Menu = require('menu');
|
var Menu = require('menu');
|
||||||
var Tray = require('tray');
|
var Tray = require('tray');
|
||||||
var shell = require('shell');
|
var shell = require('shell');
|
||||||
|
@ -44,19 +44,26 @@ const osType = os.type();
|
||||||
var isShuttingDown = false;
|
var isShuttingDown = false;
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
if (!isShuttingDown) {
|
if (!isShuttingDown) {
|
||||||
isShuttingDown = true;
|
var idx = dialog.showMessageBox({
|
||||||
logWindow.close();
|
type: 'question',
|
||||||
homeServer.stop();
|
buttons: ['Yes', 'No'],
|
||||||
|
message: 'Are you sure you want to quit?'
|
||||||
var timeoutID = setTimeout(app.quit, 5000);
|
|
||||||
homeServer.on('state-update', function(processGroup) {
|
|
||||||
if (processGroup.state == ProcessGroupStates.STOPPED) {
|
|
||||||
clearTimeout(timeoutID);
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
if (idx == 0) {
|
||||||
|
isShuttingDown = true;
|
||||||
|
logWindow.close();
|
||||||
|
homeServer.stop();
|
||||||
|
|
||||||
updateTrayMenu(null);
|
var timeoutID = setTimeout(app.quit, 5000);
|
||||||
|
homeServer.on('state-update', function(processGroup) {
|
||||||
|
if (processGroup.state == ProcessGroupStates.STOPPED) {
|
||||||
|
clearTimeout(timeoutID);
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateTrayMenu(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue