Skip to content

A full-featured download manager.

fix: tray icon adapts to the dark mode #206 #207

Dr_rOotd5b3ad5933ec
diff --git a/src/main/Application.js b/src/main/Application.js
index 5cfc7464..80d67aaa 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -141,6 +141,7 @@ export default class Application extends EventEmitter {
initThemeManager () {
this.themeManager = new ThemeManager()
this.themeManager.on('system-theme-changed', (theme) => {
+ this.trayManager.changeIconTheme(theme)
this.sendCommandToAll('application:theme', theme)
})
}
diff --git a/src/main/ui/TrayManager.js b/src/main/ui/TrayManager.js
index 88ed7f09..f429ba0c 100644
--- a/src/main/ui/TrayManager.js
+++ b/src/main/ui/TrayManager.js
@@ -1,9 +1,10 @@
import { EventEmitter } from 'events'
import { join } from 'path'
-import { Tray, Menu } from 'electron'
+import { Tray, Menu, systemPreferences } from 'electron'
import is from 'electron-is'
import { translateTemplate } from '../utils/menu'
import { getI18n } from '@/ui/Locale'
+import { LIGHT_THEME, DARK_THEME } from '@shared/constants'
let tray = null
@@ -23,10 +24,11 @@ export default class TrayManager extends EventEmitter {
load () {
this.template = require(`../menus/tray.json`)
+ const theme = systemPreferences.isDarkMode() ? DARK_THEME : LIGHT_THEME
if (is.macOS()) {
- this.normalIcon = join(__static, './mo-tray-normal.png')
- this.activeIcon = join(__static, './mo-tray-active.png')
+ this.normalIcon = join(__static, `./mo-tray-${theme}-normal.png`)
+ this.activeIcon = join(__static, `./mo-tray-${theme}-active.png`)
} else {
this.normalIcon = join(__static, './mo-tray-colorful-normal.png')
this.activeIcon = join(__static, './mo-tray-colorful-active.png')
@@ -91,7 +93,23 @@ export default class TrayManager extends EventEmitter {
}
updateStatus (status) {
- const icon = status ? this.activeIcon : this.normalIcon
+ this.status = status
+ this.updateIcon()
+ }
+
+ updateIcon () {
+ const icon = this.status ? this.activeIcon : this.normalIcon
tray.setImage(icon)
}
+
+ changeIconTheme (theme = LIGHT_THEME) {
+ if (!is.macOS()) {
+ return
+ }
+
+ this.normalIcon = join(__static, `./mo-tray-${theme}-normal.png`)
+ this.activeIcon = join(__static, `./mo-tray-${theme}-active.png`)
+
+ this.updateIcon()
+ }
}
diff --git a/static/mo-tray-active.png b/static/mo-tray-active.png
deleted file mode 100755
index 6511cf0a..00000000
Binary files a/static/mo-tray-active.png and /dev/null differ
diff --git a/static/[email protected] b/static/[email protected]
deleted file mode 100755
index 9583cc38..00000000
Binary files a/static/[email protected] and /dev/null differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..87546dd5
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..87546dd5
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..daec1054
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..daec1054
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..c7db2726
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..c7db2726
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..384d0ae8
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/[email protected] b/static/[email protected]
new file mode 100644
index 00000000..384d0ae8
Binary files /dev/null and b/static/[email protected] differ
diff --git a/static/mo-tray-normal.png b/static/mo-tray-normal.png
deleted file mode 100755
index 5b957f79..00000000
Binary files a/static/mo-tray-normal.png and /dev/null differ
diff --git a/static/[email protected] b/static/[email protected]
deleted file mode 100755
index 2b9af30f..00000000
Binary files a/static/[email protected] and /dev/null differ