From eb32a927f18ab9f3fe5ca5acb760e58e0b5fc013 Mon Sep 17 00:00:00 2001 From: NuthX Date: Fri, 8 Nov 2024 14:41:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=E8=AE=BE=E7=BD=AE=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=B7=BB=E5=8A=A0=E6=BB=9A=E5=8A=A8=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现垂直滚动功能 - 调整设置项之间的间距和边距,提高界面可读性 - 调整窗口高度以适应新布局 --- src/gui/setting.py | 59 ++++++++++++++++++++++++--------------- src/style/style_dark.qss | 6 ++++ src/style/style_light.qss | 6 ++++ 3 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/gui/setting.py b/src/gui/setting.py index d82b524..46dbf4a 100644 --- a/src/gui/setting.py +++ b/src/gui/setting.py @@ -1,7 +1,8 @@ -from PySide6.QtWidgets import QLabel, QVBoxLayout, QHBoxLayout, QFrame +from PySide6.QtCore import Qt from PySide6.QtGui import QIcon +from PySide6.QtWidgets import QLabel, QVBoxLayout, QHBoxLayout, QFrame, QWidget from qfluentwidgets import (Theme, setTheme, PushButton, SwitchButton, ComboBox, PrimaryPushButton, EditableComboBox, - LineEdit, setThemeColor, qconfig) + LineEdit, setThemeColor, qconfig, SingleDirectionScrollArea, SmoothMode) from src.module.resource import getResource @@ -10,7 +11,7 @@ class SettingWindow(object): def setupUI(self, this_window): this_window.setWindowTitle("设置") this_window.setWindowIcon(QIcon(getResource("image/icon.png"))) - this_window.resize(800, 600) + this_window.resize(800, 580) this_window.setFixedSize(self.size()) # 禁止拉伸窗口 # ================================================= @@ -121,26 +122,40 @@ def setupUI(self, this_window): self.buttonLayout.addWidget(self.applyButton) self.buttonLayout.addStretch(0) - # 叠叠乐 - + # ================================================= + # 嵌套滚动区域到settingLayout中 + scrollWidget = QWidget() + scrollWidget.setObjectName("scrollWidget") + + # 滚动区域 + scrollArea = SingleDirectionScrollArea(orient=Qt.Vertical) + scrollArea.setWidgetResizable(True) + scrollArea.setSmoothMode(SmoothMode.NO_SMOOTH) # 取消平滑滚动 + scrollArea.setWidget(scrollWidget) + + # 设置布局 + settingLayout = QVBoxLayout(scrollWidget) + settingLayout.setSpacing(8) + settingLayout.setContentsMargins(20, 20, 20, 0) # 上左右下 + settingLayout.addWidget(self.themeTitle) + settingLayout.addWidget(self.themeSelectCard) + settingLayout.addSpacing(12) + settingLayout.addWidget(self.videoTypeTitle) + settingLayout.addWidget(self.videoCard) + settingLayout.addSpacing(12) + settingLayout.addWidget(self.extensionTitle) + settingLayout.addWidget(self.scCard) + settingLayout.addWidget(self.tcCard) + settingLayout.addSpacing(12) + settingLayout.addWidget(self.otherTitle) + settingLayout.addWidget(self.removeSubCard) + settingLayout.addWidget(self.moveSubCard) + settingLayout.addWidget(self.encodeCard) + + # 添加到窗口 layout = QVBoxLayout(this_window) - layout.setSpacing(12) - layout.setContentsMargins(24, 24, 24, 24) - layout.addWidget(self.themeTitle) - layout.addWidget(self.themeSelectCard) - layout.addSpacing(20) - layout.addWidget(self.videoTypeTitle) - layout.addWidget(self.videoCard) - layout.addSpacing(20) - layout.addWidget(self.extensionTitle) - layout.addWidget(self.scCard) - layout.addWidget(self.tcCard) - layout.addSpacing(20) - layout.addWidget(self.otherTitle) - layout.addWidget(self.removeSubCard) - layout.addWidget(self.moveSubCard) - layout.addWidget(self.encodeCard) - layout.addSpacing(12) + layout.setContentsMargins(0, 0, 0, 16) + layout.addWidget(scrollArea) layout.addLayout(self.buttonLayout) def settingCard(self, card_title, card_info, card_func): diff --git a/src/style/style_dark.qss b/src/style/style_dark.qss index 66dcc43..d4649d0 100644 --- a/src/style/style_dark.qss +++ b/src/style/style_dark.qss @@ -42,6 +42,12 @@ MySettingWindow { border-radius: 8px; } +QScrollArea, +#scrollWidget { + background: transparent; + border: none; +} + /* Info */ #versionLabel { diff --git a/src/style/style_light.qss b/src/style/style_light.qss index ca15242..fa5743b 100644 --- a/src/style/style_light.qss +++ b/src/style/style_light.qss @@ -42,6 +42,12 @@ MySettingWindow { border-radius: 8px; } +QScrollArea, +#scrollWidget { + background: transparent; + border: none; +} + /* Info */ #versionLabel {