Skip to content

Commit 486f850

Browse files
committed
fix: only set dark theme on success
1 parent e1b2c20 commit 486f850

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Lib/RabbitCandidateBox.ahk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class CandidateBox extends Gui {
5151
}
5252

5353
UpdateUIStyle() {
54-
global IS_DARK_MODE
5554
local back_color_val := UIStyle.back_color & 0xffffff ; alpha not supported
5655
local text_color := Format("c{:x}", UIStyle.text_color & 0xffffff)
5756
local font_point := Format("S{:d}", UIStyle.font_point)
@@ -61,7 +60,7 @@ class CandidateBox extends Gui {
6160
this.pre.SetFont(Format("{} {}", font_point, text_color), font_face)
6261
this.lv.Opt(Format("{} Background0x{:x}", text_color, back_color_val))
6362

64-
if IS_DARK_MODE {
63+
if UIStyle.use_dark {
6564
DllCall("uxtheme\SetWindowTheme", "ptr", this.lv.hwnd, "WStr", "DarkMode_Explorer", "ptr", 0)
6665
DllCall("uxtheme\SetWindowTheme", "ptr", this.lv.hwnd, "WStr", "DarkMode_ItemsView", "ptr", 0)
6766
} else {

Lib/RabbitConfig.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class RabbitConfig {
6262
UIStyle.Update(config, true)
6363
if IS_DARK_MODE := RabbitIsUserDarkMode() {
6464
if color_name := rime.config_get_string(config, "style/color_scheme_dark")
65-
UIStyle.UpdateColor(config, color_name)
65+
UIStyle.use_dark := UIStyle.UpdateColor(config, color_name)
6666
}
6767

6868
rime.config_close(config)

Lib/RabbitUIStyle.ahk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#Include <RabbitCommon>
2020

2121
class UIStyle {
22+
static use_dark := false
2223
static text_color := 0xff000000
2324
static back_color := 0xffeceeee
2425
static font_face := "Microsoft YaHei UI"
@@ -28,6 +29,7 @@ class UIStyle {
2829
global rime
2930
if !rime || !config
3031
return
32+
UIStyle.use_dark := false
3133
UIStyle.font_face := rime.config_get_string(config, "style/font_face")
3234
if not UIStyle.font_face
3335
UIStyle.font_face := "Microsoft YaHei UI"
@@ -58,7 +60,7 @@ class UIStyle {
5860

5961
static GetColor(config, key, fmt, fallback) {
6062
global rime
61-
if not color := rime.config_get_string(config, key)
63+
if not rime.config_test_get_string(config, key, &color)
6264
return fallback
6365

6466
local val := fallback
@@ -135,7 +137,7 @@ OnColorChange(wParam, lParam, msg, hWnd) {
135137
UIStyle.Update(config, true)
136138
if IS_DARK_MODE {
137139
if color_name := rime.config_get_string(config, "style/color_scheme_dark")
138-
UIStyle.UpdateColor(config, color_name)
140+
UIStyle.use_dark := UIStyle.UpdateColor(config, color_name)
139141
}
140142

141143
rime.config_close(config)

0 commit comments

Comments
 (0)