From 1d3f23f6c32ce251336625ac4628d69a510aafb6 Mon Sep 17 00:00:00 2001 From: NuthX Date: Fri, 8 Nov 2024 13:52:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=95=8C=E9=9D=A2=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/setting.py | 55 +++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/src/gui/setting.py b/src/gui/setting.py index 9fa1262..d82b524 100644 --- a/src/gui/setting.py +++ b/src/gui/setting.py @@ -10,115 +10,95 @@ class SettingWindow(object): def setupUI(self, this_window): this_window.setWindowTitle("设置") this_window.setWindowIcon(QIcon(getResource("image/icon.png"))) - this_window.resize(800, -1) + this_window.resize(800, 600) this_window.setFixedSize(self.size()) # 禁止拉伸窗口 - # 标题 - + # ================================================= + # 主题设置 self.themeTitle = QLabel("主题设置") self.themeTitle.setObjectName("settingTitle") self.themeTitle.setIndent(22) - # 设置主题模式 - + # 主题模式 self.themeSelectTitle = QLabel("主题模式") self.themeSelectInfo = QLabel("当前主题:跟随系统") - self.themeSelectSwitch = ComboBox(self) self.themeSelectSwitch.setMinimumWidth(240) self.themeSelectSwitch.setMaximumWidth(240) self.themeSelectSwitch.addItems(["跟随系统", "浅色模式", "深色模式"]) self.themeSelectSwitch.setCurrentIndex(0) # 默认第一个 self.themeSelectSwitch.currentIndexChanged.connect(self.themeSelectFunction) - self.themeSelectCard = self.settingCard(self.themeSelectTitle, self.themeSelectInfo, self.themeSelectSwitch) - # 标题 - + # ================================================= + # 视频格式设置 self.videoTypeTitle = QLabel("视频格式设置") self.videoTypeTitle.setObjectName("settingTitle") self.videoTypeTitle.setIndent(22) - # 简体扩展名 - + # 简体字幕扩展名 self.videoTitle = QLabel("简体字幕扩展名") self.videoInfo = QLabel("用于支持更多视频格式,扩展名使用英文逗号分隔,如 rm, rmvb") - self.videoFormat = LineEdit(self) self.videoFormat.setMinimumWidth(240) self.videoFormat.setMaximumWidth(240) self.videoFormat.setPlaceholderText("默认已支持常见视频文件") - self.videoCard = self.settingCard(self.videoTitle, self.videoInfo, self.videoFormat) - # 标题 - + # ================================================= + # 扩展名设置 self.extensionTitle = QLabel("扩展名设置") self.extensionTitle.setObjectName("settingTitle") self.extensionTitle.setIndent(22) - # 简体扩展名 - + # 简体字幕扩展名 self.scTitle = QLabel("简体字幕扩展名") self.scInfo = QLabel("默认为空,设置后会显示在字幕扩展名之前") - self.scFormat = EditableComboBox(self) self.scFormat.setMinimumWidth(240) self.scFormat.setMaximumWidth(240) self.scFormat.addItems([".sc", ".chs", ".zh-Hans"]) self.scFormat.setPlaceholderText("不添加简体扩展名") - self.scCard = self.settingCard(self.scTitle, self.scInfo, self.scFormat) - # 繁体扩展名 - + # 繁体字幕扩展名 self.tcTitle = QLabel("繁体字幕扩展名") self.tcInfo = QLabel("默认为空,设置后会显示在字幕扩展名之前") - self.tcFormat = EditableComboBox(self) self.tcFormat.setMinimumWidth(240) self.tcFormat.setMaximumWidth(240) self.tcFormat.addItems([".tc", ".cht", ".zh-Hant"]) self.tcFormat.setPlaceholderText("不添加繁体扩展名") - self.tcCard = self.settingCard(self.tcTitle, self.tcInfo, self.tcFormat) - # 标题 - + # ================================================= + # 其他设置 self.otherTitle = QLabel("其他设置") self.otherTitle.setObjectName("settingTitle") self.otherTitle.setIndent(22) - # 删除没有重命名的字幕文件 - + # 删除多余字幕 self.removeSubTitle = QLabel("删除多余字幕") self.removeSubInfo = QLabel("当前操作:没有选择的字幕语言将在重命名后被删除") - self.removeSubSwitch = SwitchButton() self.removeSubSwitch.setChecked(True) # 默认开启 self.removeSubSwitch.checkedChanged.connect(self.removeSubFunction) - self.removeSubCard = self.settingCard(self.removeSubTitle, self.removeSubInfo, self.removeSubSwitch) - # 移动字幕到视频文件夹 - + # 移动字幕文件 self.moveSubTitle = QLabel("移动字幕文件") self.moveSubInfo = QLabel("当前操作:重命名成功后,移动字幕到视频文件夹") - self.moveSubSwitch = ComboBox(self) self.moveSubSwitch.setMinimumWidth(240) self.moveSubSwitch.setMaximumWidth(240) self.moveSubSwitch.addItems(["不移动", "复制字幕", "剪切字幕"]) self.moveSubSwitch.setCurrentIndex(0) # 默认第一个 self.moveSubSwitch.currentIndexChanged.connect(self.moveSubFunction) - self.moveSubCard = self.settingCard(self.moveSubTitle, self.moveSubInfo, self.moveSubSwitch) - # 转换字幕编码至UTF-8 - + # 转换字幕编码 self.encodeTitle = QLabel("转换字幕编码") self.encodeInfo = QLabel("重命名后将字幕编码转换为指定格式") - self.encodeType = ComboBox(self) self.encodeType.setMinimumWidth(240) self.encodeType.setMaximumWidth(240) @@ -126,10 +106,11 @@ def setupUI(self, this_window): self.encodeType.setCurrentIndex(0) # 默认第一个 self.encodeCard = self.settingCard(self.encodeTitle, self.encodeInfo, self.encodeType) + # ================================================= # 按钮 - self.cancelButton = PushButton("取消", self) self.cancelButton.setFixedWidth(120) + self.applyButton = PrimaryPushButton("保存", self) self.applyButton.setFixedWidth(120) From eb32a927f18ab9f3fe5ca5acb760e58e0b5fc013 Mon Sep 17 00:00:00 2001 From: NuthX Date: Fri, 8 Nov 2024 14:41:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E4=B8=BA=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=B7=BB=E5=8A=A0=E6=BB=9A=E5=8A=A8=E5=8C=BA?= =?UTF-8?q?=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 { From 3b361b3de8aedac4c8bdf63065453f00f9f1ecfc Mon Sep 17 00:00:00 2001 From: NuthX Date: Fri, 8 Nov 2024 14:50:39 +0800 Subject: [PATCH 3/3] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E8=87=B3=201.8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.spec | 2 +- src/module/version.py | 2 +- version.py | 2 +- version.txt | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.spec b/build.spec index a343b07..e423e49 100644 --- a/build.spec +++ b/build.spec @@ -49,5 +49,5 @@ app = BUNDLE( name='SubtitleRenamer.app', icon='image/icon.icns', bundle_identifier=None, - version='1.8', + version='1.8.1', ) diff --git a/src/module/version.py b/src/module/version.py index 0b5788f..7d3f9b2 100644 --- a/src/module/version.py +++ b/src/module/version.py @@ -3,7 +3,7 @@ def currentVersion(): - current_version = "1.8" + current_version = "1.8.1" return current_version diff --git a/version.py b/version.py index 16f567d..2fc5cfb 100644 --- a/version.py +++ b/version.py @@ -1,6 +1,6 @@ import re -ver = "1.8" +ver = "1.8.1" ver_sp = [num for num in str(ver).split(".")] if len(ver) == 3: diff --git a/version.txt b/version.txt index ced07e7..34cc2b5 100644 --- a/version.txt +++ b/version.txt @@ -4,8 +4,8 @@ VSVersionInfo( ffi=FixedFileInfo( # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # Set not needed items to zero 0. - filevers=(1, 8, 0, 0), - prodvers=(1, 8, 0, 0), + filevers=(1, 8, 1, 0), + prodvers=(1, 8, 1, 0), # Contains a bitmask that specifies the valid bits. mask=0x3f, # Contains a bitmask that specifies the Boolean attributes of the file. @@ -28,10 +28,10 @@ VSVersionInfo( StringTable( u'080404b0', [StringStruct(u'FileDescription', u'SubtitleRenamer'), - StringStruct(u'FileVersion', u'1.8'), + StringStruct(u'FileVersion', u'1.8.1'), StringStruct(u'LegalCopyright', u'Copyright (C) 2023 NuthX'), StringStruct(u'ProductName', u'SubtitleRenamer'), - StringStruct(u'ProductVersion', u'1.8')]) + StringStruct(u'ProductVersion', u'1.8.1')]) ]), VarFileInfo([VarStruct(u'Translation', [2052, 1200])]) ]