diff --git a/qt/aqt/browser/sidebar/searchbar.py b/qt/aqt/browser/sidebar/searchbar.py index b73d90f12..d8f11f6ee 100644 --- a/qt/aqt/browser/sidebar/searchbar.py +++ b/qt/aqt/browser/sidebar/searchbar.py @@ -6,7 +6,9 @@ from __future__ import annotations import aqt import aqt.browser import aqt.gui_hooks +from aqt import colors from aqt.qt import * +from aqt.theme import theme_manager class SidebarSearchBar(QLineEdit): @@ -18,10 +20,29 @@ class SidebarSearchBar(QLineEdit): self.timer.setInterval(600) self.timer.setSingleShot(True) self.setFrame(False) + self.setup_style() qconnect(self.timer.timeout, self.onSearch) qconnect(self.textChanged, self.onTextChanged) + aqt.gui_hooks.theme_did_change.append(self.setup_style) + + def setup_style(self) -> None: + styles = [ + "padding: 2px", + f"border: 1px solid {theme_manager.color(colors.BORDER)}", + "border-radius: 5px", + ] + + self.setStyleSheet( + "QLineEdit { %s }" % ";".join(styles) + + f""" +QLineEdit:focus {{ + border: 1px solid {theme_manager.color(colors.FOCUS_BORDER)}; +}} + """ + ) + def onTextChanged(self, text: str) -> None: if not self.timer.isActive(): self.timer.start() @@ -36,3 +57,6 @@ class SidebarSearchBar(QLineEdit): self.onSearch() else: QLineEdit.keyPressEvent(self, evt) + + def cleanup(self) -> None: + aqt.gui_hooks.theme_did_change.remove(self.setup_style) diff --git a/qt/aqt/browser/sidebar/tree.py b/qt/aqt/browser/sidebar/tree.py index ebb3fcb90..972e1555e 100644 --- a/qt/aqt/browser/sidebar/tree.py +++ b/qt/aqt/browser/sidebar/tree.py @@ -116,6 +116,7 @@ class SidebarTreeView(QTreeView): def cleanup(self) -> None: self.toolbar.cleanup() + self.searchBar.cleanup() gui_hooks.flag_label_did_change.remove(self.refresh) gui_hooks.theme_did_change.remove(self._setup_style) diff --git a/qt/aqt/data/qt/icons/BUILD.bazel b/qt/aqt/data/qt/icons/BUILD.bazel index b3f131a17..bf5c44ba4 100644 --- a/qt/aqt/data/qt/icons/BUILD.bazel +++ b/qt/aqt/data/qt/icons/BUILD.bazel @@ -33,9 +33,6 @@ copy_mdi_icons( # tags "tag-outline.svg", "tag-off-outline.svg", - - # QComboBox arrow - "chevron-down.svg", ], ) diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index 976124182..444af9aff 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -186,33 +186,7 @@ class ThemeManager: gui_hooks.theme_did_change() def _apply_style(self, app: QApplication) -> None: - buf = f""" -QComboBox, -QLineEdit {{ - border: 1px solid {self.color(colors.BORDER)}; - border-radius: 5px; - padding: 2px; -}} -QComboBox:focus, -QLineEdit:focus {{ - border: 1px solid {self.color(colors.FOCUS_BORDER)}; -}} -QComboBox:on {{ - border-bottom: none; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -}} -QComboBox::drop-down {{ - border: 0px; /* This resets the arrow styles */ - subcontrol-origin: padding; - padding: 4px; - subcontrol-position: top right; - width: 18px; -}} -QComboBox::down-arrow {{ - image: url(icons:chevron-down.svg); -}} - """ + buf = "" if is_win and platform.release() == "10": # day mode is missing a bottom border; background must be