Skip to content

Commit 5982eae

Browse files
committed
Fix dark theme for autolabeling
1 parent 691f744 commit 5982eae

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

anylabeling/app_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__appname__ = "AnyLabeling"
22
__appdescription__ = "Effortless data labeling with AI support"
3-
__version__ = "0.4.23"
3+
__version__ = "0.4.24"
44
__preferred_device__ = "CPU" # GPU or CPU

anylabeling/views/labeling/widgets/auto_labeling/auto_labeling.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
22

3-
import darkdetect
43
from PyQt5 import uic
54
from PyQt5.QtCore import pyqtSignal, pyqtSlot
65
from PyQt5.QtWidgets import QWidget, QFileDialog
76

87
from anylabeling.services.auto_labeling.model_manager import ModelManager
98
from anylabeling.services.auto_labeling.types import AutoLabelingMode
9+
from anylabeling.styles.theme import AppTheme
1010

1111

1212
class AutoLabelingWidget(QWidget):
@@ -128,38 +128,55 @@ def update_model_configs(self, model_list):
128128

129129
@pyqtSlot()
130130
def update_button_colors(self):
131-
"""Update button colors"""
131+
"""Update button colors based on current theme and mode"""
132132
style_sheet = """
133133
text-align: center;
134134
margin-right: 3px;
135135
border-radius: 5px;
136136
padding: 4px 8px;
137-
border: 1px solid #999999;
137+
border: 1px solid {border_color};
138138
"""
139-
normal_color = "#333333" if darkdetect.isDark() else "#ffffff"
139+
140+
border_color = AppTheme.get_color("border")
141+
normal_bg_color = AppTheme.get_color("button")
142+
normal_text_color = AppTheme.get_color("button_text")
143+
active_bg_color = AppTheme.get_color("success")
144+
remove_bg_color = AppTheme.get_color("error")
145+
highlighted_text_color = AppTheme.get_color("highlighted_text")
146+
147+
normal_style = (
148+
style_sheet.format(border_color=border_color)
149+
+ f"background-color: {normal_bg_color}; color: {normal_text_color};"
150+
)
151+
140152
for button in [
141153
self.button_add_point,
142154
self.button_remove_point,
143155
self.button_add_rect,
144156
self.button_clear,
145157
self.button_finish_object,
146158
]:
147-
button.setStyleSheet(style_sheet + f"background-color: {normal_color};")
159+
button.setStyleSheet(normal_style)
160+
148161
if self.auto_labeling_mode == AutoLabelingMode.NONE:
149162
return
163+
150164
if self.auto_labeling_mode.edit_mode == AutoLabelingMode.ADD:
151165
if self.auto_labeling_mode.shape_type == AutoLabelingMode.POINT:
152166
self.button_add_point.setStyleSheet(
153-
style_sheet + "background-color: #00c100; color: #555555;"
167+
style_sheet.format(border_color=border_color)
168+
+ f"background-color: {active_bg_color}; color: {highlighted_text_color};"
154169
)
155170
elif self.auto_labeling_mode.shape_type == AutoLabelingMode.RECTANGLE:
156171
self.button_add_rect.setStyleSheet(
157-
style_sheet + "background-color: #00c100; color: #555555;"
172+
style_sheet.format(border_color=border_color)
173+
+ f"background-color: {active_bg_color}; color: {highlighted_text_color};"
158174
)
159175
elif self.auto_labeling_mode.edit_mode == AutoLabelingMode.REMOVE:
160176
if self.auto_labeling_mode.shape_type == AutoLabelingMode.POINT:
161177
self.button_remove_point.setStyleSheet(
162-
style_sheet + "background-color: #d30000; color: #fff;"
178+
style_sheet.format(border_color=border_color)
179+
+ f"background-color: {remove_bg_color}; color: {highlighted_text_color};"
163180
)
164181

165182
def set_auto_labeling_mode(self, edit_mode, shape_type=None):

0 commit comments

Comments
 (0)