Files
video-subtitle-remover/ui/setting_interface.py
flavioy 0bae013097
Some checks failed
Docker Build and Push / check-secrets (push) Successful in 2s
Docker Build and Push / build-and-push (cpu, latest) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 11.8) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.6) (push) Has been skipped
Docker Build and Push / build-and-push (cuda, 12.8) (push) Has been skipped
Docker Build and Push / build-and-push (directml, latest) (push) Has been skipped
Build Windows CPU / build (push) Has been cancelled
Build Windows CUDA 11.8 / build (push) Has been cancelled
Build Windows CUDA 12.6 / build (push) Has been cancelled
Build Windows CUDA 12.8 / build (push) Has been cancelled
Build Windows DirectML / build (push) Has been cancelled
优化字幕检测算法、添加多语言翻译支持
- 自适应采样间隔:根据视频帧率调整(60fps+→4, 30fps+→3, 低帧率→2)
- filter_and_merge_intervals 复杂度从 O(n²) 优化为 O(n log n)
- detect_subtitle 区域过滤:单区域快速路径,多区域匹配即停
- 插值逻辑改用 zip 预计算 max_gap,更高效
- SubtitleDetectMode 枚举值改为英文key,通过翻译系统显示本地化名称
- 7种语言文件添加 SubtitleDetectMode 翻译(中/繁/英/日/韩/越/西)
- 旧配置值自动迁移兼容

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 00:17:01 +08:00

75 lines
3.3 KiB
Python

from PySide6 import QtWidgets
from qfluentwidgets import (FluentWindow, PushButton, Slider, ProgressBar, PlainTextEdit,
setTheme, Theme, FluentIcon, CardWidget, SettingCardGroup,
ComboBoxSettingCard, SwitchSettingCard, RangeSettingCard,
PushSettingCard, PrimaryPushSettingCard, OptionsSettingCard,
FolderListSettingCard, HyperlinkCard, ColorSettingCard,
CustomColorSettingCard)
from backend.config import config, tr, HARDWARD_ACCELERATION_OPTION
from backend.tools.constant import InpaintMode, SubtitleDetectMode
class SettingInterface(QtWidgets.QVBoxLayout):
def __init__(self, parent):
super().__init__()
self.setContentsMargins(16, 16, 16, 16)
# 界面语言设置
self.interface_combo = ComboBoxSettingCard(
configItem=config.interface,
icon=FluentIcon.LANGUAGE,
title=tr["SubtitleExtractorGUI"]["InterfaceLanguage"],
content="",
parent=parent,
texts=config.intefaceTexts.keys(),
)
self.addWidget(self.interface_combo)
# 处理模式设置
self.inpaint_mode_combo = ComboBoxSettingCard(
configItem=config.inpaintMode,
icon=FluentIcon.GLOBE,
title=tr["SubtitleExtractorGUI"]["InpaintMode"],
content="",
parent=parent,
texts=[list(tr['InpaintMode'].values())[i] for i,_ in enumerate(config.inpaintMode.validator.options)],
)
self.inpaint_mode_combo.setToolTip(tr["SubtitleExtractorGUI"]["InpaintModeDesc"])
self.addWidget(self.inpaint_mode_combo)
self.subtitle_detect_model_combo = ComboBoxSettingCard(
configItem=config.subtitleDetectMode,
icon=FluentIcon.SEARCH,
title=tr["SubtitleExtractorGUI"]["SubtitleDetectMode"],
content="",
parent=parent,
texts=[list(tr['SubtitleDetectMode'].values())[i] for i,_ in enumerate(config.subtitleDetectMode.validator.options)],
)
self.addWidget(self.subtitle_detect_model_combo)
# 是否启用硬件加速
self.hardware_acceleration = SwitchSettingCard(
configItem=config.hardwareAcceleration,
icon=FluentIcon.SPEED_HIGH,
title=tr["Setting"]["HardwareAcceleration"],
content=tr["Setting"]["HardwareAccelerationDesc"],
parent=parent
)
self.addWidget(self.hardware_acceleration)
# 如果硬件加速选项被禁用, 设置硬件加速为False并只读
if not HARDWARD_ACCELERATION_OPTION:
self.hardware_acceleration.switchButton.setChecked(False)
self.hardware_acceleration.switchButton.setEnabled(False)
self.hardware_acceleration.setContent(tr["Setting"]["HardwareAccelerationNO"])
config.set(config.hardwareAcceleration, False)
# 添加一些空间
self.addStretch(1)
def set_inpaint_mode_enabled(self, enabled):
"""启用或禁用 inpaint 模式下拉框"""
self.inpaint_mode_combo.comboBox.setEnabled(enabled)
def reset_setting(self):
"""重置所有设置为默认值"""
# 这里需要实现重置逻辑
pass