diff options
author | 2021-08-02 18:29:05 +0000 | |
---|---|---|
committer | 2021-08-02 23:59:05 +0530 | |
commit | ea705c4ee3760ebad73988e96c50faef52c1cacf (patch) | |
tree | 3a4c3ddc3d1ee7f1d08d3f1b3d63cbc246c2699d /src/lib | |
parent | Add stnkl as a contributor for bug (#1727) [skip ci] (diff) | |
download | ferdium-app-ea705c4ee3760ebad73988e96c50faef52c1cacf.tar.gz ferdium-app-ea705c4ee3760ebad73988e96c50faef52c1cacf.tar.zst ferdium-app-ea705c4ee3760ebad73988e96c50faef52c1cacf.zip |
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 475 |
1 files changed, 55 insertions, 420 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index fe12f7dc4..89e6e0e0b 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, ctrlKey, isLinux, isMac, aboutAppDetails, termsBase, | 9 | cmdKey, isLinux, isMac, aboutAppDetails, termsBase, |
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'; |
@@ -20,37 +20,9 @@ const menuItems = defineMessages({ | |||
20 | id: 'menu.edit', | 20 | id: 'menu.edit', |
21 | defaultMessage: '!!!Edit', | 21 | defaultMessage: '!!!Edit', |
22 | }, | 22 | }, |
23 | undo: { | 23 | view: { |
24 | id: 'menu.edit.undo', | 24 | id: 'menu.view', |
25 | defaultMessage: '!!!Undo', | 25 | defaultMessage: '!!!View', |
26 | }, | ||
27 | redo: { | ||
28 | id: 'menu.edit.redo', | ||
29 | defaultMessage: '!!!Redo', | ||
30 | }, | ||
31 | cut: { | ||
32 | id: 'menu.edit.cut', | ||
33 | defaultMessage: '!!!Cut', | ||
34 | }, | ||
35 | copy: { | ||
36 | id: 'menu.edit.copy', | ||
37 | defaultMessage: '!!!Copy', | ||
38 | }, | ||
39 | paste: { | ||
40 | id: 'menu.edit.paste', | ||
41 | defaultMessage: '!!!Paste', | ||
42 | }, | ||
43 | pasteAndMatchStyle: { | ||
44 | id: 'menu.edit.pasteAndMatchStyle', | ||
45 | defaultMessage: '!!!Paste And Match Style', | ||
46 | }, | ||
47 | delete: { | ||
48 | id: 'menu.edit.delete', | ||
49 | defaultMessage: '!!!Delete', | ||
50 | }, | ||
51 | selectAll: { | ||
52 | id: 'menu.edit.selectAll', | ||
53 | defaultMessage: '!!!Select All', | ||
54 | }, | 26 | }, |
55 | findInPage: { | 27 | findInPage: { |
56 | id: 'menu.edit.findInPage', | 28 | id: 'menu.edit.findInPage', |
@@ -88,30 +60,6 @@ const menuItems = defineMessages({ | |||
88 | id: 'menu.view.forward', | 60 | id: 'menu.view.forward', |
89 | defaultMessage: '!!!Forward', | 61 | defaultMessage: '!!!Forward', |
90 | }, | 62 | }, |
91 | resetZoom: { | ||
92 | id: 'menu.view.resetZoom', | ||
93 | defaultMessage: '!!!Actual Size', | ||
94 | }, | ||
95 | zoomIn: { | ||
96 | id: 'menu.view.zoomIn', | ||
97 | defaultMessage: '!!!Zoom In', | ||
98 | }, | ||
99 | zoomOut: { | ||
100 | id: 'menu.view.zoomOut', | ||
101 | defaultMessage: '!!!Zoom Out', | ||
102 | }, | ||
103 | enterFullScreen: { | ||
104 | id: 'menu.view.enterFullScreen', | ||
105 | defaultMessage: '!!!Enter Full Screen', | ||
106 | }, | ||
107 | exitFullScreen: { | ||
108 | id: 'menu.view.exitFullScreen', | ||
109 | defaultMessage: '!!!Exit Full Screen', | ||
110 | }, | ||
111 | toggleFullScreen: { | ||
112 | id: 'menu.view.toggleFullScreen', | ||
113 | defaultMessage: '!!!Toggle Full Screen', | ||
114 | }, | ||
115 | toggleDarkMode: { | 63 | toggleDarkMode: { |
116 | id: 'menu.view.toggleDarkMode', | 64 | id: 'menu.view.toggleDarkMode', |
117 | defaultMessage: '!!!Toggle Dark Mode', | 65 | defaultMessage: '!!!Toggle Dark Mode', |
@@ -132,8 +80,8 @@ const menuItems = defineMessages({ | |||
132 | id: 'menu.view.reloadService', | 80 | id: 'menu.view.reloadService', |
133 | defaultMessage: '!!!Reload Service', | 81 | defaultMessage: '!!!Reload Service', |
134 | }, | 82 | }, |
135 | reloadFranz: { | 83 | reloadFerdi: { |
136 | id: 'menu.view.reloadFranz', | 84 | id: 'menu.view.reloadFerdi', |
137 | defaultMessage: '!!!Reload Ferdi', | 85 | defaultMessage: '!!!Reload Ferdi', |
138 | }, | 86 | }, |
139 | lockFerdi: { | 87 | lockFerdi: { |
@@ -144,14 +92,6 @@ const menuItems = defineMessages({ | |||
144 | id: 'menu.view.reloadTodos', | 92 | id: 'menu.view.reloadTodos', |
145 | defaultMessage: '!!!Reload ToDos', | 93 | defaultMessage: '!!!Reload ToDos', |
146 | }, | 94 | }, |
147 | minimize: { | ||
148 | id: 'menu.window.minimize', | ||
149 | defaultMessage: '!!!Minimize', | ||
150 | }, | ||
151 | close: { | ||
152 | id: 'menu.window.close', | ||
153 | defaultMessage: '!!!Close', | ||
154 | }, | ||
155 | learnMore: { | 95 | learnMore: { |
156 | id: 'menu.help.learnMore', | 96 | id: 'menu.help.learnMore', |
157 | defaultMessage: '!!!Learn More', | 97 | defaultMessage: '!!!Learn More', |
@@ -200,26 +140,10 @@ const menuItems = defineMessages({ | |||
200 | id: 'menu.file', | 140 | id: 'menu.file', |
201 | defaultMessage: '!!!File', | 141 | defaultMessage: '!!!File', |
202 | }, | 142 | }, |
203 | view: { | ||
204 | id: 'menu.view', | ||
205 | defaultMessage: '!!!View', | ||
206 | }, | ||
207 | services: { | 143 | services: { |
208 | id: 'menu.services', | 144 | id: 'menu.services', |
209 | defaultMessage: '!!!Services', | 145 | defaultMessage: '!!!Services', |
210 | }, | 146 | }, |
211 | window: { | ||
212 | id: 'menu.window', | ||
213 | defaultMessage: '!!!Window', | ||
214 | }, | ||
215 | help: { | ||
216 | id: 'menu.help', | ||
217 | defaultMessage: '!!!Help', | ||
218 | }, | ||
219 | about: { | ||
220 | id: 'menu.app.about', | ||
221 | defaultMessage: '!!!About Ferdi', | ||
222 | }, | ||
223 | announcement: { | 147 | announcement: { |
224 | id: 'menu.app.announcement', | 148 | id: 'menu.app.announcement', |
225 | defaultMessage: '!!!What\'s new?', | 149 | defaultMessage: '!!!What\'s new?', |
@@ -232,26 +156,10 @@ const menuItems = defineMessages({ | |||
232 | id: 'menu.app.checkForUpdates', | 156 | id: 'menu.app.checkForUpdates', |
233 | defaultMessage: '!!!Check for updates', | 157 | defaultMessage: '!!!Check for updates', |
234 | }, | 158 | }, |
235 | hide: { | ||
236 | id: 'menu.app.hide', | ||
237 | defaultMessage: '!!!Hide', | ||
238 | }, | ||
239 | hideOthers: { | ||
240 | id: 'menu.app.hideOthers', | ||
241 | defaultMessage: '!!!Hide Others', | ||
242 | }, | ||
243 | unhide: { | ||
244 | id: 'menu.app.unhide', | ||
245 | defaultMessage: '!!!Unhide', | ||
246 | }, | ||
247 | autohideMenuBar: { | 159 | autohideMenuBar: { |
248 | id: 'menu.app.autohideMenuBar', | 160 | id: 'menu.app.autohideMenuBar', |
249 | defaultMessage: '!!!Auto-hide menu bar', | 161 | defaultMessage: '!!!Auto-hide menu bar', |
250 | }, | 162 | }, |
251 | quit: { | ||
252 | id: 'menu.app.quit', | ||
253 | defaultMessage: '!!!Quit', | ||
254 | }, | ||
255 | addNewService: { | 163 | addNewService: { |
256 | id: 'menu.services.addNewService', | 164 | id: 'menu.services.addNewService', |
257 | defaultMessage: '!!!Add New Service...', | 165 | defaultMessage: '!!!Add New Service...', |
@@ -318,57 +226,44 @@ function getActiveWebview() { | |||
318 | return window.ferdi.stores.services.active.webview; | 226 | return window.ferdi.stores.services.active.webview; |
319 | } | 227 | } |
320 | 228 | ||
321 | const _templateFactory = (intl, locked) => [ | 229 | const _titleBarTemplateFactory = (intl, locked) => [ |
322 | { | 230 | { |
323 | label: intl.formatMessage(menuItems.edit), | 231 | label: intl.formatMessage(menuItems.edit), |
232 | accelerator: 'Alt+E', | ||
324 | submenu: [ | 233 | submenu: [ |
325 | { | 234 | { |
326 | label: intl.formatMessage(menuItems.undo), | ||
327 | role: 'undo', | 235 | role: 'undo', |
328 | }, | 236 | }, |
329 | { | 237 | { |
330 | label: intl.formatMessage(menuItems.redo), | ||
331 | role: 'redo', | 238 | role: 'redo', |
332 | }, | 239 | }, |
333 | { | 240 | { |
334 | type: 'separator', | 241 | type: 'separator', |
335 | }, | 242 | }, |
336 | { | 243 | { |
337 | label: intl.formatMessage(menuItems.cut), | 244 | role: 'cut', |
338 | accelerator: 'Cmd+X', | ||
339 | selector: 'cut:', | ||
340 | }, | 245 | }, |
341 | { | 246 | { |
342 | label: intl.formatMessage(menuItems.copy), | 247 | role: 'copy', |
343 | accelerator: 'Cmd+C', | ||
344 | selector: 'copy:', | ||
345 | }, | 248 | }, |
346 | { | 249 | { |
347 | label: intl.formatMessage(menuItems.paste), | 250 | role: 'paste', |
348 | accelerator: 'Cmd+V', | ||
349 | selector: 'paste:', | ||
350 | }, | 251 | }, |
351 | { | 252 | { |
352 | label: intl.formatMessage(menuItems.pasteAndMatchStyle), | 253 | role: 'pasteAndMatchStyle', |
353 | accelerator: 'Cmd+Shift+V', | 254 | accelerator: `${cmdKey}+Shift+V`, // Override the accelerator since this adds new key combo in macos |
354 | selector: 'pasteAndMatchStyle:', | ||
355 | click() { | ||
356 | getActiveWebview().pasteAndMatchStyle(); | ||
357 | }, | ||
358 | }, | 255 | }, |
359 | { | 256 | { |
360 | label: intl.formatMessage(menuItems.delete), | ||
361 | role: 'delete', | 257 | role: 'delete', |
362 | }, | 258 | }, |
363 | { | 259 | { |
364 | label: intl.formatMessage(menuItems.selectAll), | 260 | role: 'selectall', |
365 | accelerator: 'Cmd+A', | ||
366 | selector: 'selectAll:', | ||
367 | }, | 261 | }, |
368 | ], | 262 | ], |
369 | }, | 263 | }, |
370 | { | 264 | { |
371 | label: intl.formatMessage(menuItems.view), | 265 | label: intl.formatMessage(menuItems.view), |
266 | accelerator: 'Alt+V', | ||
372 | visible: !locked, | 267 | visible: !locked, |
373 | submenu: [ | 268 | submenu: [ |
374 | { | 269 | { |
@@ -376,7 +271,7 @@ const _templateFactory = (intl, locked) => [ | |||
376 | }, | 271 | }, |
377 | { | 272 | { |
378 | label: intl.formatMessage(menuItems.openQuickSwitch), | 273 | label: intl.formatMessage(menuItems.openQuickSwitch), |
379 | accelerator: 'CmdOrCtrl+S', | 274 | accelerator: `${cmdKey}+S`, |
380 | click() { | 275 | click() { |
381 | window.ferdi.features.quickSwitch.state.isModalVisible = true; | 276 | window.ferdi.features.quickSwitch.state.isModalVisible = true; |
382 | }, | 277 | }, |
@@ -386,7 +281,7 @@ const _templateFactory = (intl, locked) => [ | |||
386 | }, | 281 | }, |
387 | { | 282 | { |
388 | label: intl.formatMessage(menuItems.findInPage), | 283 | label: intl.formatMessage(menuItems.findInPage), |
389 | accelerator: 'CmdOrCtrl+F', | 284 | accelerator: `${cmdKey}+F`, |
390 | click() { | 285 | click() { |
391 | // Check if there is a service active | 286 | // Check if there is a service active |
392 | if (!window.ferdi.stores.services.active) return; | 287 | if (!window.ferdi.stores.services.active) return; |
@@ -407,33 +302,29 @@ const _templateFactory = (intl, locked) => [ | |||
407 | }, | 302 | }, |
408 | { | 303 | { |
409 | label: intl.formatMessage(menuItems.back), | 304 | label: intl.formatMessage(menuItems.back), |
410 | accelerator: 'CmdOrCtrl+Left', | 305 | accelerator: `${cmdKey}+Left`, |
411 | click() { | 306 | click() { |
412 | const activeService = getActiveWebview(); | 307 | getActiveWebview().goBack(); |
413 | activeService.goBack(); | ||
414 | }, | 308 | }, |
415 | }, | 309 | }, |
416 | { | 310 | { |
417 | label: intl.formatMessage(menuItems.forward), | 311 | label: intl.formatMessage(menuItems.forward), |
418 | accelerator: 'CmdOrCtrl+Right', | 312 | accelerator: `${cmdKey}+Right`, |
419 | click() { | 313 | click() { |
420 | const activeService = getActiveWebview(); | 314 | getActiveWebview().goForward(); |
421 | activeService.goForward(); | ||
422 | }, | 315 | }, |
423 | }, | 316 | }, |
424 | { | 317 | { |
425 | type: 'separator', | 318 | type: 'separator', |
426 | }, | 319 | }, |
427 | { | 320 | { |
428 | label: intl.formatMessage(menuItems.resetZoom), | 321 | role: 'resetZoom', |
429 | accelerator: 'Cmd+0', | ||
430 | click() { | 322 | click() { |
431 | getActiveWebview().setZoomLevel(0); | 323 | getActiveWebview().setZoomLevel(0); |
432 | }, | 324 | }, |
433 | }, | 325 | }, |
434 | { | 326 | { |
435 | label: intl.formatMessage(menuItems.zoomIn), | 327 | role: 'zoomIn', |
436 | accelerator: 'Cmd+plus', | ||
437 | click() { | 328 | click() { |
438 | const activeService = getActiveWebview(); | 329 | const activeService = getActiveWebview(); |
439 | const level = activeService.getZoomLevel(); | 330 | const level = activeService.getZoomLevel(); |
@@ -443,8 +334,7 @@ const _templateFactory = (intl, locked) => [ | |||
443 | }, | 334 | }, |
444 | }, | 335 | }, |
445 | { | 336 | { |
446 | label: intl.formatMessage(menuItems.zoomOut), | 337 | role: 'zoomOut', |
447 | accelerator: 'Cmd+-', | ||
448 | click() { | 338 | click() { |
449 | const activeService = getActiveWebview(); | 339 | const activeService = getActiveWebview(); |
450 | const level = activeService.getZoomLevel(); | 340 | const level = activeService.getZoomLevel(); |
@@ -457,10 +347,7 @@ const _templateFactory = (intl, locked) => [ | |||
457 | type: 'separator', | 347 | type: 'separator', |
458 | }, | 348 | }, |
459 | { | 349 | { |
460 | label: app.mainWindow.isFullScreen() // label doesn't work, gets overridden by Electron | 350 | role: 'toggleFullScreen', |
461 | ? intl.formatMessage(menuItems.exitFullScreen) | ||
462 | : intl.formatMessage(menuItems.enterFullScreen), | ||
463 | role: 'togglefullscreen', | ||
464 | }, | 351 | }, |
465 | { | 352 | { |
466 | label: intl.formatMessage(menuItems.toggleDarkMode), | 353 | label: intl.formatMessage(menuItems.toggleDarkMode), |
@@ -480,11 +367,13 @@ const _templateFactory = (intl, locked) => [ | |||
480 | }, | 367 | }, |
481 | { | 368 | { |
482 | label: intl.formatMessage(menuItems.services), | 369 | label: intl.formatMessage(menuItems.services), |
370 | accelerator: 'Alt+S', | ||
483 | visible: !locked, | 371 | visible: !locked, |
484 | submenu: [], | 372 | submenu: [], |
485 | }, | 373 | }, |
486 | { | 374 | { |
487 | label: intl.formatMessage(menuItems.workspaces), | 375 | label: intl.formatMessage(menuItems.workspaces), |
376 | accelerator: 'Alt+W', | ||
488 | submenu: [], | 377 | submenu: [], |
489 | visible: !locked && workspaceStore.isFeatureEnabled, | 378 | visible: !locked && workspaceStore.isFeatureEnabled, |
490 | }, | 379 | }, |
@@ -494,21 +383,17 @@ const _templateFactory = (intl, locked) => [ | |||
494 | visible: !locked && todosStore.isFeatureEnabled, | 383 | visible: !locked && todosStore.isFeatureEnabled, |
495 | }, | 384 | }, |
496 | { | 385 | { |
497 | label: intl.formatMessage(menuItems.window), | ||
498 | role: 'window', | 386 | role: 'window', |
499 | submenu: [ | 387 | submenu: [ |
500 | { | 388 | { |
501 | label: intl.formatMessage(menuItems.minimize), | ||
502 | role: 'minimize', | 389 | role: 'minimize', |
503 | }, | 390 | }, |
504 | { | 391 | { |
505 | label: intl.formatMessage(menuItems.close), | ||
506 | role: 'close', | 392 | role: 'close', |
507 | }, | 393 | }, |
508 | ], | 394 | ], |
509 | }, | 395 | }, |
510 | { | 396 | { |
511 | label: intl.formatMessage(menuItems.help), | ||
512 | role: 'help', | 397 | role: 'help', |
513 | submenu: [ | 398 | submenu: [ |
514 | { | 399 | { |
@@ -516,276 +401,18 @@ const _templateFactory = (intl, locked) => [ | |||
516 | click() { shell.openExternal(LIVE_API_FERDI_WEBSITE); }, | 401 | click() { shell.openExternal(LIVE_API_FERDI_WEBSITE); }, |
517 | }, | 402 | }, |
518 | { | 403 | { |
519 | label: intl.formatMessage(menuItems.announcement), | 404 | label: intl.formatMessage(menuItems.changelog), |
520 | click: () => { | 405 | click() { shell.openExternal(`${GITHUB_FERDI_URL}/ferdi/blob/master/CHANGELOG.md`); }, |
521 | announcementActions.show(); | ||
522 | }, | ||
523 | visible: !locked && window.ferdi.stores.user.isLoggedIn && announcementsStore.areNewsAvailable, | ||
524 | }, | ||
525 | { | ||
526 | type: 'separator', | ||
527 | }, | ||
528 | { | ||
529 | label: intl.formatMessage(menuItems.support), | ||
530 | click() { shell.openExternal(`${LIVE_API_FERDI_WEBSITE}/contact`); }, | ||
531 | }, | ||
532 | { | ||
533 | type: 'separator', | ||
534 | }, | ||
535 | { | ||
536 | label: intl.formatMessage(menuItems.tos), | ||
537 | click() { shell.openExternal(`${termsBase()}/terms`); }, | ||
538 | }, | ||
539 | { | ||
540 | label: intl.formatMessage(menuItems.privacy), | ||
541 | click() { shell.openExternal(`${termsBase()}/privacy`); }, | ||
542 | }, | ||
543 | ], | ||
544 | }, | ||
545 | ]; | ||
546 | |||
547 | const _titleBarTemplateFactory = (intl, locked) => [ | ||
548 | { | ||
549 | label: intl.formatMessage(menuItems.edit), | ||
550 | accelerator: 'Alt+E', | ||
551 | submenu: [ | ||
552 | { | ||
553 | label: intl.formatMessage(menuItems.undo), | ||
554 | accelerator: `${ctrlKey}+Z`, | ||
555 | click() { | ||
556 | getActiveWebview().undo(); | ||
557 | }, | ||
558 | }, | ||
559 | { | ||
560 | label: intl.formatMessage(menuItems.redo), | ||
561 | accelerator: `${ctrlKey}+Y`, | ||
562 | click() { | ||
563 | getActiveWebview().redo(); | ||
564 | }, | ||
565 | }, | ||
566 | { | ||
567 | type: 'separator', | ||
568 | }, | ||
569 | { | ||
570 | label: intl.formatMessage(menuItems.cut), | ||
571 | accelerator: `${ctrlKey}+X`, | ||
572 | click() { | ||
573 | getActiveWebview().cut(); | ||
574 | }, | ||
575 | }, | ||
576 | { | ||
577 | label: intl.formatMessage(menuItems.copy), | ||
578 | accelerator: `${ctrlKey}+C`, | ||
579 | click() { | ||
580 | getActiveWebview().copy(); | ||
581 | }, | ||
582 | }, | ||
583 | { | ||
584 | label: intl.formatMessage(menuItems.paste), | ||
585 | accelerator: `${ctrlKey}+V`, | ||
586 | role: 'paste', | ||
587 | click() { | ||
588 | getActiveWebview().paste(); | ||
589 | }, | ||
590 | }, | ||
591 | { | ||
592 | label: intl.formatMessage(menuItems.pasteAndMatchStyle), | ||
593 | accelerator: `${ctrlKey}+Shift+V`, | ||
594 | role: 'pasteAndMatchStyle', | ||
595 | click() { | ||
596 | getActiveWebview().pasteAndMatchStyle(); | ||
597 | }, | ||
598 | }, | ||
599 | { | ||
600 | label: intl.formatMessage(menuItems.delete), | ||
601 | click() { | ||
602 | getActiveWebview().delete(); | ||
603 | }, | ||
604 | }, | ||
605 | { | ||
606 | label: intl.formatMessage(menuItems.selectAll), | ||
607 | accelerator: `${ctrlKey}+A`, | ||
608 | click() { | ||
609 | getActiveWebview().selectAll(); | ||
610 | }, | ||
611 | }, | ||
612 | ], | ||
613 | }, | ||
614 | { | ||
615 | label: intl.formatMessage(menuItems.view), | ||
616 | accelerator: 'Alt+V', | ||
617 | visible: !locked, | ||
618 | submenu: [ | ||
619 | { | ||
620 | type: 'separator', | ||
621 | }, | ||
622 | { | ||
623 | label: intl.formatMessage(menuItems.openQuickSwitch), | ||
624 | accelerator: 'CmdOrCtrl+S', | ||
625 | click() { | ||
626 | window.ferdi.features.quickSwitch.state.isModalVisible = true; | ||
627 | }, | ||
628 | }, | ||
629 | { | ||
630 | type: 'separator', | ||
631 | }, | ||
632 | { | ||
633 | label: intl.formatMessage(menuItems.findInPage), | ||
634 | accelerator: 'CmdOrCtrl+F', | ||
635 | click() { | ||
636 | // Check if there is a service active | ||
637 | if (!window.ferdi.stores.services.active) return; | ||
638 | |||
639 | // Focus webview so find in page popup gets focused | ||
640 | window.ferdi.stores.services.active.webview.focus(); | ||
641 | |||
642 | const currentService = window.ferdi.stores.services.active.id; | ||
643 | window.ferdi.actions.service.sendIPCMessage({ | ||
644 | serviceId: currentService, | ||
645 | channel: 'find-in-page', | ||
646 | args: {}, | ||
647 | }); | ||
648 | }, | ||
649 | }, | ||
650 | { | ||
651 | type: 'separator', | ||
652 | }, | ||
653 | { | ||
654 | label: intl.formatMessage(menuItems.back), | ||
655 | accelerator: 'CmdOrCtrl+Left', | ||
656 | click() { | ||
657 | const activeService = getActiveWebview(); | ||
658 | activeService.goBack(); | ||
659 | }, | ||
660 | }, | ||
661 | { | ||
662 | label: intl.formatMessage(menuItems.forward), | ||
663 | accelerator: 'CmdOrCtrl+Right', | ||
664 | click() { | ||
665 | const activeService = getActiveWebview(); | ||
666 | activeService.goForward(); | ||
667 | }, | ||
668 | }, | ||
669 | { | ||
670 | type: 'separator', | ||
671 | }, | ||
672 | { | ||
673 | label: intl.formatMessage(menuItems.resetZoom), | ||
674 | accelerator: `${ctrlKey}+0`, | ||
675 | click() { | ||
676 | getActiveWebview().setZoomLevel(0); | ||
677 | }, | ||
678 | }, | ||
679 | { | ||
680 | label: intl.formatMessage(menuItems.zoomIn), | ||
681 | accelerator: `${ctrlKey}+=`, | ||
682 | click() { | ||
683 | const activeService = getActiveWebview(); | ||
684 | const level = activeService.getZoomLevel(); | ||
685 | |||
686 | // level 9 =~ +300% and setZoomLevel wouldnt zoom in further | ||
687 | if (level < 9) activeService.setZoomLevel(level + 1); | ||
688 | }, | ||
689 | }, | ||
690 | { | ||
691 | label: intl.formatMessage(menuItems.zoomOut), | ||
692 | accelerator: `${ctrlKey}+-`, | ||
693 | click() { | ||
694 | const activeService = getActiveWebview(); | ||
695 | const level = activeService.getZoomLevel(); | ||
696 | |||
697 | // level -9 =~ -50% and setZoomLevel wouldnt zoom out further | ||
698 | if (level > -9) activeService.setZoomLevel(level - 1); | ||
699 | }, | ||
700 | }, | 406 | }, |
701 | { | 407 | { |
702 | type: 'separator', | 408 | type: 'separator', |
703 | }, | 409 | }, |
704 | { | 410 | { |
705 | label: app.mainWindow.isFullScreen() // label doesn't work, gets overridden by Electron | 411 | label: intl.formatMessage(menuItems.announcement), |
706 | ? intl.formatMessage(menuItems.exitFullScreen) | ||
707 | : intl.formatMessage(menuItems.enterFullScreen), | ||
708 | accelerator: 'F11', | ||
709 | click(menuItem, browserWindow) { | ||
710 | browserWindow.setFullScreen(!browserWindow.isFullScreen()); | ||
711 | }, | ||
712 | }, | ||
713 | { | ||
714 | label: intl.formatMessage(menuItems.toggleDarkMode), | ||
715 | type: 'checkbox', | ||
716 | accelerator: `${cmdKey}+Shift+D`, | ||
717 | checked: window.ferdi.stores.settings.app.darkMode, | ||
718 | click: () => { | ||
719 | window.ferdi.actions.settings.update({ | ||
720 | type: 'app', | ||
721 | data: { | ||
722 | darkMode: !window.ferdi.stores.settings.app.darkMode, | ||
723 | }, | ||
724 | }); | ||
725 | }, | ||
726 | }, | ||
727 | { | ||
728 | label: intl.formatMessage(menuItems.autohideMenuBar), | ||
729 | type: 'checkbox', | ||
730 | checked: window.ferdi.stores.settings.app.autohideMenuBar, | ||
731 | click: () => { | 412 | click: () => { |
732 | window.ferdi.actions.settings.update({ | 413 | announcementActions.show(); |
733 | type: 'app', | ||
734 | data: { | ||
735 | autohideMenuBar: !window.ferdi.stores.settings.app.autohideMenuBar, | ||
736 | }, | ||
737 | }); | ||
738 | }, | ||
739 | }, | ||
740 | ], | ||
741 | }, | ||
742 | { | ||
743 | label: intl.formatMessage(menuItems.services), | ||
744 | accelerator: 'Alt+S', | ||
745 | visible: !locked, | ||
746 | submenu: [], | ||
747 | }, | ||
748 | { | ||
749 | label: intl.formatMessage(menuItems.workspaces), | ||
750 | accelerator: 'Alt+W', | ||
751 | submenu: [], | ||
752 | visible: !locked && workspaceStore.isFeatureEnabled, | ||
753 | }, | ||
754 | { | ||
755 | label: intl.formatMessage(menuItems.todos), | ||
756 | submenu: [], | ||
757 | visible: !locked && todosStore.isFeatureEnabled, | ||
758 | }, | ||
759 | { | ||
760 | label: intl.formatMessage(menuItems.window), | ||
761 | submenu: [ | ||
762 | { | ||
763 | label: intl.formatMessage(menuItems.minimize), | ||
764 | accelerator: 'Ctrl+M', | ||
765 | click(menuItem, browserWindow) { | ||
766 | browserWindow.minimize(); | ||
767 | }, | 414 | }, |
768 | }, | 415 | enabled: !locked && window.ferdi.stores.user.isLoggedIn && announcementsStore.areNewsAvailable, |
769 | { | ||
770 | label: intl.formatMessage(menuItems.close), | ||
771 | accelerator: 'Ctrl+W', | ||
772 | click(menuItem, browserWindow) { | ||
773 | browserWindow.close(); | ||
774 | }, | ||
775 | }, | ||
776 | ], | ||
777 | }, | ||
778 | { | ||
779 | label: '?', | ||
780 | accelerator: 'Alt+?', | ||
781 | submenu: [ | ||
782 | { | ||
783 | label: intl.formatMessage(menuItems.learnMore), | ||
784 | click() { shell.openExternal(LIVE_API_FERDI_WEBSITE); }, | ||
785 | }, | ||
786 | { | ||
787 | label: intl.formatMessage(menuItems.changelog), | ||
788 | click() { shell.openExternal(`${GITHUB_FERDI_URL}/ferdi/blob/master/CHANGELOG.md`); }, | ||
789 | }, | 416 | }, |
790 | { | 417 | { |
791 | type: 'separator', | 418 | type: 'separator', |
@@ -840,11 +467,25 @@ export default class FranzMenu { | |||
840 | } | 467 | } |
841 | 468 | ||
842 | const { intl } = window.ferdi; | 469 | const { intl } = window.ferdi; |
843 | const tpl = isMac | 470 | const tpl = _titleBarTemplateFactory(intl, this.stores.settings.app.locked); |
844 | ? _templateFactory(intl, this.stores.settings.app.locked) | ||
845 | : _titleBarTemplateFactory(intl, this.stores.settings.app.locked); | ||
846 | const { actions } = this; | 471 | const { actions } = this; |
847 | 472 | ||
473 | if (!isMac) { | ||
474 | tpl[1].submenu.push({ | ||
475 | label: intl.formatMessage(menuItems.autohideMenuBar), | ||
476 | type: 'checkbox', | ||
477 | checked: window.ferdi.stores.settings.app.autohideMenuBar, | ||
478 | click: () => { | ||
479 | window.ferdi.actions.settings.update({ | ||
480 | type: 'app', | ||
481 | data: { | ||
482 | autohideMenuBar: !window.ferdi.stores.settings.app.autohideMenuBar, | ||
483 | }, | ||
484 | }); | ||
485 | }, | ||
486 | }); | ||
487 | } | ||
488 | |||
848 | if (!this.stores.settings.app.locked) { | 489 | if (!this.stores.settings.app.locked) { |
849 | tpl[1].submenu.push({ | 490 | tpl[1].submenu.push({ |
850 | type: 'separator', | 491 | type: 'separator', |
@@ -891,7 +532,7 @@ export default class FranzMenu { | |||
891 | } | 532 | } |
892 | }, | 533 | }, |
893 | }, { | 534 | }, { |
894 | label: intl.formatMessage(menuItems.reloadFranz), | 535 | label: intl.formatMessage(menuItems.reloadFerdi), |
895 | accelerator: `${cmdKey}+Shift+R`, | 536 | accelerator: `${cmdKey}+Shift+R`, |
896 | click: () => { | 537 | click: () => { |
897 | window.location.reload(); | 538 | window.location.reload(); |
@@ -906,7 +547,7 @@ export default class FranzMenu { | |||
906 | type: 'separator', | 547 | type: 'separator', |
907 | }, { | 548 | }, { |
908 | label: intl.formatMessage(menuItems.lockFerdi), | 549 | label: intl.formatMessage(menuItems.lockFerdi), |
909 | accelerator: 'CmdOrCtrl+Shift+L', | 550 | accelerator: `${cmdKey}+Shift+L`, |
910 | enabled: this.stores.user.isLoggedIn && this.stores.settings.app.lockingFeatureEnabled, | 551 | enabled: this.stores.user.isLoggedIn && this.stores.settings.app.lockingFeatureEnabled, |
911 | click() { | 552 | click() { |
912 | actions.settings.update({ | 553 | actions.settings.update({ |
@@ -934,7 +575,7 @@ export default class FranzMenu { | |||
934 | 575 | ||
935 | tpl[0].submenu.unshift({ | 576 | tpl[0].submenu.unshift({ |
936 | label: intl.formatMessage(menuItems.touchId), | 577 | label: intl.formatMessage(menuItems.touchId), |
937 | accelerator: 'CmdOrCtrl+Shift+L', | 578 | accelerator: `${cmdKey}+Shift+L`, |
938 | visible: touchIdEnabled, | 579 | visible: touchIdEnabled, |
939 | click() { | 580 | click() { |
940 | systemPreferences.promptTouchID(intl.formatMessage(menuItems.touchIdPrompt)).then(() => { | 581 | systemPreferences.promptTouchID(intl.formatMessage(menuItems.touchIdPrompt)).then(() => { |
@@ -957,7 +598,6 @@ export default class FranzMenu { | |||
957 | accelerator: 'Alt+F', | 598 | accelerator: 'Alt+F', |
958 | submenu: [ | 599 | submenu: [ |
959 | { | 600 | { |
960 | label: intl.formatMessage(menuItems.about), | ||
961 | role: 'about', | 601 | role: 'about', |
962 | }, | 602 | }, |
963 | { | 603 | { |
@@ -965,7 +605,7 @@ export default class FranzMenu { | |||
965 | }, | 605 | }, |
966 | { | 606 | { |
967 | label: intl.formatMessage(menuItems.settings), | 607 | label: intl.formatMessage(menuItems.settings), |
968 | accelerator: 'CmdOrCtrl+,', | 608 | accelerator: `${cmdKey}+,`, |
969 | click: () => { | 609 | click: () => { |
970 | this.actions.ui.openSettings({ path: 'app' }); | 610 | this.actions.ui.openSettings({ path: 'app' }); |
971 | }, | 611 | }, |
@@ -992,22 +632,18 @@ export default class FranzMenu { | |||
992 | type: 'separator', | 632 | type: 'separator', |
993 | }, | 633 | }, |
994 | { | 634 | { |
995 | label: intl.formatMessage(menuItems.hide), | ||
996 | role: 'hide', | 635 | role: 'hide', |
997 | }, | 636 | }, |
998 | { | 637 | { |
999 | label: intl.formatMessage(menuItems.hideOthers), | 638 | role: 'hideOthers', |
1000 | role: 'hideothers', | ||
1001 | }, | 639 | }, |
1002 | { | 640 | { |
1003 | label: intl.formatMessage(menuItems.unhide), | ||
1004 | role: 'unhide', | 641 | role: 'unhide', |
1005 | }, | 642 | }, |
1006 | { | 643 | { |
1007 | type: 'separator', | 644 | type: 'separator', |
1008 | }, | 645 | }, |
1009 | { | 646 | { |
1010 | label: intl.formatMessage(menuItems.quit), | ||
1011 | role: 'quit', | 647 | role: 'quit', |
1012 | click() { | 648 | click() { |
1013 | app.quit(); | 649 | app.quit(); |
@@ -1017,7 +653,7 @@ export default class FranzMenu { | |||
1017 | }); | 653 | }); |
1018 | 654 | ||
1019 | const about = { | 655 | const about = { |
1020 | label: intl.formatMessage(menuItems.about), | 656 | role: 'about', |
1021 | click: () => { | 657 | click: () => { |
1022 | dialog.showMessageBox({ | 658 | dialog.showMessageBox({ |
1023 | type: 'info', | 659 | type: 'info', |
@@ -1067,7 +703,6 @@ export default class FranzMenu { | |||
1067 | type: 'separator', | 703 | type: 'separator', |
1068 | }, | 704 | }, |
1069 | { | 705 | { |
1070 | label: intl.formatMessage(menuItems.quit), | ||
1071 | role: 'quit', | 706 | role: 'quit', |
1072 | accelerator: 'Ctrl+Q', | 707 | accelerator: 'Ctrl+Q', |
1073 | click() { | 708 | click() { |