From 271b221d899e79cd85fb3fe105360ae8ff460afb Mon Sep 17 00:00:00 2001 From: zeptofine Date: Mon, 4 Nov 2024 20:10:16 -0500 Subject: [PATCH] Use a frame instead of a ListWidget, trigger visibility when... download is clicked and the repo is invisible --- source/widgets/repo_group.py | 23 ++++++++++--------- source/widgets/repo_visibility_view.py | 10 ++++++-- .../settings_window/blender_builds_tab.py | 5 ---- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/source/widgets/repo_group.py b/source/widgets/repo_group.py index fa67ccb..ad733f6 100644 --- a/source/widgets/repo_group.py +++ b/source/widgets/repo_group.py @@ -7,20 +7,22 @@ get_show_experimental_and_patch_builds, get_show_stable_builds, ) -from PyQt5.QtCore import Qt, pyqtSlot +from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import ( QButtonGroup, - QListWidget, - QListWidgetItem, + QFrame, + QSizePolicy, + QVBoxLayout, ) from widgets.repo_visibility_view import RepoUserView -class RepoGroup(QListWidget): +class RepoGroup(QFrame): def __init__(self, parent=None): super().__init__(parent) - self.setAlternatingRowColors(True) + self.setProperty("SettingsGroup", True) self.setContentsMargins(0, 0, 0, 0) + self.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Maximum) self.stable_repo = RepoUserView( "Stable", @@ -70,17 +72,16 @@ def __init__(self, parent=None): self.bforartists_repo, ] + self.layout_ = QVBoxLayout(self) + self.layout_.setContentsMargins(0, 0, 0, 5) + for widget in self.repos: - item = QListWidgetItem() - item.setSizeHint(widget.sizeHint()) - item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsSelectable) # type: ignore - self.addItem(item) - self.setItemWidget(item, widget) + self.layout_.addWidget(widget) @pyqtSlot() def check_if_both_automated_are_disabled(self): if (not self.daily_repo.library) and (not self.experimental_repo.library): - self.daily_repo.download = False # Will also set experimental_repo + self.daily_repo.download = False # Will also set experimental_repo self.daily_repo.download_enable_button.setEnabled(False) self.experimental_repo.download_enable_button.setEnabled(False) return diff --git a/source/widgets/repo_visibility_view.py b/source/widgets/repo_visibility_view.py index c221740..2f96208 100644 --- a/source/widgets/repo_visibility_view.py +++ b/source/widgets/repo_visibility_view.py @@ -27,6 +27,7 @@ def __init__( parent=None, ): super().__init__(parent) + self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum) self.name = name self.title_label = QLabel(name, self) @@ -58,7 +59,7 @@ def __init__( If you force-check by holding SHIFT while pressing the "Check" button,
\ Then all visible categories will download regardless of fetching settings.' ) - self.download_enable_button.toggled.connect(self.download_changed) + self.download_enable_button.toggled.connect(self.__download_button_toggled) self.previous_download = download or False if download is None: @@ -90,13 +91,18 @@ def __library_button_toggled(self, checked: bool): self.__library_bound_toggle(checked) self.library_changed.emit(checked) + def __download_button_toggled(self, checked: bool): + if not self.library_enable_button.isChecked() and checked: + self.library_enable_button.setChecked(True) + self.download_enable_button.setChecked(checked) + self.download_changed.emit(checked) + def __library_bound_toggle(self, b: bool): if not b: self.previous_download = self.download_enable_button.isChecked() self.download_enable_button.setChecked(False) else: self.download_enable_button.setChecked(self.previous_download) - self.download_enable_button.setEnabled(b) def __library_toggled(self, btn: QCheckBox, checked: bool): if btn is not self and checked != self.library_enable_button.isChecked(): diff --git a/source/widgets/settings_window/blender_builds_tab.py b/source/widgets/settings_window/blender_builds_tab.py index 9fb3791..4793d9a 100644 --- a/source/widgets/settings_window/blender_builds_tab.py +++ b/source/widgets/settings_window/blender_builds_tab.py @@ -47,7 +47,6 @@ QGridLayout, QLabel, QLineEdit, - QListWidget, QSpinBox, QVBoxLayout, ) @@ -64,10 +63,6 @@ def __init__(self, parent=None): self.repo_settings = SettingsGroup("Visibility and Downloading", parent=self) self.repo_group = RepoGroup(self) - self.repo_group.setMinimumHeight(self.repo_group.total_height() + 2) - self.repo_group.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) - self.repo_group.setVerticalScrollMode(QListWidget.ScrollMode.ScrollPerPixel) - self.repo_group.stable_repo.library_changed.connect(lambda b: set_show_stable_builds(b)) self.repo_group.stable_repo.download_changed.connect(self.toggle_scrape_stable_builds) self.repo_group.daily_repo.library_changed.connect(lambda b: set_show_daily_builds(b))