feat(tray): tray hide on closing #32

This commit is contained in:
Alexey Kasyanchuk
2018-05-29 14:48:48 +03:00
parent ae8b84fed6
commit 50a95aeb72
6 changed files with 46 additions and 5 deletions

View File

@ -161,6 +161,26 @@ export default class ConfigPage extends Page {
}} />
</div>
<Toggle
style={{marginTop: '10px'}}
label={__('Hide to tray on application minimize')}
toggled={this.options.trayOnMinimize}
onToggle={(e, checked) => {
this.options.trayOnMinimize = checked
this.forceUpdate()
}}
/>
<Toggle
style={{marginTop: '10px'}}
label={__('Hide to tray on application close')}
toggled={this.options.trayOnClose}
onToggle={(e, checked) => {
this.options.trayOnClose = checked
this.forceUpdate()
}}
/>
<div style={{marginTop: 10}}>{__('P2P Rats network settings')}:</div>
<Toggle
style={{marginTop: '10px'}}

View File

@ -178,13 +178,24 @@ app.on("ready", () => {
mainWindow.on('hide', () => {
tray.setHighlightMode('never')
})
mainWindow.on('close', (event) => {
if (!app.isQuiting && appConfig.trayOnClose && process.platform !== 'linux') {
event.preventDefault()
mainWindow.hide()
return
}
})
mainWindow.on('closed', () => {
mainWindow = undefined
})
mainWindow.on('minimize', (event) => {
event.preventDefault();
mainWindow.hide();
if(appConfig.trayOnMinimize)
{
event.preventDefault();
mainWindow.hide();
}
});
var contextMenu = Menu.buildFromTemplate([
@ -260,6 +271,7 @@ app.on("window-all-closed", () => {
});
app.on('before-quit', () => {
app.isQuiting = true
if (sphinx)
stop()
})

View File

@ -19,6 +19,9 @@ let config = {
upnp: true,
trayOnClose: false,
trayOnMinimize: true,
sitemapMaxSize: 25000,
sphinx: {