diff options
Diffstat (limited to 'src/lib/Menu.js')
-rw-r--r-- | src/lib/Menu.js | 104 |
1 files changed, 90 insertions, 14 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 91e7c981a..4547e84f9 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -10,8 +10,9 @@ import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; | |||
10 | import { workspaceActions } from '../features/workspaces/actions'; | 10 | import { workspaceActions } from '../features/workspaces/actions'; |
11 | import { workspaceStore } from '../features/workspaces/index'; | 11 | import { workspaceStore } from '../features/workspaces/index'; |
12 | 12 | ||
13 | 13 | const { | |
14 | const { app, Menu, dialog } = remote; | 14 | app, Menu, dialog, systemPreferences, |
15 | } = remote; | ||
15 | 16 | ||
16 | const menuItems = defineMessages({ | 17 | const menuItems = defineMessages({ |
17 | edit: { | 18 | edit: { |
@@ -50,6 +51,10 @@ const menuItems = defineMessages({ | |||
50 | id: 'menu.edit.selectAll', | 51 | id: 'menu.edit.selectAll', |
51 | defaultMessage: '!!!Select All', | 52 | defaultMessage: '!!!Select All', |
52 | }, | 53 | }, |
54 | findInPage: { | ||
55 | id: 'menu.edit.findInPage', | ||
56 | defaultMessage: '!!!Find in Page', | ||
57 | }, | ||
53 | speech: { | 58 | speech: { |
54 | id: 'menu.edit.speech', | 59 | id: 'menu.edit.speech', |
55 | defaultMessage: '!!!Speech', | 60 | defaultMessage: '!!!Speech', |
@@ -166,6 +171,14 @@ const menuItems = defineMessages({ | |||
166 | id: 'menu.help.debugInfoCopiedBody', | 171 | id: 'menu.help.debugInfoCopiedBody', |
167 | defaultMessage: '!!!Your Debug Information has been copied to your clipboard.', | 172 | defaultMessage: '!!!Your Debug Information has been copied to your clipboard.', |
168 | }, | 173 | }, |
174 | touchId: { | ||
175 | id: 'locked.touchId', | ||
176 | defaultMessage: '!!!Unlock with Touch ID', | ||
177 | }, | ||
178 | touchIdPrompt: { | ||
179 | id: 'locked.touchIdPrompt', | ||
180 | defaultMessage: '!!!unlock via Touch ID', | ||
181 | }, | ||
169 | tos: { | 182 | tos: { |
170 | id: 'menu.help.tos', | 183 | id: 'menu.help.tos', |
171 | defaultMessage: '!!!Terms of Service', | 184 | defaultMessage: '!!!Terms of Service', |
@@ -367,6 +380,27 @@ const _templateFactory = (intl, locked) => [ | |||
367 | type: 'separator', | 380 | type: 'separator', |
368 | }, | 381 | }, |
369 | { | 382 | { |
383 | label: intl.formatMessage(menuItems.findInPage), | ||
384 | accelerator: 'CmdOrCtrl+F', | ||
385 | click() { | ||
386 | // Check if there is a service active | ||
387 | if (!window.ferdi.stores.services.active) return; | ||
388 | |||
389 | // Focus webview so find in page popup gets focused | ||
390 | window.ferdi.stores.services.active.webview.focus(); | ||
391 | |||
392 | const currentService = window.ferdi.stores.services.active.id; | ||
393 | window.ferdi.actions.service.sendIPCMessage({ | ||
394 | serviceId: currentService, | ||
395 | channel: 'find-in-page', | ||
396 | args: {}, | ||
397 | }); | ||
398 | }, | ||
399 | }, | ||
400 | { | ||
401 | type: 'separator', | ||
402 | }, | ||
403 | { | ||
370 | label: intl.formatMessage(menuItems.back), | 404 | label: intl.formatMessage(menuItems.back), |
371 | accelerator: 'CmdOrCtrl+Left', | 405 | accelerator: 'CmdOrCtrl+Left', |
372 | click() { | 406 | click() { |
@@ -575,6 +609,27 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
575 | type: 'separator', | 609 | type: 'separator', |
576 | }, | 610 | }, |
577 | { | 611 | { |
612 | label: intl.formatMessage(menuItems.findInPage), | ||
613 | accelerator: 'CmdOrCtrl+F', | ||
614 | click() { | ||
615 | // Check if there is a service active | ||
616 | if (!window.ferdi.stores.services.active) return; | ||
617 | |||
618 | // Focus webview so find in page popup gets focused | ||
619 | window.ferdi.stores.services.active.webview.focus(); | ||
620 | |||
621 | const currentService = window.ferdi.stores.services.active.id; | ||
622 | window.ferdi.actions.service.sendIPCMessage({ | ||
623 | serviceId: currentService, | ||
624 | channel: 'find-in-page', | ||
625 | args: {}, | ||
626 | }); | ||
627 | }, | ||
628 | }, | ||
629 | { | ||
630 | type: 'separator', | ||
631 | }, | ||
632 | { | ||
578 | label: intl.formatMessage(menuItems.back), | 633 | label: intl.formatMessage(menuItems.back), |
579 | accelerator: 'CmdOrCtrl+Left', | 634 | accelerator: 'CmdOrCtrl+Left', |
580 | click() { | 635 | click() { |
@@ -755,7 +810,7 @@ export default class FranzMenu { | |||
755 | : _titleBarTemplateFactory(intl, this.stores.settings.app.locked); | 810 | : _titleBarTemplateFactory(intl, this.stores.settings.app.locked); |
756 | const { actions } = this; | 811 | const { actions } = this; |
757 | 812 | ||
758 | if (this.stores.settings.app.locked) { | 813 | if (!this.stores.settings.app.locked) { |
759 | tpl[1].submenu.push({ | 814 | tpl[1].submenu.push({ |
760 | type: 'separator', | 815 | type: 'separator', |
761 | }, { | 816 | }, { |
@@ -819,7 +874,7 @@ export default class FranzMenu { | |||
819 | locked: true, | 874 | locked: true, |
820 | }, | 875 | }, |
821 | }); | 876 | }); |
822 | } | 877 | }, |
823 | }); | 878 | }); |
824 | 879 | ||
825 | if (serviceTpl.length > 0) { | 880 | if (serviceTpl.length > 0) { |
@@ -833,6 +888,27 @@ export default class FranzMenu { | |||
833 | if (todosStore.isFeatureEnabled) { | 888 | if (todosStore.isFeatureEnabled) { |
834 | tpl[5].submenu = this.todosMenu(); | 889 | tpl[5].submenu = this.todosMenu(); |
835 | } | 890 | } |
891 | } else { | ||
892 | const touchIdEnabled = this.stores.settings.app.useTouchIdToUnlock && systemPreferences.canPromptTouchID(); | ||
893 | |||
894 | tpl[0].submenu.unshift({ | ||
895 | label: intl.formatMessage(menuItems.touchId), | ||
896 | accelerator: 'CmdOrCtrl+Shift+L', | ||
897 | visible: touchIdEnabled, | ||
898 | click() { | ||
899 | systemPreferences.promptTouchID(intl.formatMessage(menuItems.touchIdPrompt)).then(() => { | ||
900 | actions.settings.update({ | ||
901 | type: 'app', | ||
902 | data: { | ||
903 | locked: false, | ||
904 | }, | ||
905 | }); | ||
906 | }); | ||
907 | }, | ||
908 | }, { | ||
909 | type: 'separator', | ||
910 | visible: touchIdEnabled, | ||
911 | }); | ||
836 | } | 912 | } |
837 | 913 | ||
838 | tpl.unshift({ | 914 | tpl.unshift({ |
@@ -964,19 +1040,19 @@ export default class FranzMenu { | |||
964 | }, about); | 1040 | }, about); |
965 | } | 1041 | } |
966 | 1042 | ||
967 | if (serviceTpl.length > 0) { | 1043 | if (!this.stores.settings.app.locked) { |
968 | tpl[3].submenu = serviceTpl; | 1044 | if (serviceTpl.length > 0) { |
969 | } | 1045 | tpl[3].submenu = serviceTpl; |
1046 | } | ||
970 | 1047 | ||
971 | if (workspaceStore.isFeatureEnabled) { | 1048 | if (workspaceStore.isFeatureEnabled) { |
972 | tpl[4].submenu = this.workspacesMenu(); | 1049 | tpl[4].submenu = this.workspacesMenu(); |
973 | } | 1050 | } |
974 | 1051 | ||
975 | if (todosStore.isFeatureEnabled) { | 1052 | if (todosStore.isFeatureEnabled) { |
976 | tpl[5].submenu = this.todosMenu(); | 1053 | tpl[5].submenu = this.todosMenu(); |
977 | } | 1054 | } |
978 | 1055 | ||
979 | if (!this.stores.settings.app.locked) { | ||
980 | tpl[tpl.length - 1].submenu.push({ | 1056 | tpl[tpl.length - 1].submenu.push({ |
981 | type: 'separator', | 1057 | type: 'separator', |
982 | }, ...this.debugMenu()); | 1058 | }, ...this.debugMenu()); |