Add QMenu stylesheet

This commit is contained in:
Matthias Metelka 2022-10-09 23:46:32 +02:00
parent 2c0a1dd298
commit 95b715427d
3 changed files with 44 additions and 10 deletions

View file

@ -28,7 +28,8 @@ qlineargradient(
def general_styles(tm: ThemeManager) -> str:
return f"""
QFrame {{
QFrame,
QWidget {{
background: none;
}}
QPushButton,
@ -61,6 +62,36 @@ QToolTip {{
"""
def menu_styles(tm: ThemeManager()) -> str:
return f"""
QMenu {{
background-color: {tm.var(colors.CANVAS_OVERLAY)};
border: 1px solid {tm.var(colors.BORDER)};
padding: 4px;
}}
QMenu::item {{
background-color: transparent;
padding: 3px 10px;
margin-bottom: 4px;
min-width: 120px;
}}
QMenu::item:selected {{
background-color: {tm.var(colors.HIGHLIGHT_BG)};
color: {tm.var(colors.HIGHLIGHT_FG)};
border-radius: {tm.var(props.BORDER_RADIUS)};
}}
QMenu::separator {{
height: 1px;
background: {tm.var(colors.BORDER)};
margin: 0 8px 4px 8px;
}}
QMenu::indicator {{
border-color: {tm.var(colors.BORDER_STRONG)};
margin-left: 2px;
}}
"""
def button_styles(tm: ThemeManager) -> str:
return f"""
QPushButton,
@ -374,16 +405,16 @@ QRadioButton {{
margin: 2px 0;
}}
QCheckBox::indicator,
QRadioButton::indicator {{
QRadioButton::indicator,
QMenu::indicator {{
border: 1px solid {tm.var(colors.BUTTON_BORDER)};
border-radius: {tm.var(props.BORDER_RADIUS)};
background: {tm.var(colors.CANVAS_INSET)};
width: 16px;
height: 16px;
}}
QCheckBox::indicator {{
border-radius: {tm.var(props.BORDER_RADIUS)};
}}
QRadioButton::indicator {{
QRadioButton::indicator,
QMenu::indicator:exclusive {{
border-radius: 8px;
}}
QCheckBox::indicator:hover,
@ -395,7 +426,8 @@ QRadioButton::indicator:checked:hover {{
height: 14px;
}}
QCheckBox::indicator:checked,
QRadioButton::indicator:checked {{
QRadioButton::indicator:checked,
QMenu::indicator:checked {{
image: url({tm.themed_icon("mdi:check")});
}}
QCheckBox::indicator:indeterminate {{

View file

@ -218,6 +218,7 @@ class ThemeManager:
checkbox_styles,
combobox_styles,
general_styles,
menu_styles,
scrollbar_styles,
spinbox_styles,
table_styles,
@ -229,11 +230,12 @@ class ThemeManager:
[
general_styles(self),
button_styles(self),
checkbox_styles(self),
menu_styles(self),
combobox_styles(self),
tabwidget_styles(self),
table_styles(self),
spinbox_styles(self),
checkbox_styles(self),
scrollbar_styles(self),
]
)

View file

@ -56,8 +56,8 @@ $vars: (
dark: palette(darkgray, 6),
),
overlay: (
light: white,
dark: black,
light: palette(lightgray, 0),
dark: palette(darkgray, 5),
),
code: (
light: white,