From bcf8992a9df57aed7341c2fa9ccef9cced8a4973 Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Tue, 16 Aug 2022 22:35:34 +0200 Subject: [PATCH] Define styling for QComboBox and QLineEdit globally --- qt/aqt/data/qt/icons/BUILD.bazel | 3 +++ qt/aqt/theme.py | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/qt/aqt/data/qt/icons/BUILD.bazel b/qt/aqt/data/qt/icons/BUILD.bazel index bf5c44ba4..b3f131a17 100644 --- a/qt/aqt/data/qt/icons/BUILD.bazel +++ b/qt/aqt/data/qt/icons/BUILD.bazel @@ -33,6 +33,9 @@ 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 444af9aff..976124182 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -186,7 +186,33 @@ class ThemeManager: gui_hooks.theme_did_change() def _apply_style(self, app: QApplication) -> None: - buf = "" + 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); +}} + """ if is_win and platform.release() == "10": # day mode is missing a bottom border; background must be