fixes for some styles #209

Merged
Boria138 merged 5 commits from Dervart/PortProtonQt:theme-fix into main 2026-06-28 12:34:05 +00:00
7 changed files with 34 additions and 13 deletions

No files matched your search

+19 -5
View File
@@ -492,6 +492,19 @@ class ClickableLabel(QLabel):
super().leaveEvent(event)
class AutoSizeButton(QPushButton):
def _normalize_padding(self, padding):
if isinstance(padding, int):
return (padding, padding, padding, padding)
if isinstance(padding, (tuple, list)):
if len(padding) == 2:
v, h = padding
return (v, v, h, h) # top=bottom=v, left=right=h
elif len(padding) == 4:
return tuple(padding)
else:
raise ValueError("padding must be tuple of 2 or 4 values")
raise TypeError("padding must be int or tuple/list")
def __init__(self, *args, icon=None, icon_size=16,
min_font_size=6, max_font_size=14, padding=None, update_size=True, **kwargs):
if args and isinstance(args[0], str):
@@ -515,12 +528,13 @@ class AutoSizeButton(QPushButton):
if padding is None:
padding = getattr(self.theme, 'autoSizeButtonPadding', 20)
self._pad_top, self._pad_bottom, self._pad_left, self._pad_right = self._normalize_padding(padding)
self._icon = icon
self._icon_size = icon_size
self._alignment = Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
self._min_font_size = min_font_size
self._max_font_size = max_font_size
self._padding = padding
self._update_size = update_size
self._original_font = self.font()
self._original_text = self.text()
@@ -624,7 +638,7 @@ class AutoSizeButton(QPushButton):
available_width -= self._icon_size
margins = self.contentsMargins()
available_width -= (margins.left() + margins.right() + self._padding * 2)
available_width -= (margins.left() + margins.right() + self._pad_left + self._pad_right)
font = QFont(self._original_font)
text = self._original_text
@@ -643,7 +657,7 @@ class AutoSizeButton(QPushButton):
fm = QFontMetrics(font)
text_width = fm.horizontalAdvance(text)
required_width = text_width + margins.left() + margins.right() + self._padding * 2
required_width = text_width + margins.left() + margins.right() + self._pad_left + self._pad_right
if self._icon:
required_width += self._icon_size
@@ -660,10 +674,10 @@ class AutoSizeButton(QPushButton):
fm = QFontMetrics(font)
text_width = fm.horizontalAdvance(self._original_text)
margins = self.contentsMargins()
width = text_width + margins.left() + margins.right() + self._padding * 2
width = text_width + margins.left() + margins.right() + self._pad_left + self._pad_right
if self._icon:
width += self._icon_size
height = fm.height() + margins.top() + margins.bottom() + self._padding
height = fm.height() + margins.top() + margins.bottom() + self._pad_top + self._pad_bottom
return QSize(width, height)
class NavLabel(QLabel):
+1
View File
@@ -209,6 +209,7 @@ class ThemeStoreMixin:
self.themeStoreDownloadButton.setStyleSheet(self.theme.ACTION_BUTTON_STYLE)
self.themeStoreDownloadButton.clicked.connect(self._download_current_store_theme)
header.addWidget(self.themeStoreDownloadButton)
header.setContentsMargins(0, 0, 0, 20)
return header
def _create_theme_store_detail_body(self) -> AutoHideScrollArea:
@@ -10,6 +10,7 @@ current_theme_name = ui_config.get_theme()
LIBRARY_LAYOUT_MODE = "list"
DETAIL_PAGE_LAYOUT_MODE = "compact"
autoSizeButtonPadding = (0, 20)
portProtonPageMargins = (10, 7, 15, 10)
portProtonPageHorizontalSpacing = 5
portProtonPageVerticalSpacing = 2
+1
View File
@@ -10,6 +10,7 @@ current_theme_name = ui_config.get_theme()
LIBRARY_LAYOUT_MODE = "list"
DETAIL_PAGE_LAYOUT_MODE = "compact"
autoSizeButtonPadding = (0, 20)
portProtonPageMargins = (10, 7, 15, 10)
portProtonPageHorizontalSpacing = 5
portProtonPageVerticalSpacing = 2
+6 -4
View File
@@ -5,6 +5,7 @@ theme_manager = ThemeManager()
current_theme_name = ui_config.get_theme()
# CONSTANTS
autoSizeButtonPadding = (10, 20)
favoriteLabelSize = 48, 48
favoriteLabelIconSize = 32
detailCompactCoverFrameSize = 128
@@ -65,6 +66,7 @@ color_separator = "#7f7f7f"
# Scrollbar
color_scrollbar_bg = "rgba(20, 20, 20, 0.20)"
color_scrollbar_handle = "#bfbfbf"
border_radius_scroll = "5px"
# Slider
color_slider_handle = "#bfbfbf"
@@ -1222,13 +1224,13 @@ SCROLL_STYLE = f"""
QScrollBar:vertical {{
width: 10px;
border: {border_none};
border-radius: 5px;
border-radius: {border_radius_scroll};
background: {color_scrollbar_bg};
}}
QScrollBar::handle:vertical {{
background: {color_scrollbar_handle};
border: {border_none};
border-radius: 5px;
border-radius: {border_radius_scroll};
}}
QScrollBar::add-line:vertical {{
border: {border_none};
@@ -1247,13 +1249,13 @@ SCROLL_STYLE = f"""
QScrollBar:horizontal {{
height: 10px;
border: {border_none};
border-radius: 5px;
border-radius: {border_radius_scroll};
background: {color_scrollbar_bg};
}}
QScrollBar::handle:horizontal {{
background: {color_scrollbar_handle};
border: {border_none};
border-radius: 5px;
border-radius: {border_radius_scroll};
}}
QScrollBar::add-line:horizontal {{
border: {border_none};
+4 -4
View File
@@ -605,13 +605,13 @@ SCROLL_STYLE = f"""
QScrollBar:vertical {{
width: 10px;
border: {border_none};
border-radius: {border_radius_small};
border-radius: {border_radius_scroll};
background: {color_scrollbar_bg};
}}
QScrollBar::handle:vertical {{
background: {color_scrollbar_handle};
border: {border_none};
border-radius: {border_radius_small};
border-radius: {border_radius_scroll};
}}
QScrollBar::add-line:vertical {{
border: {border_none};
@@ -630,13 +630,13 @@ SCROLL_STYLE = f"""
QScrollBar:horizontal {{
height: 10px;
border: {border_none};
border-radius: {border_radius_small};
border-radius: {border_radius_scroll};
background: {color_scrollbar_bg};
}}
QScrollBar::handle:horizontal {{
background: {color_scrollbar_handle};
border: {border_none};
border-radius: {border_radius_small};
border-radius: {border_radius_scroll};
}}
QScrollBar::add-line:horizontal {{
border: {border_none};
@@ -5,6 +5,7 @@ theme_manager = ThemeManager()
current_theme_name = ui_config.get_theme()
# === Layout Constants ===
autoSizeButtonPadding = (10, 20)
favoriteLabelSize = 48, 48
favoriteLabelIconSize = 32
detailCompactCoverFrameSize = 128
@@ -88,6 +89,7 @@ color_separator = "#7f7f7f"
# === Scrollbar ===
color_scrollbar_bg = "rgba(20, 20, 20, 0.30)"
color_scrollbar_handle = "#bebebe"
border_radius_scroll = "5px"
# === Slider ===
color_slider_handle = "#bebebe"