The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
fix(Setting): 用 CollapsibleSettingCard 替换 ExpandSettingCard
XiaoYouChR667f0290c675
diff --git a/app/view/components/category_settings.py b/app/view/components/category_settings.pyindex 5d27ed06..da2c643d 100644--- a/app/view/components/category_settings.py+++ b/app/view/components/category_settings.py@@ -1,10 +1,12 @@from PySide6.QtCore import Signalfrom PySide6.QtWidgets import QHBoxLayout, QWidgetfrom qfluentwidgets import (- BodyLabel, ExpandSettingCard, FluentIcon, IconWidget,+ BodyLabel, FluentIcon, IconWidget,PushButton, StrongBodyLabel, ToolButton, ToolTipFilter,)+from app.view.components.setting_card_group import CollapsibleSettingCard+from app.services.category_service import Category, categoryService@@ -58,7 +60,7 @@ class CategoryRowWidget(QWidget):return head-class CategoryRulesCard(ExpandSettingCard):+class CategoryRulesCard(CollapsibleSettingCard):def __init__(self, parent=None):super().__init__(@@ -107,12 +109,6 @@ class CategoryRulesCard(ExpandSettingCard):self.viewLayout.addWidget(self.buttonContainer)self.card.setContent(self.tr("已配置 {0} 个分类").format(len(self._rowWidgets)))- h = sum(row.sizeHint().height() for row in self._rowWidgets)- h += self.buttonContainer.sizeHint().height()- self.spaceWidget.setFixedHeight(h)- if self.isExpand:- self.setFixedHeight(self.card.height() + h)-def _onAddClicked(self) -> None:from app.view.dialogs.category_edit import CategoryEditDialogdialog = CategoryEditDialog(self.window())diff --git a/app/view/components/setting_card_group.py b/app/view/components/setting_card_group.pyindex 3601831c..778265f2 100644--- a/app/view/components/setting_card_group.py+++ b/app/view/components/setting_card_group.py@@ -5,13 +5,13 @@ from PySide6.QtCore import (QPropertyAnimation, QSize, Qt, Signal,)from PySide6.QtGui import QColor, QPainter-from PySide6.QtWidgets import QHBoxLayout, QLabel, QSizePolicy, QVBoxLayout, QWidget+from PySide6.QtWidgets import QApplication, QHBoxLayout, QLabel, QSizePolicy, QVBoxLayout, QWidgetfrom qfluentwidgets import (CardWidget, FluentIcon, FluentIconBase, FluentStyleSheet, SettingCard,StrongBodyLabel, TransparentToolButton, isDarkTheme,)from qfluentwidgets.components.settings.expand_setting_card import (- ExpandBorderWidget, ExpandSettingCard, GroupSeparator,+ ExpandBorderWidget, GroupSeparator, HeaderSettingCard,)from app.config.cfg import cfg@@ -41,6 +41,70 @@ class CardPaintFilter(QObject):return event.type() == QEvent.Type.Paint+class CollapsibleSettingCard(QWidget):++ def __init__(self, icon, title: str, content: str | None = None, parent=None):+ super().__init__(parent)+ self.isExpand = False++ self.card = HeaderSettingCard(icon, title, content, self)+ self.view = QWidget(self)+ self.borderWidget = ExpandBorderWidget(self)++ self._expandAnim = QPropertyAnimation(self.view, QByteArray(b"maximumHeight"), self)+ self._expandAnim.setDuration(200)+ self._expandAnim.setEasingCurve(QEasingCurve.Type.OutCubic)++ self.vBoxLayout = QVBoxLayout(self)+ self.viewLayout = QVBoxLayout(self.view)++ self.view.setMaximumHeight(0)+ self.view.setObjectName("view")+ self.vBoxLayout.setContentsMargins(0, 0, 0, 0)+ self.vBoxLayout.setSpacing(0)+ self.vBoxLayout.addWidget(self.card)+ self.vBoxLayout.addWidget(self.view)+ self.viewLayout.setContentsMargins(0, 0, 0, 0)+ self.viewLayout.setSpacing(0)++ self.card.expandButton.clicked.connect(self._onExpandClicked)+ self._expandAnim.finished.connect(self._onExpandFinished)++ FluentStyleSheet.EXPAND_SETTING_CARD.apply(self.card)+ FluentStyleSheet.EXPAND_SETTING_CARD.apply(self)++ def addWidget(self, widget: QWidget) -> None:+ self.card.addWidget(widget)++ def addGroupWidget(self, widget: QWidget) -> None:+ if self.viewLayout.count() >= 1:+ self.viewLayout.addWidget(GroupSeparator(self.view))+ widget.setParent(self.view)+ self.viewLayout.addWidget(widget)++ def setExpand(self, isExpand: bool) -> None:+ if self.isExpand == isExpand:+ return+ self.isExpand = isExpand+ self.setProperty("isExpand", isExpand)+ self.setStyle(QApplication.style())+ self.card.expandButton.setExpand(isExpand)+ self._expandAnim.stop()+ self._expandAnim.setStartValue(self.view.height())+ self._expandAnim.setEndValue(0 if not isExpand else self.view.sizeHint().height())+ self._expandAnim.start()++ def _onExpandClicked(self) -> None:+ self.setExpand(not self.isExpand)++ def _onExpandFinished(self) -> None:+ if self.isExpand:+ self.view.setMaximumHeight(QWIDGETSIZE_MAX)++ def setValue(self, value) -> None:+ pass++class CollapsibleSettingCardGroup(CardWidget):orderChanged = Signal()@@ -109,7 +173,7 @@ class CollapsibleSettingCardGroup(CardWidget):def addSettingCard(self, card: SettingCard) -> None:self.cardLayout.addWidget(card)targets: list[QWidget] = [card]- if isinstance(card, ExpandSettingCard):+ if isinstance(card, CollapsibleSettingCard):targets += card.findChildren(SettingCard)targets += card.findChildren(ExpandBorderWidget)targets += card.findChildren(GroupSeparator)diff --git a/app/view/components/setting_cards.py b/app/view/components/setting_cards.pyindex c2740503..34014e3f 100644--- a/app/view/components/setting_cards.py+++ b/app/view/components/setting_cards.py@@ -12,12 +12,14 @@ from PySide6.QtWidgets import ()from qfluentwidgets import (SettingCard, PushSettingCard, RangeConfigItem, SpinBox, DoubleSpinBox,- ExpandGroupSettingCard, ConfigItem, FluentIcon, BodyLabel, CaptionLabel,+ ConfigItem, FluentIcon, BodyLabel, CaptionLabel,RadioButton, ComboBox, LineEdit, ToolButton, ToolTipFilter,PrimaryPushButton, InfoBar, InfoBarPosition,IconWidget,)+from app.view.components.setting_card_group import CollapsibleSettingCard+from app.config.cfg import cfg, proxy, BASE_HEADERSfrom app.view.components.banners import WarningBanner@@ -131,7 +133,7 @@ class LineEditSettingCard(SettingCard):)-class ProxySettingCard(ExpandGroupSettingCard):+class ProxySettingCard(CollapsibleSettingCard):def __init__(self, configItem: ConfigItem, parent=None):super().__init__(FluentIcon.GLOBE, self.tr("代理"),@@ -298,10 +300,6 @@ class ProxySettingCard(ExpandGroupSettingCard):else:self.compatBanner.hide()- h = self.viewLayout.sizeHint().height()- self.spaceWidget.setFixedHeight(h)- if self.isExpand:- self.setFixedHeight(self.card.height() + h)def _buildProxyUrl(self) -> str:protocol = self.protocolCombo.currentText()