(trayIcon: Icon | null)
| 63 | } |
| 64 | |
| 65 | setTrayIcon(trayIcon: Icon | null) { |
| 66 | if (this.trayIcon == trayIcon || |
| 67 | this.trayIcon?.filePath == trayIcon?.filePath) |
| 68 | return; |
| 69 | if (this.tray) { // remove existing tray |
| 70 | this.tray.remove(); |
| 71 | this.#removeIcon(this.trayIcon); |
| 72 | } |
| 73 | if (trayIcon) { // create new one |
| 74 | if (trayIcon.getImage().getSize().width > 22) |
| 75 | this.trayIcon = this.#resizeIcon(trayIcon, {width: 16, height: 16}); |
| 76 | else |
| 77 | this.trayIcon = trayIcon; |
| 78 | this.tray = gui.Tray.createWithImage(this.trayIcon.getImage()); |
| 79 | if (process.platform != 'darwin') { |
| 80 | this.trayMenu = gui.Menu.create([ |
| 81 | { |
| 82 | label: `Open ${this.service.name}...`, |
| 83 | onClick: this.onActivate.bind(this), |
| 84 | }, |
| 85 | { |
| 86 | label: 'Open in Dashboard...', |
| 87 | onClick: this.onActivateDashboard.bind(this), |
| 88 | }, |
| 89 | ]); |
| 90 | this.tray.setMenu(this.trayMenu); |
| 91 | } |
| 92 | this.tray.onClick = this.onActivate.bind(this); |
| 93 | } else { // remove record |
| 94 | this.tray = null; |
| 95 | this.trayIcon = null; |
| 96 | this.trayMenu = null; |
| 97 | collectGarbage(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | onActivate() { |
| 102 | const windowManager = require('../controller/window-manager').default; |
no test coverage detected