Merge branch 'master' into dev
This commit is contained in:
22
src/main.js
22
src/main.js
@@ -2,6 +2,9 @@
|
||||
|
||||
const electron = require('electron');
|
||||
const app = electron.app; // Module to control application life.
|
||||
|
||||
if (require('electron-squirrel-startup')) app.quit();
|
||||
|
||||
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
|
||||
const Menu = electron.Menu;
|
||||
const Tray = electron.Tray;
|
||||
@@ -13,6 +16,7 @@ const path = require('path');
|
||||
var settings = require('./common/settings');
|
||||
var certificateStore = require('./main/certificateStore').load(path.resolve(app.getPath('userData'), 'certificate.json'));
|
||||
var appMenu = require('./main/menus/app');
|
||||
const allowProtocolDialog = require('./main/allowProtocolDialog');
|
||||
|
||||
var argv = require('yargs').argv;
|
||||
|
||||
@@ -161,6 +165,8 @@ app.on('login', function(event, webContents, request, authInfo, callback) {
|
||||
mainWindow.webContents.send('login-request', request, authInfo);
|
||||
});
|
||||
|
||||
allowProtocolDialog.init(mainWindow);
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
app.on('ready', function() {
|
||||
@@ -168,11 +174,12 @@ app.on('ready', function() {
|
||||
// set up tray icon
|
||||
trayIcon = new Tray(trayImages.normal);
|
||||
trayIcon.setToolTip(app.getName());
|
||||
var tray_menu = require('./main/menus/tray').createDefault();
|
||||
trayIcon.setContextMenu(tray_menu);
|
||||
trayIcon.on('click', function() {
|
||||
mainWindow.focus();
|
||||
});
|
||||
trayIcon.on('right-click', () => {
|
||||
trayIcon.popUpContextMenu();
|
||||
});
|
||||
trayIcon.on('balloon-click', function() {
|
||||
mainWindow.focus();
|
||||
});
|
||||
@@ -194,12 +201,15 @@ app.on('ready', function() {
|
||||
|
||||
if (arg.mentionCount > 0) {
|
||||
trayIcon.setImage(trayImages.mention);
|
||||
trayIcon.setToolTip(arg.mentionCount + ' unread mentions');
|
||||
}
|
||||
else if (arg.unreadCount > 0) {
|
||||
trayIcon.setImage(trayImages.unread);
|
||||
trayIcon.setToolTip(arg.unreadCount + ' unread channels');
|
||||
}
|
||||
else {
|
||||
trayIcon.setImage(trayImages.normal);
|
||||
trayIcon.setToolTip(app.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -218,7 +228,7 @@ app.on('ready', function() {
|
||||
// On HiDPI Windows environment, the taskbar icon is pixelated. So this line is necessary.
|
||||
window_options.icon = path.resolve(__dirname, 'resources/appicon.png');
|
||||
}
|
||||
window_options.fullScreenable = true;
|
||||
window_options.title = app.getName();
|
||||
mainWindow = new BrowserWindow(window_options);
|
||||
mainWindow.setFullScreenable(true); // fullscreenable option has no effect.
|
||||
if (window_options.maximized) {
|
||||
@@ -238,6 +248,12 @@ app.on('ready', function() {
|
||||
});
|
||||
ipc.emit('update-menu', true, config);
|
||||
|
||||
// set up context menu for tray icon
|
||||
if (shouldShowTrayIcon()) {
|
||||
const tray_menu = require('./main/menus/tray').createDefault(mainWindow);
|
||||
trayIcon.setContextMenu(tray_menu);
|
||||
}
|
||||
|
||||
// Open the DevTools.
|
||||
// mainWindow.openDevTools();
|
||||
|
||||
|
Reference in New Issue
Block a user