From 8006fa23a29d2253c05aa33a8e432243e2765e56 Mon Sep 17 00:00:00 2001 From: dervart Date: Sun, 28 Jun 2026 18:54:24 +0700 Subject: [PATCH 1/5] feat: AutoSizeButton: allow tuple padding (2 or 4 values) --- portprotonqt/custom_widgets.py | 24 +++++++++++++++---- portprotonqt/themes/classic-light/styles.py | 1 + portprotonqt/themes/classic/styles.py | 2 ++ portprotonqt/themes/standart-light/styles.py | 1 + .../themes/standart/styles/constants.py | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/portprotonqt/custom_widgets.py b/portprotonqt/custom_widgets.py index 4b369cea..c304dc62 100644 --- a/portprotonqt/custom_widgets.py +++ b/portprotonqt/custom_widgets.py @@ -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): diff --git a/portprotonqt/themes/classic-light/styles.py b/portprotonqt/themes/classic-light/styles.py index f7788f49..0b39b27b 100644 --- a/portprotonqt/themes/classic-light/styles.py +++ b/portprotonqt/themes/classic-light/styles.py @@ -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 diff --git a/portprotonqt/themes/classic/styles.py b/portprotonqt/themes/classic/styles.py index 9a8b48a1..90c941a5 100644 --- a/portprotonqt/themes/classic/styles.py +++ b/portprotonqt/themes/classic/styles.py @@ -10,6 +10,8 @@ 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 diff --git a/portprotonqt/themes/standart-light/styles.py b/portprotonqt/themes/standart-light/styles.py index 6415ffd5..3183d707 100644 --- a/portprotonqt/themes/standart-light/styles.py +++ b/portprotonqt/themes/standart-light/styles.py @@ -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 diff --git a/portprotonqt/themes/standart/styles/constants.py b/portprotonqt/themes/standart/styles/constants.py index 330e1d2c..11bb8c66 100644 --- a/portprotonqt/themes/standart/styles/constants.py +++ b/portprotonqt/themes/standart/styles/constants.py @@ -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 -- 2.54.0 From eb707c60bba6954504c952c87f075cdadc2478ed Mon Sep 17 00:00:00 2001 From: dervart Date: Sun, 28 Jun 2026 18:54:42 +0700 Subject: [PATCH 2/5] Update styles.py --- portprotonqt/themes/classic/styles.py | 1 - 1 file changed, 1 deletion(-) diff --git a/portprotonqt/themes/classic/styles.py b/portprotonqt/themes/classic/styles.py index 90c941a5..d394c7c5 100644 --- a/portprotonqt/themes/classic/styles.py +++ b/portprotonqt/themes/classic/styles.py @@ -11,7 +11,6 @@ LIBRARY_LAYOUT_MODE = "list" DETAIL_PAGE_LAYOUT_MODE = "compact" autoSizeButtonPadding = (0, 20) - portProtonPageMargins = (10, 7, 15, 10) portProtonPageHorizontalSpacing = 5 portProtonPageVerticalSpacing = 2 -- 2.54.0 From 1edcb43bb1f1a607b233835138c3f55012bfe7a3 Mon Sep 17 00:00:00 2001 From: dervart Date: Sun, 28 Jun 2026 19:01:50 +0700 Subject: [PATCH 3/5] fix: scrollbar border style --- portprotonqt/themes/standart/styles/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/portprotonqt/themes/standart/styles/base.py b/portprotonqt/themes/standart/styles/base.py index 34ed513e..18ca987b 100644 --- a/portprotonqt/themes/standart/styles/base.py +++ b/portprotonqt/themes/standart/styles/base.py @@ -605,13 +605,13 @@ SCROLL_STYLE = f""" QScrollBar:vertical {{ width: 10px; border: {border_none}; - border-radius: {border_radius_small}; + border-radius: 5px; background: {color_scrollbar_bg}; }} QScrollBar::handle:vertical {{ background: {color_scrollbar_handle}; border: {border_none}; - border-radius: {border_radius_small}; + border-radius: 5px; }} 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: 5px; background: {color_scrollbar_bg}; }} QScrollBar::handle:horizontal {{ background: {color_scrollbar_handle}; border: {border_none}; - border-radius: {border_radius_small}; + border-radius: 5px; }} QScrollBar::add-line:horizontal {{ border: {border_none}; -- 2.54.0 From be6761804ecc1b031c4a72150eae53edf3a1ee71 Mon Sep 17 00:00:00 2001 From: dervart Date: Sun, 28 Jun 2026 19:14:15 +0700 Subject: [PATCH 4/5] fix: ThemeStore add bottom margin to detail header layout --- portprotonqt/tabs/theme_store.py | 1 + 1 file changed, 1 insertion(+) diff --git a/portprotonqt/tabs/theme_store.py b/portprotonqt/tabs/theme_store.py index d37855e2..14dd88b4 100644 --- a/portprotonqt/tabs/theme_store.py +++ b/portprotonqt/tabs/theme_store.py @@ -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: -- 2.54.0 From 7d9463ed043848c2938072693535805fa0f0146e Mon Sep 17 00:00:00 2001 From: dervart Date: Sun, 28 Jun 2026 19:30:21 +0700 Subject: [PATCH 5/5] fix: border-radius to constant --- portprotonqt/themes/standart-light/styles.py | 9 +++++---- portprotonqt/themes/standart/styles/base.py | 8 ++++---- portprotonqt/themes/standart/styles/constants.py | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/portprotonqt/themes/standart-light/styles.py b/portprotonqt/themes/standart-light/styles.py index 3183d707..3157b988 100644 --- a/portprotonqt/themes/standart-light/styles.py +++ b/portprotonqt/themes/standart-light/styles.py @@ -66,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" @@ -1223,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}; @@ -1248,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}; diff --git a/portprotonqt/themes/standart/styles/base.py b/portprotonqt/themes/standart/styles/base.py index 18ca987b..764ec375 100644 --- a/portprotonqt/themes/standart/styles/base.py +++ b/portprotonqt/themes/standart/styles/base.py @@ -605,13 +605,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}; @@ -630,13 +630,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}; diff --git a/portprotonqt/themes/standart/styles/constants.py b/portprotonqt/themes/standart/styles/constants.py index 11bb8c66..16dc653f 100644 --- a/portprotonqt/themes/standart/styles/constants.py +++ b/portprotonqt/themes/standart/styles/constants.py @@ -89,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" -- 2.54.0