diff options
author | 2021-08-13 00:24:40 +0530 | |
---|---|---|
committer | 2021-08-13 00:24:40 +0530 | |
commit | 52dba987668f4962895e8298d8d32fe877240a76 (patch) | |
tree | 9ccbd1938ab9ee066918252347d7b87bad549529 /src/lib | |
parent | Fix error while importing without workspaces (#1776) (diff) | |
download | ferdium-app-52dba987668f4962895e8298d8d32fe877240a76.tar.gz ferdium-app-52dba987668f4962895e8298d8d32fe877240a76.tar.zst ferdium-app-52dba987668f4962895e8298d8d32fe877240a76.zip |
refactor: Use the 'shortcutKey' function without exposing the 'ctrlKey' or the 'cmdKey'
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index 21133bfde..e4056e536 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -6,7 +6,7 @@ import { autorun, observable } from 'mobx'; | |||
6 | import { defineMessages } from 'react-intl'; | 6 | import { defineMessages } from 'react-intl'; |
7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; | 7 | import { CUSTOM_WEBSITE_RECIPE_ID, GITHUB_FERDI_URL, LIVE_API_FERDI_WEBSITE } from '../config'; |
8 | import { | 8 | import { |
9 | cmdKey, altKey, shiftKey, settingsShortcutKey, isLinux, isMac, aboutAppDetails, lockFerdiShortcutKey, todosToggleShortcutKey, workspaceToggleShortcutKey, addNewServiceShortcutKey, muteFerdiShortcutKey, | 9 | shortcutKey, altKey, shiftKey, settingsShortcutKey, isLinux, isMac, aboutAppDetails, lockFerdiShortcutKey, todosToggleShortcutKey, workspaceToggleShortcutKey, addNewServiceShortcutKey, muteFerdiShortcutKey, |
10 | } from '../environment'; | 10 | } from '../environment'; |
11 | import { announcementsStore } from '../features/announcements'; | 11 | import { announcementsStore } from '../features/announcements'; |
12 | import { announcementActions } from '../features/announcements/actions'; | 12 | import { announcementActions } from '../features/announcements/actions'; |
@@ -333,22 +333,22 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
333 | }, | 333 | }, |
334 | { | 334 | { |
335 | label: intl.formatMessage(menuItems.cut), | 335 | label: intl.formatMessage(menuItems.cut), |
336 | accelerator: `${cmdKey}+X`, | 336 | accelerator: `${shortcutKey()}+X`, |
337 | role: 'cut', | 337 | role: 'cut', |
338 | }, | 338 | }, |
339 | { | 339 | { |
340 | label: intl.formatMessage(menuItems.copy), | 340 | label: intl.formatMessage(menuItems.copy), |
341 | accelerator: `${cmdKey}+C`, | 341 | accelerator: `${shortcutKey()}+C`, |
342 | role: 'copy', | 342 | role: 'copy', |
343 | }, | 343 | }, |
344 | { | 344 | { |
345 | label: intl.formatMessage(menuItems.paste), | 345 | label: intl.formatMessage(menuItems.paste), |
346 | accelerator: `${cmdKey}+V`, | 346 | accelerator: `${shortcutKey()}+V`, |
347 | role: 'paste', | 347 | role: 'paste', |
348 | }, | 348 | }, |
349 | { | 349 | { |
350 | label: intl.formatMessage(menuItems.pasteAndMatchStyle), | 350 | label: intl.formatMessage(menuItems.pasteAndMatchStyle), |
351 | accelerator: `${cmdKey}+${shiftKey}+V`, // Override the accelerator since this adds new key combo in macos | 351 | accelerator: `${shortcutKey()}+${shiftKey}+V`, // Override the accelerator since this adds new key combo in macos |
352 | role: 'pasteAndMatchStyle', | 352 | role: 'pasteAndMatchStyle', |
353 | click() { | 353 | click() { |
354 | getActiveWebview().pasteAndMatchStyle(); | 354 | getActiveWebview().pasteAndMatchStyle(); |
@@ -360,7 +360,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
360 | }, | 360 | }, |
361 | { | 361 | { |
362 | label: intl.formatMessage(menuItems.selectAll), | 362 | label: intl.formatMessage(menuItems.selectAll), |
363 | accelerator: `${cmdKey}+A`, | 363 | accelerator: `${shortcutKey()}+A`, |
364 | role: 'selectall', | 364 | role: 'selectall', |
365 | }, | 365 | }, |
366 | ], | 366 | ], |
@@ -375,7 +375,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
375 | }, | 375 | }, |
376 | { | 376 | { |
377 | label: intl.formatMessage(menuItems.openQuickSwitch), | 377 | label: intl.formatMessage(menuItems.openQuickSwitch), |
378 | accelerator: `${cmdKey}+S`, | 378 | accelerator: `${shortcutKey()}+S`, |
379 | click() { | 379 | click() { |
380 | window.ferdi.features.quickSwitch.state.isModalVisible = true; | 380 | window.ferdi.features.quickSwitch.state.isModalVisible = true; |
381 | }, | 381 | }, |
@@ -385,7 +385,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
385 | }, | 385 | }, |
386 | { | 386 | { |
387 | label: intl.formatMessage(menuItems.findInPage), | 387 | label: intl.formatMessage(menuItems.findInPage), |
388 | accelerator: `${cmdKey}+F`, | 388 | accelerator: `${shortcutKey()}+F`, |
389 | click() { | 389 | click() { |
390 | // Check if there is a service active | 390 | // Check if there is a service active |
391 | if (!window.ferdi.stores.services.active) return; | 391 | if (!window.ferdi.stores.services.active) return; |
@@ -406,14 +406,14 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
406 | }, | 406 | }, |
407 | { | 407 | { |
408 | label: intl.formatMessage(menuItems.back), | 408 | label: intl.formatMessage(menuItems.back), |
409 | accelerator: `${cmdKey}+Left`, | 409 | accelerator: `${shortcutKey()}+Left`, |
410 | click() { | 410 | click() { |
411 | getActiveWebview().goBack(); | 411 | getActiveWebview().goBack(); |
412 | }, | 412 | }, |
413 | }, | 413 | }, |
414 | { | 414 | { |
415 | label: intl.formatMessage(menuItems.forward), | 415 | label: intl.formatMessage(menuItems.forward), |
416 | accelerator: `${cmdKey}+Right`, | 416 | accelerator: `${shortcutKey()}+Right`, |
417 | click() { | 417 | click() { |
418 | getActiveWebview().goForward(); | 418 | getActiveWebview().goForward(); |
419 | }, | 419 | }, |
@@ -423,7 +423,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
423 | }, | 423 | }, |
424 | { | 424 | { |
425 | label: intl.formatMessage(menuItems.resetZoom), | 425 | label: intl.formatMessage(menuItems.resetZoom), |
426 | accelerator: `${cmdKey}+0`, | 426 | accelerator: `${shortcutKey()}+0`, |
427 | role: 'resetZoom', | 427 | role: 'resetZoom', |
428 | click() { | 428 | click() { |
429 | getActiveWebview().setZoomLevel(0); | 429 | getActiveWebview().setZoomLevel(0); |
@@ -431,7 +431,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
431 | }, | 431 | }, |
432 | { | 432 | { |
433 | label: intl.formatMessage(menuItems.zoomIn), | 433 | label: intl.formatMessage(menuItems.zoomIn), |
434 | accelerator: `${cmdKey}+plus`, | 434 | accelerator: `${shortcutKey()}+plus`, |
435 | role: 'zoomIn', | 435 | role: 'zoomIn', |
436 | click() { | 436 | click() { |
437 | const activeService = getActiveWebview(); | 437 | const activeService = getActiveWebview(); |
@@ -443,7 +443,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
443 | }, | 443 | }, |
444 | { | 444 | { |
445 | label: intl.formatMessage(menuItems.zoomOut), | 445 | label: intl.formatMessage(menuItems.zoomOut), |
446 | accelerator: `${cmdKey}+-`, | 446 | accelerator: `${shortcutKey()}+-`, |
447 | role: 'zoomOut', | 447 | role: 'zoomOut', |
448 | click() { | 448 | click() { |
449 | const activeService = getActiveWebview(); | 449 | const activeService = getActiveWebview(); |
@@ -463,7 +463,7 @@ const _titleBarTemplateFactory = (intl, locked) => [ | |||
463 | { | 463 | { |
464 | label: intl.formatMessage(menuItems.toggleDarkMode), | 464 | label: intl.formatMessage(menuItems.toggleDarkMode), |
465 | type: 'checkbox', | 465 | type: 'checkbox', |
466 | accelerator: `${cmdKey}+${shiftKey}+D`, | 466 | accelerator: `${shortcutKey()}+${shiftKey}+D`, |
467 | checked: window.ferdi.stores.settings.app.darkMode, | 467 | checked: window.ferdi.stores.settings.app.darkMode, |
468 | click: () => { | 468 | click: () => { |
469 | window.ferdi.actions.settings.update({ | 469 | window.ferdi.actions.settings.update({ |
@@ -612,13 +612,13 @@ export default class FranzMenu { | |||
612 | type: 'separator', | 612 | type: 'separator', |
613 | }, { | 613 | }, { |
614 | label: intl.formatMessage(menuItems.toggleDevTools), | 614 | label: intl.formatMessage(menuItems.toggleDevTools), |
615 | accelerator: `${cmdKey}+${altKey}+I`, | 615 | accelerator: `${shortcutKey()}+${altKey}+I`, |
616 | click: (menuItem, browserWindow) => { | 616 | click: (menuItem, browserWindow) => { |
617 | browserWindow.webContents.toggleDevTools(); | 617 | browserWindow.webContents.toggleDevTools(); |
618 | }, | 618 | }, |
619 | }, { | 619 | }, { |
620 | label: intl.formatMessage(menuItems.toggleServiceDevTools), | 620 | label: intl.formatMessage(menuItems.toggleServiceDevTools), |
621 | accelerator: `${cmdKey}+${shiftKey}+${altKey}+I`, | 621 | accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+I`, |
622 | click: () => { | 622 | click: () => { |
623 | this.actions.service.openDevToolsForActiveService(); | 623 | this.actions.service.openDevToolsForActiveService(); |
624 | }, | 624 | }, |
@@ -628,7 +628,7 @@ export default class FranzMenu { | |||
628 | if (this.stores.features.features.isTodosEnabled) { | 628 | if (this.stores.features.features.isTodosEnabled) { |
629 | tpl[1].submenu.push({ | 629 | tpl[1].submenu.push({ |
630 | label: intl.formatMessage(menuItems.toggleTodosDevTools), | 630 | label: intl.formatMessage(menuItems.toggleTodosDevTools), |
631 | accelerator: `${cmdKey}+${shiftKey}+${altKey}+O`, | 631 | accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+O`, |
632 | click: () => { | 632 | click: () => { |
633 | const webview = document.querySelector('#todos-panel webview'); | 633 | const webview = document.querySelector('#todos-panel webview'); |
634 | if (webview) this.actions.todos.openDevTools(); | 634 | if (webview) this.actions.todos.openDevTools(); |
@@ -639,7 +639,7 @@ export default class FranzMenu { | |||
639 | tpl[1].submenu.unshift({ | 639 | tpl[1].submenu.unshift({ |
640 | label: intl.formatMessage(menuItems.reloadService), | 640 | label: intl.formatMessage(menuItems.reloadService), |
641 | id: 'reloadService', // TODO: needed? | 641 | id: 'reloadService', // TODO: needed? |
642 | accelerator: `${cmdKey}+R`, | 642 | accelerator: `${shortcutKey()}+R`, |
643 | click: () => { | 643 | click: () => { |
644 | if (this.stores.user.isLoggedIn | 644 | if (this.stores.user.isLoggedIn |
645 | && this.stores.services.enabled.length > 0) { | 645 | && this.stores.services.enabled.length > 0) { |
@@ -654,13 +654,13 @@ export default class FranzMenu { | |||
654 | }, | 654 | }, |
655 | }, { | 655 | }, { |
656 | label: intl.formatMessage(menuItems.reloadFerdi), | 656 | label: intl.formatMessage(menuItems.reloadFerdi), |
657 | accelerator: `${cmdKey}+${shiftKey}+R`, | 657 | accelerator: `${shortcutKey()}+${shiftKey}+R`, |
658 | click: () => { | 658 | click: () => { |
659 | window.location.reload(); | 659 | window.location.reload(); |
660 | }, | 660 | }, |
661 | }, { | 661 | }, { |
662 | label: intl.formatMessage(menuItems.reloadTodos), | 662 | label: intl.formatMessage(menuItems.reloadTodos), |
663 | accelerator: `${cmdKey}+${shiftKey}+${altKey}+R`, | 663 | accelerator: `${shortcutKey()}+${shiftKey}+${altKey}+R`, |
664 | click: () => { | 664 | click: () => { |
665 | this.actions.todos.reload(); | 665 | this.actions.todos.reload(); |
666 | }, | 666 | }, |
@@ -832,7 +832,7 @@ export default class FranzMenu { | |||
832 | { | 832 | { |
833 | label: intl.formatMessage(menuItems.quit), | 833 | label: intl.formatMessage(menuItems.quit), |
834 | role: 'quit', | 834 | role: 'quit', |
835 | accelerator: `${cmdKey}+Q`, | 835 | accelerator: `${shortcutKey()}+Q`, |
836 | click() { | 836 | click() { |
837 | app.quit(); | 837 | app.quit(); |
838 | }, | 838 | }, |
@@ -883,22 +883,22 @@ export default class FranzMenu { | |||
883 | type: 'separator', | 883 | type: 'separator', |
884 | }, { | 884 | }, { |
885 | label: intl.formatMessage(menuItems.activateNextService), | 885 | label: intl.formatMessage(menuItems.activateNextService), |
886 | accelerator: `${cmdKey}+tab`, | 886 | accelerator: `${shortcutKey()}+tab`, |
887 | click: () => this.actions.service.setActiveNext(), | 887 | click: () => this.actions.service.setActiveNext(), |
888 | visible: !cmdAltShortcutsVisibile, | 888 | visible: !cmdAltShortcutsVisibile, |
889 | }, { | 889 | }, { |
890 | label: intl.formatMessage(menuItems.activateNextService), | 890 | label: intl.formatMessage(menuItems.activateNextService), |
891 | accelerator: `${cmdKey}+${altKey}+right`, | 891 | accelerator: `${shortcutKey()}+${altKey}+right`, |
892 | click: () => this.actions.service.setActiveNext(), | 892 | click: () => this.actions.service.setActiveNext(), |
893 | visible: cmdAltShortcutsVisibile, | 893 | visible: cmdAltShortcutsVisibile, |
894 | }, { | 894 | }, { |
895 | label: intl.formatMessage(menuItems.activatePreviousService), | 895 | label: intl.formatMessage(menuItems.activatePreviousService), |
896 | accelerator: `${cmdKey}+${shiftKey}+tab`, | 896 | accelerator: `${shortcutKey()}+${shiftKey}+tab`, |
897 | click: () => this.actions.service.setActivePrev(), | 897 | click: () => this.actions.service.setActivePrev(), |
898 | visible: !cmdAltShortcutsVisibile, | 898 | visible: !cmdAltShortcutsVisibile, |
899 | }, { | 899 | }, { |
900 | label: intl.formatMessage(menuItems.activatePreviousService), | 900 | label: intl.formatMessage(menuItems.activatePreviousService), |
901 | accelerator: `${cmdKey}+${altKey}+left`, | 901 | accelerator: `${shortcutKey()}+${altKey}+left`, |
902 | click: () => this.actions.service.setActivePrev(), | 902 | click: () => this.actions.service.setActivePrev(), |
903 | visible: cmdAltShortcutsVisibile, | 903 | visible: cmdAltShortcutsVisibile, |
904 | }, { | 904 | }, { |
@@ -913,7 +913,7 @@ export default class FranzMenu { | |||
913 | 913 | ||
914 | services.allDisplayed.forEach((service, i) => (menu.push({ | 914 | services.allDisplayed.forEach((service, i) => (menu.push({ |
915 | label: this._getServiceName(service), | 915 | label: this._getServiceName(service), |
916 | accelerator: i < 9 ? `${cmdKey}+${i + 1}` : null, | 916 | accelerator: i < 9 ? `${shortcutKey()}+${i + 1}` : null, |
917 | type: 'radio', | 917 | type: 'radio', |
918 | checked: service.isActive, | 918 | checked: service.isActive, |
919 | click: () => { | 919 | click: () => { |
@@ -930,7 +930,7 @@ export default class FranzMenu { | |||
930 | type: 'separator', | 930 | type: 'separator', |
931 | }, { | 931 | }, { |
932 | label: intl.formatMessage(menuItems.serviceGoHome), | 932 | label: intl.formatMessage(menuItems.serviceGoHome), |
933 | accelerator: `${cmdKey}+${shiftKey}+H`, | 933 | accelerator: `${shortcutKey()}+${shiftKey}+H`, |
934 | click: () => this.actions.service.reloadActive(), | 934 | click: () => this.actions.service.reloadActive(), |
935 | }); | 935 | }); |
936 | } | 936 | } |
@@ -946,7 +946,7 @@ export default class FranzMenu { | |||
946 | // Add new workspace item: | 946 | // Add new workspace item: |
947 | menu.push({ | 947 | menu.push({ |
948 | label: intl.formatMessage(menuItems.addNewWorkspace), | 948 | label: intl.formatMessage(menuItems.addNewWorkspace), |
949 | accelerator: `${cmdKey}+${shiftKey}+N`, | 949 | accelerator: `${shortcutKey()}+${shiftKey}+N`, |
950 | click: () => { | 950 | click: () => { |
951 | workspaceActions.openWorkspaceSettings(); | 951 | workspaceActions.openWorkspaceSettings(); |
952 | }, | 952 | }, |
@@ -975,7 +975,7 @@ export default class FranzMenu { | |||
975 | // Default workspace | 975 | // Default workspace |
976 | menu.push({ | 976 | menu.push({ |
977 | label: intl.formatMessage(menuItems.defaultWorkspace), | 977 | label: intl.formatMessage(menuItems.defaultWorkspace), |
978 | accelerator: `${cmdKey}+${altKey}+0`, | 978 | accelerator: `${shortcutKey()}+${altKey}+0`, |
979 | type: 'radio', | 979 | type: 'radio', |
980 | checked: !activeWorkspace, | 980 | checked: !activeWorkspace, |
981 | click: () => { | 981 | click: () => { |
@@ -986,7 +986,7 @@ export default class FranzMenu { | |||
986 | // Workspace items | 986 | // Workspace items |
987 | workspaces.forEach((workspace, i) => menu.push({ | 987 | workspaces.forEach((workspace, i) => menu.push({ |
988 | label: workspace.name, | 988 | label: workspace.name, |
989 | accelerator: i < 9 ? `${cmdKey}+${altKey}+${i + 1}` : null, | 989 | accelerator: i < 9 ? `${shortcutKey()}+${altKey}+${i + 1}` : null, |
990 | type: 'radio', | 990 | type: 'radio', |
991 | checked: activeWorkspace ? workspace.id === activeWorkspace.id : false, | 991 | checked: activeWorkspace ? workspace.id === activeWorkspace.id : false, |
992 | click: () => { | 992 | click: () => { |