Skip to content

Commit

Permalink
merge: dev 1.8.1
Browse files Browse the repository at this point in the history
Dev 1.8.1
  • Loading branch information
nuthx authored Nov 8, 2024
2 parents f8f3a32 + 3b361b3 commit 78cf8e0
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ app = BUNDLE(
name='SubtitleRenamer.app',
icon='image/icon.icns',
bundle_identifier=None,
version='1.8',
version='1.8.1',
)
112 changes: 54 additions & 58 deletions src/gui/setting.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -10,126 +11,107 @@ 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, 580)
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)
self.encodeType.addItems(["Never", "UTF-8", "UTF-8-SIG"])
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)

Expand All @@ -140,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):
Expand Down
2 changes: 1 addition & 1 deletion src/module/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def currentVersion():
current_version = "1.8"
current_version = "1.8.1"
return current_version


Expand Down
6 changes: 6 additions & 0 deletions src/style/style_dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ MySettingWindow {
border-radius: 8px;
}

QScrollArea,
#scrollWidget {
background: transparent;
border: none;
}

/* Info */

#versionLabel {
Expand Down
6 changes: 6 additions & 0 deletions src/style/style_light.qss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ MySettingWindow {
border-radius: 8px;
}

QScrollArea,
#scrollWidget {
background: transparent;
border: none;
}

/* Info */

#versionLabel {
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
8 changes: 4 additions & 4 deletions version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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])])
]
Expand Down

0 comments on commit 78cf8e0

Please sign in to comment.