fix #43, #44: windows minimize to tray bugfix

This commit is contained in:
Antelle 2015-11-22 21:18:54 +03:00
parent 2dfca40246
commit 8407c76046
5 changed files with 31 additions and 9 deletions

View File

@ -54,7 +54,7 @@ if (window.process && window.process.versions && window.process.versions.electro
return false; return false;
}, },
exit: function() { exit: function() {
Launcher.exitRequested = true; this.exitRequested = true;
this.requestExit(); this.requestExit();
}, },
requestExit: function() { requestExit: function() {
@ -85,6 +85,9 @@ if (window.process && window.process.versions && window.process.versions.electro
return process.platform === 'win32'; return process.platform === 'win32';
} }
}; };
Backbone.on('launcher-exit-request', function() {
setTimeout(function() { Launcher.exit(); }, 0);
});
window.launcherOpen = function(path) { window.launcherOpen = function(path) {
Backbone.trigger('launcher-open-file', path); Backbone.trigger('launcher-open-file', path);
}; };

View File

@ -10,6 +10,7 @@ var app = require('app'),
Tray = require('tray'); Tray = require('tray');
var mainWindow = null, var mainWindow = null,
appIcon = null,
openFile = process.argv.filter(function(arg) { return /\.kdbx$/i.test(arg); })[0], openFile = process.argv.filter(function(arg) { return /\.kdbx$/i.test(arg); })[0],
ready = false, ready = false,
restartPending = false, restartPending = false,
@ -65,15 +66,30 @@ app.minimizeApp = function() {
if (process.platform === 'win32') { if (process.platform === 'win32') {
mainWindow.minimize(); mainWindow.minimize();
mainWindow.setSkipTaskbar(true); mainWindow.setSkipTaskbar(true);
var appIcon = new Tray(path.join(__dirname, 'icon.png')); appIcon = new Tray(path.join(__dirname, 'icon.png'));
appIcon.on('clicked', function () { appIcon.on('clicked', restoreMainWindow);
mainWindow.restore(); var contextMenu = Menu.buildFromTemplate([
mainWindow.setSkipTaskbar(false); { label: 'Open KeeWeb', click: restoreMainWindow },
}); { label: 'Quit KeeWeb', click: closeMainWindow }
]);
appIcon.setContextMenu(contextMenu);
appIcon.setToolTip('KeeWeb'); appIcon.setToolTip('KeeWeb');
} }
}; };
function restoreMainWindow() {
appIcon.destroy();
appIcon = null;
mainWindow.restore();
mainWindow.setSkipTaskbar(false);
}
function closeMainWindow() {
appIcon.destroy();
appIcon = null;
mainWindow.webContents.executeJavaScript('Backbone.trigger("launcher-exit-request");');
}
function setMenu() { function setMenu() {
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
var name = require('app').getName(); var name = require('app').getName();

View File

@ -1,6 +1,6 @@
{ {
"name": "KeeWeb", "name": "KeeWeb",
"version": "0.4.2", "version": "0.4.3",
"description": "KeePass web app", "description": "KeePass web app",
"main": "main.js", "main": "main.js",
"repository": "https://github.com/antelle/keeweb", "repository": "https://github.com/antelle/keeweb",

View File

@ -1,6 +1,6 @@
{ {
"name": "keeweb", "name": "keeweb",
"version": "0.4.2", "version": "0.4.3",
"description": "KeePass web app", "description": "KeePass web app",
"main": "Gruntfile.js", "main": "Gruntfile.js",
"repository": "https://github.com/antelle/keeweb", "repository": "https://github.com/antelle/keeweb",

View File

@ -1,7 +1,10 @@
Release notes Release notes
------------- -------------
##### v0.4.3 (2015-11-22)
Windows minimize to tray bugfix
##### v0.4.1, v0.4.2 (2015-11-22) ##### v0.4.1, v0.4.2 (2015-11-22)
Auto-update bugfixes Auto-update and bugfixes
##### v0.4.0 (2015-11-22) ##### v0.4.0 (2015-11-22)
Locking, better Dropbox, custom icons, security enhancements, bugfixes Locking, better Dropbox, custom icons, security enhancements, bugfixes