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/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: 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..d394c7c5 100644 --- a/portprotonqt/themes/classic/styles.py +++ b/portprotonqt/themes/classic/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/standart-light/styles.py b/portprotonqt/themes/standart-light/styles.py index 6415ffd5..3157b988 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 @@ -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}; diff --git a/portprotonqt/themes/standart/styles/base.py b/portprotonqt/themes/standart/styles/base.py index 34ed513e..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: {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}; diff --git a/portprotonqt/themes/standart/styles/constants.py b/portprotonqt/themes/standart/styles/constants.py index 330e1d2c..16dc653f 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 @@ -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"