Commit b542edc6 authored by dev0tion's avatar dev0tion

Fix left mouse button tray behavior and tray icon

parent 35a906bc
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
const app = electron.app; const app = electron.app;
// Module to create native browser window. // Module to create native browser window.
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
const nativeImage = require('electron').nativeImage
const path = require('path'); const path = require('path');
const url = require('url'); const url = require('url');
...@@ -181,36 +182,36 @@ function createTray() { ...@@ -181,36 +182,36 @@ function createTray() {
const Menu = electron.Menu; const Menu = electron.Menu;
const Tray = electron.Tray; const Tray = electron.Tray;
let appIcon = null; let trayIcon;
var iconPath
if (os.platform() === 'win32') {
if (serve) {
iconPath = '.\\src\\assets\\images\\breeze-logo-tray.ico';
} else {
iconPath = path.join(__dirname + '\\assets\\images\\breeze-logo-tray.png');
}
} else {
if (serve) { if (serve) {
iconPath = './src/assets/images/breeze-logo-tray.png'; trayIcon = nativeImage.createFromPath('./src/assets/images/breeze-logo.png');
} else { } else {
iconPath = path.join(__dirname + '//assets//images//breeze-logo-tray.png'); trayIcon = nativeImage.createFromPath('./assets/images/breeze-logo.png');
} }
}
appIcon = new Tray(iconPath); let systemTray = new Tray(trayIcon);
const contextMenu = Menu.buildFromTemplate([{ const contextMenu = Menu.buildFromTemplate([
{
label: 'Hide/Show', label: 'Hide/Show',
click: function () { click: function () {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show(); mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
} }
}]); }
appIcon.setToolTip('Breeze Wallet'); ]);
appIcon.setContextMenu(contextMenu); systemTray.setToolTip('Breeze Wallet');
systemTray.setContextMenu(contextMenu);
systemTray.on('click', function() {
if (!mainWindow.isVisible()) {
mainWindow.show();
}
if (!mainWindow.isFocused()) {
mainWindow.focus();
}
});
app.on('window-all-closed', function () { app.on('window-all-closed', function () {
if (appIcon) appIcon.destroy(); if (systemTray) systemTray.destroy();
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment