diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 37 | ||||
-rw-r--r-- | src/lib/Tray.js | 24 |
2 files changed, 43 insertions, 18 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 8a5af56fb..4f0041be6 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -27,6 +27,7 @@ import { workspaceActions } from '../features/workspaces/actions'; | |||
27 | import { workspaceStore } from '../features/workspaces/index'; | 27 | import { workspaceStore } from '../features/workspaces/index'; |
28 | import apiBase, { termsBase } from '../api/apiBase'; | 28 | import apiBase, { termsBase } from '../api/apiBase'; |
29 | import { openExternalUrl } from '../helpers/url-helpers'; | 29 | import { openExternalUrl } from '../helpers/url-helpers'; |
30 | import globalMessages from '../i18n/globalMessages'; | ||
30 | 31 | ||
31 | const menuItems = defineMessages({ | 32 | const menuItems = defineMessages({ |
32 | edit: { | 33 | edit: { |
@@ -254,10 +255,6 @@ const menuItems = defineMessages({ | |||
254 | id: 'menu.app.autohideMenuBar', | 255 | id: 'menu.app.autohideMenuBar', |
255 | defaultMessage: '!!!Auto-hide menu bar', | 256 | defaultMessage: '!!!Auto-hide menu bar', |
256 | }, | 257 | }, |
257 | quit: { | ||
258 | id: 'menu.app.quit', | ||
259 | defaultMessage: '!!!Quit', | ||
260 | }, | ||
261 | addNewService: { | 258 | addNewService: { |
262 | id: 'menu.services.addNewService', | 259 | id: 'menu.services.addNewService', |
263 | defaultMessage: '!!!Add New Service...', | 260 | defaultMessage: '!!!Add New Service...', |
@@ -599,6 +596,23 @@ export default class FranzMenu { | |||
599 | const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); | 596 | const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); |
600 | const { actions } = this; | 597 | const { actions } = this; |
601 | 598 | ||
599 | // TODO: Extract this into a reusable component and remove the duplications | ||
600 | const quitApp = () => { | ||
601 | const yesButtonIndex = 0; | ||
602 | let selection = yesButtonIndex; | ||
603 | if (window.ferdi.stores.settings.app.confirmOnQuit) { | ||
604 | selection = dialog.showMessageBoxSync(app.mainWindow, { | ||
605 | type: 'question', | ||
606 | message: intl.formatMessage(globalMessages.quit), | ||
607 | detail: intl.formatMessage(globalMessages.quitConfirmation), | ||
608 | buttons: [intl.formatMessage(globalMessages.yes), intl.formatMessage(globalMessages.no)], | ||
609 | }); | ||
610 | } | ||
611 | if (selection === yesButtonIndex) { | ||
612 | app.quit(); | ||
613 | } | ||
614 | }; | ||
615 | |||
602 | if (!isMac) { | 616 | if (!isMac) { |
603 | tpl[1].submenu.push({ | 617 | tpl[1].submenu.push({ |
604 | label: intl.formatMessage(menuItems.autohideMenuBar), | 618 | label: intl.formatMessage(menuItems.autohideMenuBar), |
@@ -801,11 +815,9 @@ export default class FranzMenu { | |||
801 | type: 'separator', | 815 | type: 'separator', |
802 | }, | 816 | }, |
803 | { | 817 | { |
804 | label: intl.formatMessage(menuItems.quit), | 818 | label: intl.formatMessage(globalMessages.quit), |
805 | role: 'quit', | 819 | accelerator: `${cmdOrCtrlShortcutKey()}+Q`, |
806 | click() { | 820 | click: quitApp, |
807 | app.quit(); | ||
808 | }, | ||
809 | }, | 821 | }, |
810 | ], | 822 | ], |
811 | }); | 823 | }); |
@@ -862,12 +874,9 @@ export default class FranzMenu { | |||
862 | type: 'separator', | 874 | type: 'separator', |
863 | }, | 875 | }, |
864 | { | 876 | { |
865 | label: intl.formatMessage(menuItems.quit), | 877 | label: intl.formatMessage(globalMessages.quit), |
866 | role: 'quit', | ||
867 | accelerator: `${cmdOrCtrlShortcutKey()}+Q`, | 878 | accelerator: `${cmdOrCtrlShortcutKey()}+Q`, |
868 | click() { | 879 | click: quitApp, |
869 | app.quit(); | ||
870 | }, | ||
871 | }, | 880 | }, |
872 | ]; | 881 | ]; |
873 | 882 | ||
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index f5970f7e7..c897d597a 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -1,5 +1,5 @@ | |||
1 | import { | 1 | import { |
2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, dialog, |
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import { join } from 'path'; | 4 | import { join } from 'path'; |
5 | import macosVersion from 'macos-version'; | 5 | import macosVersion from 'macos-version'; |
@@ -43,9 +43,7 @@ export default class TrayIcon { | |||
43 | }, | 43 | }, |
44 | { | 44 | { |
45 | label: 'Quit Ferdi', | 45 | label: 'Quit Ferdi', |
46 | click() { | 46 | click: this.quitApp, |
47 | app.quit(); | ||
48 | }, | ||
49 | }, | 47 | }, |
50 | ]; | 48 | ]; |
51 | 49 | ||
@@ -178,4 +176,22 @@ export default class TrayIcon { | |||
178 | __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, | 176 | __dirname, '..', 'assets', 'images', type, platform, `${asset}.${FILE_EXTENSION}`, |
179 | )); | 177 | )); |
180 | } | 178 | } |
179 | |||
180 | // TODO: Extract this into a reusable component and remove the duplications | ||
181 | quitApp = () => { | ||
182 | const yesButtonIndex = 0; | ||
183 | let selection = yesButtonIndex; | ||
184 | if (window.ferdi.stores.settings.app.confirmOnQuit) { | ||
185 | selection = dialog.showMessageBoxSync(app.mainWindow, { | ||
186 | // TODO: Externalize strings | ||
187 | type: 'question', | ||
188 | message: 'Quit', | ||
189 | detail: 'Do you really want to quit Ferdi?', | ||
190 | buttons: ['Yes', 'No'], | ||
191 | }); | ||
192 | } | ||
193 | if (selection === yesButtonIndex) { | ||
194 | app.quit(); | ||
195 | } | ||
196 | }; | ||
181 | } | 197 | } |