diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Menu.js | 58 | ||||
-rw-r--r-- | src/lib/Tray.js | 38 |
2 files changed, 70 insertions, 26 deletions
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index a6cde4d36..8f0a92c3d 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -1,9 +1,9 @@ | |||
1 | import { remote, shell } from 'electron'; | 1 | import { remote, shell } from 'electron'; |
2 | import { autorun, computed, observable, toJS } from 'mobx'; | 2 | import { autorun, computed, observable, toJS } from 'mobx'; |
3 | 3 | ||
4 | import { isDevMode, isMac } from '../environment'; | 4 | import { isMac } from '../environment'; |
5 | 5 | ||
6 | const { app, Menu } = remote; | 6 | const { app, Menu, dialog } = remote; |
7 | 7 | ||
8 | const template = [ | 8 | const template = [ |
9 | { | 9 | { |
@@ -84,6 +84,28 @@ const template = [ | |||
84 | label: 'Learn More', | 84 | label: 'Learn More', |
85 | click() { shell.openExternal('http://meetfranz.com'); }, | 85 | click() { shell.openExternal('http://meetfranz.com'); }, |
86 | }, | 86 | }, |
87 | { | ||
88 | label: 'Changelog', | ||
89 | click() { shell.openExternal('https://github.com/meetfranz/franz/blob/master/CHANGELOG.md'); }, | ||
90 | }, | ||
91 | { | ||
92 | type: 'separator', | ||
93 | }, | ||
94 | { | ||
95 | label: 'Support', | ||
96 | click() { shell.openExternal('http://meetfranz.com/support'); }, | ||
97 | }, | ||
98 | { | ||
99 | type: 'separator', | ||
100 | }, | ||
101 | { | ||
102 | label: 'Terms of Service', | ||
103 | click() { shell.openExternal('https://meetfranz.com/terms'); }, | ||
104 | }, | ||
105 | { | ||
106 | label: 'Privacy Statement', | ||
107 | click() { shell.openExternal('https://meetfranz.com/privacy'); }, | ||
108 | }, | ||
87 | ], | 109 | ], |
88 | }, | 110 | }, |
89 | ]; | 111 | ]; |
@@ -101,17 +123,15 @@ export default class FranzMenu { | |||
101 | _build() { | 123 | _build() { |
102 | const tpl = toJS(this.tpl); | 124 | const tpl = toJS(this.tpl); |
103 | 125 | ||
104 | if (isDevMode) { | 126 | tpl[1].submenu.push({ |
105 | tpl[1].submenu.push({ | 127 | role: 'toggledevtools', |
106 | role: 'toggledevtools', | 128 | }, { |
107 | }, { | 129 | label: 'Toggle Service Developer Tools', |
108 | label: 'Toggle Service Developer Tools', | 130 | accelerator: 'CmdOrCtrl+Shift+Alt+i', |
109 | accelerator: 'CmdOrCtrl+Shift+Alt+i', | 131 | click: () => { |
110 | click: () => { | 132 | this.actions.service.openDevToolsForActiveService(); |
111 | this.actions.service.openDevToolsForActiveService(); | 133 | }, |
112 | }, | 134 | }); |
113 | }); | ||
114 | } | ||
115 | 135 | ||
116 | tpl[1].submenu.unshift({ | 136 | tpl[1].submenu.unshift({ |
117 | label: 'Reload Service', | 137 | label: 'Reload Service', |
@@ -218,6 +238,18 @@ export default class FranzMenu { | |||
218 | role: 'front', | 238 | role: 'front', |
219 | }, | 239 | }, |
220 | ]; | 240 | ]; |
241 | } else { | ||
242 | tpl[4].submenu.unshift({ | ||
243 | role: 'about', | ||
244 | click: () => { | ||
245 | dialog.showMessageBox({ | ||
246 | type: 'info', | ||
247 | title: 'Franz', | ||
248 | message: 'Franz', | ||
249 | detail: `Version: ${remote.app.getVersion()}\nRelease: ${process.versions.electron} / ${process.platform} / ${process.arch}`, | ||
250 | }); | ||
251 | }, | ||
252 | }); | ||
221 | } | 253 | } |
222 | 254 | ||
223 | const serviceTpl = this.serviceTpl; | 255 | const serviceTpl = this.serviceTpl; |
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 67150971e..2efe71a71 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -6,12 +6,9 @@ const INDICATOR_TRAY_PLAIN = 'tray'; | |||
6 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; | 6 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; |
7 | 7 | ||
8 | export default class TrayIcon { | 8 | export default class TrayIcon { |
9 | mainWindow = null; | ||
10 | trayIcon = null; | 9 | trayIcon = null; |
11 | 10 | indicator = 0; | |
12 | constructor(mainWindow) { | 11 | themeChangeSubscriberId = null; |
13 | this.mainWindow = mainWindow; | ||
14 | } | ||
15 | 12 | ||
16 | show() { | 13 | show() { |
17 | if (this.trayIcon) return; | 14 | if (this.trayIcon) return; |
@@ -21,7 +18,7 @@ export default class TrayIcon { | |||
21 | { | 18 | { |
22 | label: 'Show Franz', | 19 | label: 'Show Franz', |
23 | click() { | 20 | click() { |
24 | this.mainWindow.show(); | 21 | app.mainWindow.show(); |
25 | }, | 22 | }, |
26 | }, { | 23 | }, { |
27 | label: 'Quit Franz', | 24 | label: 'Quit Franz', |
@@ -35,30 +32,45 @@ export default class TrayIcon { | |||
35 | this.trayIcon.setContextMenu(trayMenu); | 32 | this.trayIcon.setContextMenu(trayMenu); |
36 | 33 | ||
37 | this.trayIcon.on('click', () => { | 34 | this.trayIcon.on('click', () => { |
38 | this.mainWindow.show(); | 35 | app.mainWindow.show(); |
39 | }); | 36 | }); |
37 | |||
38 | if (process.platform === 'darwin') { | ||
39 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { | ||
40 | this._refreshIcon(); | ||
41 | }); | ||
42 | } | ||
40 | } | 43 | } |
41 | 44 | ||
42 | hide() { | 45 | hide() { |
43 | if (this.trayIcon) { | 46 | if (!this.trayIcon) return; |
44 | this.trayIcon.destroy(); | 47 | |
45 | this.trayIcon = null; | 48 | this.trayIcon.destroy(); |
49 | this.trayIcon = null; | ||
50 | |||
51 | if (process.platform === 'darwin' && this.themeChangeSubscriberId) { | ||
52 | systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId); | ||
53 | this.themeChangeSubscriberId = null; | ||
46 | } | 54 | } |
47 | } | 55 | } |
48 | 56 | ||
49 | setIndicator(indicator) { | 57 | setIndicator(indicator) { |
58 | this.indicator = indicator; | ||
59 | this._refreshIcon(); | ||
60 | } | ||
61 | |||
62 | _refreshIcon() { | ||
50 | if (!this.trayIcon) return; | 63 | if (!this.trayIcon) return; |
51 | 64 | ||
52 | this.trayIcon.setImage(this._getAsset('tray', indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN)); | 65 | this.trayIcon.setImage(this._getAsset('tray', this.indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN)); |
53 | 66 | ||
54 | if (process.platform === 'darwin') { | 67 | if (process.platform === 'darwin') { |
55 | this.trayIcon.setPressedImage( | 68 | this.trayIcon.setPressedImage( |
56 | this._getAsset('tray', `${indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`), | 69 | this._getAsset('tray', `${this.indicator !== 0 ? INDICATOR_TRAY_UNREAD : INDICATOR_TRAY_PLAIN}-active`), |
57 | ); | 70 | ); |
58 | } | 71 | } |
59 | } | 72 | } |
60 | 73 | ||
61 | |||
62 | _getAsset(type, asset) { | 74 | _getAsset(type, asset) { |
63 | let platform = process.platform; | 75 | let platform = process.platform; |
64 | 76 | ||