From 50a95aeb721142abc29e008f953c515ed5086364 Mon Sep 17 00:00:00 2001 From: Alexey Kasyanchuk Date: Tue, 29 May 2018 14:48:48 +0300 Subject: [PATCH] feat(tray): tray hide on closing #32 --- src/app/config-page.js | 20 ++++++++++++++++++++ src/background/background.js | 16 ++++++++++++++-- src/background/config.js | 3 +++ translations/en.json | 4 +++- translations/ru.json | 4 +++- translations/ua.json | 4 +++- 6 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/app/config-page.js b/src/app/config-page.js index f538181..e6f4ad8 100644 --- a/src/app/config-page.js +++ b/src/app/config-page.js @@ -161,6 +161,26 @@ export default class ConfigPage extends Page { }} /> + { + this.options.trayOnMinimize = checked + this.forceUpdate() + }} + /> + + { + this.options.trayOnClose = checked + this.forceUpdate() + }} + /> +
{__('P2P Rats network settings')}:
{ 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() }) \ No newline at end of file diff --git a/src/background/config.js b/src/background/config.js index 4bf53ce..c48b6ff 100644 --- a/src/background/config.js +++ b/src/background/config.js @@ -19,6 +19,9 @@ let config = { upnp: true, + trayOnClose: false, + trayOnMinimize: true, + sitemapMaxSize: 25000, sphinx: { diff --git a/translations/en.json b/translations/en.json index 5e441e7..d695cc3 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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" } } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index 54ab761..5feb4d5 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -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": "Сворачивать в трей при закрытии приложения" } } \ No newline at end of file diff --git a/translations/ua.json b/translations/ua.json index 79602c7..5aafae6 100644 --- a/translations/ua.json +++ b/translations/ua.json @@ -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" } } \ No newline at end of file