Fix grid selection highlight with custom QSS themes
Extract selection-background-color from QSS and apply it to the app palette so the grid's custom-painted highlight matches the theme.
This commit is contained in:
parent
0c57251d94
commit
fd476c4967
@ -1639,7 +1639,16 @@ def run() -> None:
|
|||||||
try:
|
try:
|
||||||
# Use Fusion style so QSS has full control over rendering
|
# Use Fusion style so QSS has full control over rendering
|
||||||
app.setStyle("Fusion")
|
app.setStyle("Fusion")
|
||||||
app.setStyleSheet(custom_css.read_text())
|
css_text = custom_css.read_text()
|
||||||
|
app.setStyleSheet(css_text)
|
||||||
|
# Extract selection color from QSS and apply to palette
|
||||||
|
import re
|
||||||
|
m = re.search(r'selection-background-color\s*:\s*(#[0-9a-fA-F]{3,8})', css_text)
|
||||||
|
if m:
|
||||||
|
from PySide6.QtGui import QPalette, QColor
|
||||||
|
pal = app.palette()
|
||||||
|
pal.setColor(QPalette.ColorRole.Highlight, QColor(m.group(1)))
|
||||||
|
app.setPalette(pal)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,8 @@ class ThumbnailWidget(QWidget):
|
|||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def paintEvent(self, event) -> None:
|
def paintEvent(self, event) -> None:
|
||||||
|
# Ensure QSS is applied so palette picks up custom colors
|
||||||
|
self.ensurePolished()
|
||||||
p = QPainter(self)
|
p = QPainter(self)
|
||||||
p.setRenderHint(QPainter.RenderHint.Antialiasing)
|
p.setRenderHint(QPainter.RenderHint.Antialiasing)
|
||||||
pal = self.palette()
|
pal = self.palette()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user