Skip to content

Commit

Permalink
feat(tray): tray hide on closing #32
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed May 29, 2018
1 parent 4f60539 commit d7d3939
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 5 deletions.
20 changes: 20 additions & 0 deletions src/app/config-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down
16 changes: 14 additions & 2 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -260,6 +271,7 @@ app.on("window-all-closed", () => {
});

app.on('before-quit', () => {
app.isQuiting = true
if (sphinx)
stop()
})
3 changes: 3 additions & 0 deletions src/background/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ let config = {

upnp: true,

trayOnClose: false,
trayOnMinimize: true,

sitemapMaxSize: 25000,

sphinx: {
Expand Down
4 changes: 3 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
"We are not responsible for any content": "We are not responsible for any content",
"this is only information about content that collected automatically": "this is only information about content that collected automatically",
"no torrents for": "no torrents for",
"were found": "were found"
"were found": "were found",
"Hide to tray on application minimize": "Hide to tray on application minimize",
"Hide to tray on application close": "Hide to tray on application close"
}
}
4 changes: 3 additions & 1 deletion translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
"We are not responsible for any content": "Мы не несем отвественность за контент",
"this is only information about content that collected automatically": "это лишь информация, собранная автоматически",
"no torrents for": "0 торрентов для",
"were found": "было найдено"
"were found": "было найдено",
"Hide to tray on application minimize": "Сворачивать в трей при сворачивании приложения",
"Hide to tray on application close": "Сворачивать в трей при закрытии приложения"
}
}
4 changes: 3 additions & 1 deletion translations/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@
"We are not responsible for any content": "Ми не несемо відповідальність за контент",
"this is only information about content that collected automatically": "це лише інформація, яку зібрано автоматично",
"no torrents for": "0 торентів для",
"were found": "було знайдено"
"were found": "було знайдено",
"Hide to tray on application minimize": "Hide to tray on application minimize",
"Hide to tray on application close": "Hide to tray on application close"
}
}

0 comments on commit d7d3939

Please sign in to comment.