mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
Revert QComboBox stylesheet override
This commit is contained in:
parent
ac4c88afdc
commit
b6f9c9a64e
4 changed files with 26 additions and 30 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -33,9 +33,6 @@ copy_mdi_icons(
|
|||
# tags
|
||||
"tag-outline.svg",
|
||||
"tag-off-outline.svg",
|
||||
|
||||
# QComboBox arrow
|
||||
"chevron-down.svg",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue