|
1 | 1 | import os |
2 | 2 |
|
3 | | -import darkdetect |
4 | 3 | from PyQt5 import uic |
5 | 4 | from PyQt5.QtCore import pyqtSignal, pyqtSlot |
6 | 5 | from PyQt5.QtWidgets import QWidget, QFileDialog |
7 | 6 |
|
8 | 7 | from anylabeling.services.auto_labeling.model_manager import ModelManager |
9 | 8 | from anylabeling.services.auto_labeling.types import AutoLabelingMode |
| 9 | +from anylabeling.styles.theme import AppTheme |
10 | 10 |
|
11 | 11 |
|
12 | 12 | class AutoLabelingWidget(QWidget): |
@@ -128,38 +128,55 @@ def update_model_configs(self, model_list): |
128 | 128 |
|
129 | 129 | @pyqtSlot() |
130 | 130 | def update_button_colors(self): |
131 | | - """Update button colors""" |
| 131 | + """Update button colors based on current theme and mode""" |
132 | 132 | style_sheet = """ |
133 | 133 | text-align: center; |
134 | 134 | margin-right: 3px; |
135 | 135 | border-radius: 5px; |
136 | 136 | padding: 4px 8px; |
137 | | - border: 1px solid #999999; |
| 137 | + border: 1px solid {border_color}; |
138 | 138 | """ |
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 | + |
140 | 152 | for button in [ |
141 | 153 | self.button_add_point, |
142 | 154 | self.button_remove_point, |
143 | 155 | self.button_add_rect, |
144 | 156 | self.button_clear, |
145 | 157 | self.button_finish_object, |
146 | 158 | ]: |
147 | | - button.setStyleSheet(style_sheet + f"background-color: {normal_color};") |
| 159 | + button.setStyleSheet(normal_style) |
| 160 | + |
148 | 161 | if self.auto_labeling_mode == AutoLabelingMode.NONE: |
149 | 162 | return |
| 163 | + |
150 | 164 | if self.auto_labeling_mode.edit_mode == AutoLabelingMode.ADD: |
151 | 165 | if self.auto_labeling_mode.shape_type == AutoLabelingMode.POINT: |
152 | 166 | 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};" |
154 | 169 | ) |
155 | 170 | elif self.auto_labeling_mode.shape_type == AutoLabelingMode.RECTANGLE: |
156 | 171 | 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};" |
158 | 174 | ) |
159 | 175 | elif self.auto_labeling_mode.edit_mode == AutoLabelingMode.REMOVE: |
160 | 176 | if self.auto_labeling_mode.shape_type == AutoLabelingMode.POINT: |
161 | 177 | 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};" |
163 | 180 | ) |
164 | 181 |
|
165 | 182 | def set_auto_labeling_mode(self, edit_mode, shape_type=None): |
|
0 commit comments