Fix spinbox/combobox arrows under custom QSS
Extract text and background colors from QSS and set palette roles (ButtonText, WindowText, Button) so Fusion draws arrows in the correct color. Removed broken spinbox button overrides from themes.
This commit is contained in:
parent
64f685d564
commit
0ec72f41fa
@ -1810,14 +1810,27 @@ def run() -> None:
|
|||||||
app.setStyle("Fusion")
|
app.setStyle("Fusion")
|
||||||
css_text = custom_css.read_text()
|
css_text = custom_css.read_text()
|
||||||
app.setStyleSheet(css_text)
|
app.setStyleSheet(css_text)
|
||||||
# Extract selection color from QSS and apply to palette
|
# Extract colors from QSS and apply to palette for Fusion
|
||||||
import re
|
import re
|
||||||
|
from PySide6.QtGui import QPalette, QColor
|
||||||
|
pal = app.palette()
|
||||||
m = re.search(r'selection-background-color\s*:\s*(#[0-9a-fA-F]{3,8})', css_text)
|
m = re.search(r'selection-background-color\s*:\s*(#[0-9a-fA-F]{3,8})', css_text)
|
||||||
if m:
|
if m:
|
||||||
from PySide6.QtGui import QPalette, QColor
|
|
||||||
pal = app.palette()
|
|
||||||
pal.setColor(QPalette.ColorRole.Highlight, QColor(m.group(1)))
|
pal.setColor(QPalette.ColorRole.Highlight, QColor(m.group(1)))
|
||||||
app.setPalette(pal)
|
# Set text color for spinbox/combobox arrows
|
||||||
|
m = re.search(r'QWidget\s*\{[^}]*?(?:^|\s)color\s*:\s*(#[0-9a-fA-F]{3,8})', css_text, re.MULTILINE)
|
||||||
|
if m:
|
||||||
|
text_color = QColor(m.group(1))
|
||||||
|
pal.setColor(QPalette.ColorRole.ButtonText, text_color)
|
||||||
|
pal.setColor(QPalette.ColorRole.WindowText, text_color)
|
||||||
|
pal.setColor(QPalette.ColorRole.Text, text_color)
|
||||||
|
m = re.search(r'QWidget\s*\{[^}]*?background-color\s*:\s*(#[0-9a-fA-F]{3,8})', css_text, re.MULTILINE)
|
||||||
|
if m:
|
||||||
|
bg_color = QColor(m.group(1))
|
||||||
|
pal.setColor(QPalette.ColorRole.Window, bg_color)
|
||||||
|
pal.setColor(QPalette.ColorRole.Base, bg_color)
|
||||||
|
pal.setColor(QPalette.ColorRole.Button, bg_color.lighter(120))
|
||||||
|
app.setPalette(pal)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.warning(f"Operation failed: {e}")
|
log.warning(f"Operation failed: {e}")
|
||||||
|
|
||||||
|
|||||||
@ -117,12 +117,3 @@ QTabBar::tab:selected {
|
|||||||
background: #45475a;
|
background: #45475a;
|
||||||
color: #cba6f7;
|
color: #cba6f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #313244;
|
|
||||||
border: 1px solid #45475a;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #45475a;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -114,12 +114,3 @@ QTabBar::tab:selected {
|
|||||||
background: #4f585e;
|
background: #4f585e;
|
||||||
color: #a7c080;
|
color: #a7c080;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #343f44;
|
|
||||||
border: 1px solid #4f585e;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #4f585e;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -114,12 +114,3 @@ QTabBar::tab:selected {
|
|||||||
background: #504945;
|
background: #504945;
|
||||||
color: #fe8019;
|
color: #fe8019;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #3c3836;
|
|
||||||
border: 1px solid #504945;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #504945;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -117,12 +117,3 @@ QTabBar::tab:selected {
|
|||||||
color: #88c0d0;
|
color: #88c0d0;
|
||||||
border-bottom-color: #88c0d0;
|
border-bottom-color: #88c0d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #3b4252;
|
|
||||||
border: 1px solid #4c566a;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #434c5e;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -114,12 +114,3 @@ QTabBar::tab:selected {
|
|||||||
background: #586e75;
|
background: #586e75;
|
||||||
color: #fdf6e3;
|
color: #fdf6e3;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #073642;
|
|
||||||
border: 1px solid #586e75;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #586e75;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -114,12 +114,3 @@ QTabBar::tab:selected {
|
|||||||
background: #3b4261;
|
background: #3b4261;
|
||||||
color: #7aa2f7;
|
color: #7aa2f7;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSpinBox::up-button, QSpinBox::down-button {
|
|
||||||
background: #24283b;
|
|
||||||
border: 1px solid #3b4261;
|
|
||||||
width: 16px;
|
|
||||||
}
|
|
||||||
QSpinBox::up-button:hover, QSpinBox::down-button:hover {
|
|
||||||
background: #3b4261;
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user