Skip to content

The only downloader you need. 下载器的集大成者。

feat(setting): 添加百分比调节设置卡片组件以修复界面缩放配置项无效

XiaoYouChRd4075265c4ed
diff --git a/app/view/components/setting_cards.py b/app/view/components/setting_cards.py
index 90305740..90ec38ae 100644
--- a/app/view/components/setting_cards.py
+++ b/app/view/components/setting_cards.py
@@ -9,7 +9,7 @@ from PySide6.QtWidgets import (
QSpacerItem, QSizePolicy, QFileDialog,
)
from qfluentwidgets import (
- SettingCard, PushSettingCard, RangeConfigItem, SpinBox,
+ SettingCard, PushSettingCard, RangeConfigItem, SpinBox, DoubleSpinBox,
ExpandGroupSettingCard, ConfigItem, FluentIcon, BodyLabel, CaptionLabel,
RadioButton, ComboBox, LineEdit, ToolButton, ToolTipFilter,
PrimaryPushButton, InfoBar, InfoBarPosition,
@@ -50,6 +50,36 @@ class SpinBoxSettingCard(SettingCard):
cfg.set(self._configItem, int(self.spinBox.value() / self._division))
+class PercentSpinBoxSettingCard(SettingCard):
+
+ def __init__(self, icon, title: str, content: str = "",
+ configItem: RangeConfigItem = None, parent=None,
+ singleStep: float = 25):
+ super().__init__(icon, title, content, parent)
+ self._configItem = configItem
+
+ self.spinBox = DoubleSpinBox(self)
+ self.spinBox.setDecimals(0)
+ self.spinBox.setSingleStep(singleStep)
+ self.spinBox.setMinimumWidth(180)
+ self.spinBox.setSuffix(" %")
+ self.spinBox.installEventFilter(self)
+ r = configItem.range
+ self.spinBox.setRange(r[0] * 100, r[1] * 100)
+ self.spinBox.setValue(configItem.value * 100)
+
+ self.hBoxLayout.addWidget(self.spinBox)
+ self.hBoxLayout.addSpacing(24)
+
+ def eventFilter(self, watched, event):
+ if event.type() == QEvent.Type.Wheel:
+ return True
+ return super().eventFilter(watched, event)
+
+ def leaveEvent(self, event):
+ cfg.set(self._configItem, self.spinBox.value() / 100)
+
+
class LineEditSettingCard(SettingCard):
def __init__(self, icon, title: str, content: str = "",
diff --git a/app/view/pages/setting_page.py b/app/view/pages/setting_page.py
index 91974372..03639e28 100644
--- a/app/view/pages/setting_page.py
+++ b/app/view/pages/setting_page.py
@@ -23,7 +23,7 @@ from app.view.components.category_settings import CategoryRulesCard
from app.view.components.setting_card_group import CollapsibleSettingCardGroup
from app.view.components.setting_cards import (
ClientProfileSettingCard, DefaultHeadersSettingCard, LineEditSettingCard,
- ProxySettingCard, SpinBoxSettingCard,
+ PercentSpinBoxSettingCard, ProxySettingCard, SpinBoxSettingCard,
)
from app.view.components.editors import FolderPicker
@@ -210,10 +210,10 @@ class SettingPage(ScrollArea):
),
])
- self.zoomCard = SpinBoxSettingCard(
+ self.zoomCard = PercentSpinBoxSettingCard(
FluentIcon.ZOOM, self.tr("界面缩放"),
self.tr("改变应用程序界面的缩放比例, 0% 为自动"),
- suffix=" %", configItem=cfg.dpiScale, division=100,
+ configItem=cfg.dpiScale,
)
personalCards = [