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

mac menubar icon (wip)

This commit is contained in:
antelle 2017-12-04 22:33:40 +01:00
parent e477a6a3e6
commit 0e148594fb
2 changed files with 21 additions and 11 deletions

View File

@ -88,18 +88,24 @@ app.openWindow = function (opts) {
return new electron.BrowserWindow(opts); return new electron.BrowserWindow(opts);
}; };
app.minimizeApp = function () { app.minimizeApp = function () {
if (process.platform !== 'darwin') { let imagePath;
mainWindow.minimize(); if (process.platform === 'darwin') {
mainWindow.setSkipTaskbar(true); mainWindow.hide();
appIcon = new electron.Tray(path.join(__dirname, 'icon.png')); app.dock.hide();
appIcon.on('click', restoreMainWindow); imagePath = 'mac-menubar-icon.png';
const contextMenu = electron.Menu.buildFromTemplate([ } else {
{label: 'Open KeeWeb', click: restoreMainWindow}, imagePath = 'icon.png';
{label: 'Quit KeeWeb', click: closeMainWindow}
]);
appIcon.setContextMenu(contextMenu);
appIcon.setToolTip('KeeWeb');
} }
mainWindow.setSkipTaskbar(true);
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.getMainWindow = function () { app.getMainWindow = function () {
return mainWindow; return mainWindow;
@ -176,6 +182,10 @@ function createMainWindow() {
} }
function restoreMainWindow() { function restoreMainWindow() {
// if (process.platform === 'darwin') {
// app.dock.show();
// mainWindow.show();
// }
if (mainWindow.isMinimized()) { if (mainWindow.isMinimized()) {
mainWindow.restore(); mainWindow.restore();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB