Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [win] [Linux] Icon displays poorly in the taskbar #1258

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ interface ThemeDetector {
isFollowSystem: Boolean,
isUserInDark: Boolean = false,
)

fun addListener(listener: (Boolean) -> Unit)
}

fun Color.darken(amount: Float): Color {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ class DesktopThemeDetector(private val configManager: ConfigManager) : ThemeDete

private var _isUserInDark: Boolean by mutableStateOf(configManager.config.isDarkTheme)

private val listeners: MutableList<(Boolean) -> Unit> = mutableListOf()

init {
detector.registerListener { isDark: Boolean ->
_isSystemInDark = isDark

for (listener in listeners) {
listener(isCurrentThemeDark())
}
}
}

Expand All @@ -41,5 +47,12 @@ class DesktopThemeDetector(private val configManager: ConfigManager) : ThemeDete
_isFollowSystem = isFollowSystem
_isUserInDark = isUserInDark
configManager.updateConfig { it.copy(isFollowSystemTheme = isFollowSystem, isDarkTheme = isUserInDark) }
for (listener in listeners) {
listener(isCurrentThemeDark())
}
}

override fun addListener(listener: (Boolean) -> Unit) {
listeners.add(listener)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,23 @@ object LinuxTrayView {
exitApplication: () -> Unit,
) {
val appWindowManager = koinApplication.koin.get<AppWindowManager>()
val themeDetector = koinApplication.koin.get<ThemeDetector>()
val resourceUtils = getResourceUtils()

systemTray.setImage(resourceUtils.resourceInputStream("icon/clipevery.tray.linux.png"))
themeDetector.addListener {
if (it) {
systemTray.setImage(resourceUtils.resourceInputStream("icon/clipevery.tray.linux.dark.png"))
} else {
systemTray.setImage(resourceUtils.resourceInputStream("icon/clipevery.tray.linux.light.png"))
}
}

if (themeDetector.isCurrentThemeDark()) {
systemTray.setImage(resourceUtils.resourceInputStream("icon/clipevery.tray.linux.dark.png"))
} else {
systemTray.setImage(resourceUtils.resourceInputStream("icon/clipevery.tray.linux.light.png"))
}

systemTray.setTooltip("Clipevery")
systemTray.menu?.add(
MenuItem("Open Clipevery") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ fun WindowsTray() {
val current = LocalKoinApplication.current

val appWindowManager = current.koin.get<AppWindowManager>()
val themeDetector = current.koin.get<ThemeDetector>()
val notificationManager = current.koin.get<NotificationManager>()

val trayIcon = painterResource("icon/clipevery.tray.win.png")
val trayIcon =
if (themeDetector.isCurrentThemeDark()) {
painterResource("icon/clipevery.tray.win.dark.png")
} else {
painterResource("icon/clipevery.tray.win.light.png")
}

var showMenu by remember { mutableStateOf(false) }

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading