Skip to content

Commit

Permalink
Use a frame instead of a ListWidget, trigger visibility when...
Browse files Browse the repository at this point in the history
download is clicked and the repo is invisible
  • Loading branch information
zeptofine committed Nov 5, 2024
1 parent 97a7c2b commit 271b221
Showing 3 changed files with 20 additions and 18 deletions.
23 changes: 12 additions & 11 deletions source/widgets/repo_group.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions source/widgets/repo_visibility_view.py
Original file line number Diff line number Diff line change
@@ -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,<br>\
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():
5 changes: 0 additions & 5 deletions source/widgets/settings_window/blender_builds_tab.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 271b221

Please sign in to comment.