first implementation for flash notification and settings to configure these
This commit is contained in:
@@ -49,7 +49,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') {
|
||||||
@@ -96,6 +99,13 @@ var SettingsPage = React.createClass({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleFlashWindowSetting: function(item) {
|
||||||
|
this.setState({
|
||||||
|
notifications: {
|
||||||
|
flashWindow: item.state
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
var buttonStyle = {
|
var buttonStyle = {
|
||||||
@@ -136,6 +146,40 @@ var SettingsPage = React.createClass({
|
|||||||
</Row>
|
</Row>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
|
var notificationSettings = [
|
||||||
|
{
|
||||||
|
label: 'Never',
|
||||||
|
state: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
{ notificationElements }
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid className="settingsPage">
|
<Grid className="settingsPage">
|
||||||
<Row>
|
<Row>
|
||||||
@@ -150,6 +194,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>
|
||||||
|
@@ -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
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -189,6 +189,10 @@ app.on('ready', function() {
|
|||||||
title: arg.title,
|
title: arg.title,
|
||||||
content: arg.options.body
|
content: arg.options.body
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (config.notifications.flashWindow == 2) {
|
||||||
|
mainWindow.flashFrame(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set overlay icon from dataURL
|
// Set overlay icon from dataURL
|
||||||
@@ -209,6 +213,7 @@ app.on('ready', function() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trayIcon.setImage(trayImages.normal);
|
trayIcon.setImage(trayImages.normal);
|
||||||
|
mainWindow.flashFrame(false);
|
||||||
trayIcon.setToolTip(app.getName());
|
trayIcon.setToolTip(app.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user