diff options
author | 2020-02-21 19:12:31 +0100 | |
---|---|---|
committer | 2020-02-21 19:12:31 +0100 | |
commit | d51c26c3cc6c61016fc1428f422148b498db5d10 (patch) | |
tree | a4ceaa003e470bb7147ebf2714b24f9763e7dae0 | |
parent | Replace deprecated call to getName, use name instead (diff) | |
parent | Make tray bring-to-top/show/hide on click, show menu on right click (diff) | |
download | ferdium-app-d51c26c3cc6c61016fc1428f422148b498db5d10.tar.gz ferdium-app-d51c26c3cc6c61016fc1428f422148b498db5d10.tar.zst ferdium-app-d51c26c3cc6c61016fc1428f422148b498db5d10.zip |
Merge pull request #390 from getferdi/refactor/tray
Refactor Tray behavior/settings
-rw-r--r-- | src/components/settings/settings/EditSettingsForm.js | 7 | ||||
-rw-r--r-- | src/containers/settings/EditSettingsScreen.js | 2 | ||||
-rw-r--r-- | src/i18n/locales/defaultMessages.json | 2 | ||||
-rw-r--r-- | src/i18n/messages/src/containers/settings/EditSettingsScreen.json | 2 | ||||
-rw-r--r-- | src/lib/Tray.js | 14 |
5 files changed, 16 insertions, 11 deletions
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js index 2797a2dce..6017252bc 100644 --- a/src/components/settings/settings/EditSettingsForm.js +++ b/src/components/settings/settings/EditSettingsForm.js | |||
@@ -252,6 +252,9 @@ export default @observer class EditSettingsForm extends Component { | |||
252 | <Toggle field={form.$('runInBackground')} /> | 252 | <Toggle field={form.$('runInBackground')} /> |
253 | <Toggle field={form.$('enableSystemTray')} /> | 253 | <Toggle field={form.$('enableSystemTray')} /> |
254 | {isTrayEnabled && <Toggle field={form.$('startMinimized')} />} | 254 | {isTrayEnabled && <Toggle field={form.$('startMinimized')} />} |
255 | {process.platform === 'win32' && ( | ||
256 | <Toggle field={form.$('minimizeToSystemTray')} /> | ||
257 | )} | ||
255 | <Toggle field={form.$('privateNotifications')} /> | 258 | <Toggle field={form.$('privateNotifications')} /> |
256 | <Toggle field={form.$('showServiceNavigationBar')} /> | 259 | <Toggle field={form.$('showServiceNavigationBar')} /> |
257 | 260 | ||
@@ -279,10 +282,6 @@ export default @observer class EditSettingsForm extends Component { | |||
279 | 282 | ||
280 | <Hr /> | 283 | <Hr /> |
281 | 284 | ||
282 | {process.platform === 'win32' && ( | ||
283 | <Toggle field={form.$('minimizeToSystemTray')} /> | ||
284 | )} | ||
285 | |||
286 | <Input | 285 | <Input |
287 | placeholder="Server" | 286 | placeholder="Server" |
288 | onChange={e => this.submit(e)} | 287 | onChange={e => this.submit(e)} |
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js index 595cfdcc7..8eb7c3b82 100644 --- a/src/containers/settings/EditSettingsScreen.js +++ b/src/containers/settings/EditSettingsScreen.js | |||
@@ -44,7 +44,7 @@ const messages = defineMessages({ | |||
44 | }, | 44 | }, |
45 | enableSystemTray: { | 45 | enableSystemTray: { |
46 | id: 'settings.app.form.enableSystemTray', | 46 | id: 'settings.app.form.enableSystemTray', |
47 | defaultMessage: '!!!Show Ferdi in system tray', | 47 | defaultMessage: '!!!Always show Ferdi in system tray', |
48 | }, | 48 | }, |
49 | minimizeToSystemTray: { | 49 | minimizeToSystemTray: { |
50 | id: 'settings.app.form.minimizeToSystemTray', | 50 | id: 'settings.app.form.minimizeToSystemTray', |
diff --git a/src/i18n/locales/defaultMessages.json b/src/i18n/locales/defaultMessages.json index 6ac9153a4..17f77b609 100644 --- a/src/i18n/locales/defaultMessages.json +++ b/src/i18n/locales/defaultMessages.json | |||
@@ -4136,7 +4136,7 @@ | |||
4136 | } | 4136 | } |
4137 | }, | 4137 | }, |
4138 | { | 4138 | { |
4139 | "defaultMessage": "!!!Show Ferdi in system tray", | 4139 | "defaultMessage": "!!!Always show Ferdi in system tray", |
4140 | "end": { | 4140 | "end": { |
4141 | "column": 3, | 4141 | "column": 3, |
4142 | "line": 48 | 4142 | "line": 48 |
diff --git a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json index 22417f340..d2e53d625 100644 --- a/src/i18n/messages/src/containers/settings/EditSettingsScreen.json +++ b/src/i18n/messages/src/containers/settings/EditSettingsScreen.json | |||
@@ -53,7 +53,7 @@ | |||
53 | }, | 53 | }, |
54 | { | 54 | { |
55 | "id": "settings.app.form.enableSystemTray", | 55 | "id": "settings.app.form.enableSystemTray", |
56 | "defaultMessage": "!!!Show Ferdi in system tray", | 56 | "defaultMessage": "!!!Always show Ferdi in system tray", |
57 | "file": "src/containers/settings/EditSettingsScreen.js", | 57 | "file": "src/containers/settings/EditSettingsScreen.js", |
58 | "start": { | 58 | "start": { |
59 | "line": 45, | 59 | "line": 45, |
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index c0d936599..84ee8e3bb 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -1,5 +1,5 @@ | |||
1 | import { | 1 | import { |
2 | app, Tray, Menu, systemPreferences, nativeTheme, nativeImage, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, |
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | 5 | ||
@@ -37,14 +37,20 @@ export default class TrayIcon { | |||
37 | ]; | 37 | ]; |
38 | 38 | ||
39 | const trayMenu = Menu.buildFromTemplate(trayMenuTemplate); | 39 | const trayMenu = Menu.buildFromTemplate(trayMenuTemplate); |
40 | this.trayIcon.setContextMenu(trayMenu); | ||
41 | 40 | ||
42 | this.trayIcon.on('click', () => { | 41 | this.trayIcon.on('click', () => { |
43 | if (app.mainWindow.isMinimized()) { | 42 | if (app.mainWindow.isMinimized()) { |
44 | app.mainWindow.restore(); | 43 | app.mainWindow.restore(); |
44 | } else if (app.mainWindow.isVisible()) { | ||
45 | app.mainWindow.hide(); | ||
46 | } else { | ||
47 | app.mainWindow.show(); | ||
48 | app.mainWindow.focus(); | ||
45 | } | 49 | } |
46 | app.mainWindow.show(); | 50 | }); |
47 | app.mainWindow.focus(); | 51 | |
52 | this.trayIcon.on('right-click', () => { | ||
53 | this.trayIcon.popUpContextMenu(trayMenu); | ||
48 | }); | 54 | }); |
49 | 55 | ||
50 | if (process.platform === 'darwin') { | 56 | if (process.platform === 'darwin') { |