1
0
mirror of https://github.com/keeweb/keeweb.git synced 2024-06-27 07:45:08 +02:00

Merge pull request #995 from Coises/tray-min-auto-type-select-fix

tray-min-auto-type-select-fix
This commit is contained in:
antelle 2018-09-05 20:44:24 +03:00 committed by GitHub
commit 61ca037357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 13 deletions

View File

@ -200,7 +200,7 @@ const Launcher = {
hideApp: function() {
const app = this.remoteApp();
if (this.canMinimize()) {
app.getMainWindow().minimize();
app.minimizeThenHideIfInTray();
} else {
app.hide();
}

View File

@ -91,24 +91,31 @@ app.openWindow = function (opts) {
};
app.minimizeApp = function () {
let imagePath;
mainWindow.hide();
if (process.platform === 'darwin') {
mainWindow.hide();
app.dock.hide();
imagePath = 'mac-menubar-icon.png';
mainWindow.setSkipTaskbar(true);
} else {
mainWindow.hide();
imagePath = 'icon.png';
}
const image = electron.nativeImage.createFromPath(path.join(__dirname, imagePath));
appIcon = new electron.Tray(image);
appIcon.on('click', restoreMainWindow);
const contextMenu = electron.Menu.buildFromTemplate([
{label: 'Open KeeWeb', click: restoreMainWindow},
{label: 'Quit KeeWeb', click: closeMainWindow}
]);
appIcon.setContextMenu(contextMenu);
appIcon.setToolTip('KeeWeb');
mainWindow.setSkipTaskbar(true);
if (!appIcon) {
const image = electron.nativeImage.createFromPath(path.join(__dirname, imagePath));
appIcon = new electron.Tray(image);
appIcon.on('click', restoreMainWindow);
const contextMenu = electron.Menu.buildFromTemplate([
{label: 'Open KeeWeb', click: restoreMainWindow},
{label: 'Quit KeeWeb', click: closeMainWindow}
]);
appIcon.setContextMenu(contextMenu);
appIcon.setToolTip('KeeWeb');
}
};
app.minimizeThenHideIfInTray = function () {
// This function is called when auto-type has displayed a selection list and a selection was made.
// To ensure focus returns to the previous window we must minimize first even if we're going to hide.
mainWindow.minimize();
if (appIcon) mainWindow.hide();
};
app.getMainWindow = function () {
return mainWindow;