Merge pull request #159 from MetalCar/blinkNotification
This commit is contained in:
commit
3061598935
|
@ -64,7 +64,10 @@ var SettingsPage = React.createClass({
|
||||||
showTrayIcon: this.state.showTrayIcon,
|
showTrayIcon: this.state.showTrayIcon,
|
||||||
trayIconTheme: this.state.trayIconTheme,
|
trayIconTheme: this.state.trayIconTheme,
|
||||||
disablewebsecurity: this.state.disablewebsecurity,
|
disablewebsecurity: this.state.disablewebsecurity,
|
||||||
version: settings.version
|
version: settings.version,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: this.state.notifications.flashWindow
|
||||||
|
}
|
||||||
};
|
};
|
||||||
settings.writeFileSync(this.props.configFile, config);
|
settings.writeFileSync(this.props.configFile, config);
|
||||||
if (process.platform === 'win32' || process.platform === 'linux') {
|
if (process.platform === 'win32' || process.platform === 'linux') {
|
||||||
|
@ -125,6 +128,13 @@ var SettingsPage = React.createClass({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleFlashWindowSetting: function(item) {
|
||||||
|
this.setState({
|
||||||
|
notifications: {
|
||||||
|
flashWindow: item.state
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
var buttonStyle = {
|
var buttonStyle = {
|
||||||
|
@ -169,6 +179,40 @@ var SettingsPage = React.createClass({
|
||||||
</Row>
|
</Row>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
|
var notificationSettings = [
|
||||||
|
{
|
||||||
|
label: 'Never',
|
||||||
|
state: 0
|
||||||
|
},
|
||||||
|
/* ToDo: Idle isn't implemented yet
|
||||||
|
{
|
||||||
|
label: 'Only when idle (after 10 seconds)',
|
||||||
|
state: 1
|
||||||
|
},*/
|
||||||
|
{
|
||||||
|
label: 'Always',
|
||||||
|
state: 2
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
var notificationElements = notificationSettings.map(function(item) {
|
||||||
|
var boundClick = that.handleFlashWindowSetting.bind(that, item);
|
||||||
|
return (
|
||||||
|
<Input key={ "flashWindow" + item.state } name="handleFlashWindow" ref={ "flashWindow" + item.state } type="radio" label={ item.label } value={ item.state } onChange={ boundClick }
|
||||||
|
checked={ that.state.notifications.flashWindow == item.state ? "checked" : "" } />
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
var notifications = (
|
||||||
|
<Row>
|
||||||
|
<Col md={ 12 }>
|
||||||
|
<h2>Notifications</h2> Configure, that the taskicon in the taskbar blinks when you were mentioned.
|
||||||
|
{ notificationElements }
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid className="settingsPage">
|
<Grid className="settingsPage">
|
||||||
<Row>
|
<Row>
|
||||||
|
@ -183,6 +227,10 @@ var SettingsPage = React.createClass({
|
||||||
</Row>
|
</Row>
|
||||||
{ teams_row }
|
{ teams_row }
|
||||||
{ options_row }
|
{ options_row }
|
||||||
|
{ notifications }
|
||||||
|
<div>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
<Row>
|
<Row>
|
||||||
<Col md={ 12 }>
|
<Col md={ 12 }>
|
||||||
<Button id="btnCancel" onClick={ this.handleCancel }>Cancel</Button>
|
<Button id="btnCancel" onClick={ this.handleCancel }>Cancel</Button>
|
||||||
|
|
|
@ -97,39 +97,23 @@ function isElementVisible(elem) {
|
||||||
return elem.offsetHeight !== 0;
|
return elem.offsetHeight !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Windows 8.1 and Windows 8, a shortcut with a Application User Model ID must be installed to the Start screen.
|
notification.override({
|
||||||
// In current version, use tray balloon for notification
|
// Send a notification event to the main process.
|
||||||
function isLowerThanOrEqualWindows8_1() {
|
notification: function(title, options) {
|
||||||
if (process.platform != 'win32') {
|
ipc.send('notified', {
|
||||||
return false;
|
title: title,
|
||||||
}
|
options: options
|
||||||
var osVersion = require('../../common/osVersion');
|
});
|
||||||
return (osVersion.major <= 6 && osVersion.minor <= 3);
|
},
|
||||||
};
|
|
||||||
|
|
||||||
if (process.platform === 'win32' && isLowerThanOrEqualWindows8_1()) {
|
|
||||||
// Show balloon when notified.
|
|
||||||
notification.override({
|
|
||||||
notification: function(title, options) {
|
|
||||||
ipc.send('notified', {
|
|
||||||
title: title,
|
|
||||||
options: options
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Show window even if it is hidden/minimized when notification is clicked.
|
// Show window even if it is hidden/minimized when notification is clicked.
|
||||||
notification.override({
|
onclick: function() {
|
||||||
onclick: function() {
|
if (process.platform === 'win32') {
|
||||||
if (process.platform === 'win32') {
|
// show() breaks Aero Snap state.
|
||||||
// show() breaks Aero Snap state.
|
electron.remote.getCurrentWindow().focus();
|
||||||
electron.remote.getCurrentWindow().focus();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
electron.remote.getCurrentWindow().show();
|
|
||||||
}
|
|
||||||
ipc.sendToHost('onNotificationClick');
|
|
||||||
}
|
}
|
||||||
});
|
else {
|
||||||
}
|
electron.remote.getCurrentWindow().show();
|
||||||
|
}
|
||||||
|
ipc.sendToHost('onNotificationClick');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -3,5 +3,12 @@ var release_split = os.release().split('.');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
major: parseInt(release_split[0]),
|
major: parseInt(release_split[0]),
|
||||||
minor: parseInt(release_split[1])
|
minor: parseInt(release_split[1]),
|
||||||
|
isLowerThanOrEqualWindows8_1: function() {
|
||||||
|
if (process.platform != 'win32') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// consider Windows 7 and later.
|
||||||
|
return (this.major <= 6 && this.minor <= 3);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,10 @@ var loadDefault = function(version) {
|
||||||
showTrayIcon: false,
|
showTrayIcon: false,
|
||||||
trayIconTheme: '',
|
trayIconTheme: '',
|
||||||
disablewebsecurity: true,
|
disablewebsecurity: true,
|
||||||
version: 1
|
version: 1,
|
||||||
|
notifications: {
|
||||||
|
flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
src/main.js
20
src/main.js
|
@ -28,6 +28,7 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
var settings = require('./common/settings');
|
var settings = require('./common/settings');
|
||||||
|
const osVersion = require('./common/osVersion');
|
||||||
var certificateStore = require('./main/certificateStore').load(path.resolve(app.getPath('userData'), 'certificate.json'));
|
var certificateStore = require('./main/certificateStore').load(path.resolve(app.getPath('userData'), 'certificate.json'));
|
||||||
var appMenu = require('./main/menus/app');
|
var appMenu = require('./main/menus/app');
|
||||||
const allowProtocolDialog = require('./main/allowProtocolDialog');
|
const allowProtocolDialog = require('./main/allowProtocolDialog');
|
||||||
|
@ -198,11 +199,20 @@ app.on('ready', function() {
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
});
|
});
|
||||||
ipc.on('notified', function(event, arg) {
|
ipc.on('notified', function(event, arg) {
|
||||||
trayIcon.displayBalloon({
|
if (process.platform === 'win32') {
|
||||||
icon: path.resolve(__dirname, 'resources/appicon.png'),
|
if (config.notifications.flashWindow === 2) {
|
||||||
title: arg.title,
|
mainWindow.flashFrame(true);
|
||||||
content: arg.options.body
|
}
|
||||||
});
|
// On Windows 8.1 and Windows 8, a shortcut with a Application User Model ID must be installed to the Start screen.
|
||||||
|
// In current version, use tray balloon for notification
|
||||||
|
if (osVersion.isLowerThanOrEqualWindows8_1()) {
|
||||||
|
trayIcon.displayBalloon({
|
||||||
|
icon: path.resolve(__dirname, 'resources/appicon.png'),
|
||||||
|
title: arg.title,
|
||||||
|
content: arg.options.body
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set overlay icon from dataURL
|
// Set overlay icon from dataURL
|
||||||
|
|
Loading…
Reference in a new issue