支持设置视频保存路径

This commit is contained in:
Jason
2025-05-22 09:30:24 +08:00
parent 70488eb290
commit afcc93b9cc
12 changed files with 89 additions and 16 deletions

View File

@@ -1,13 +1,17 @@
import os
from pathlib import Path
from enum import Enum, unique
from dataclasses import dataclass
from functools import cached_property
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QAbstractItemView, QTableWidgetItem, QHeaderView
from PySide6.QtCore import Qt, Signal, QModelIndex, QUrl
from qfluentwidgets import TableWidget, BodyLabel, FluentIcon, InfoBar, InfoBarPosition
from PySide6.QtGui import QAction, QColor, QBrush
from showinfm import show_in_file_manager
from backend.config import tr
from backend.config import config, tr
from backend.tools.common_tools import is_image_file
@unique
class TaskStatus(Enum):
@@ -28,8 +32,30 @@ class Task:
name: str
progress: int
status: TaskStatus
output_path: str
options: dict
# 用于储存只读的输出路径, 在任务完成后设置
_output_path: str = None
@property
def output_path(self):
"""获取输出路径"""
if self._output_path is not None:
return self._output_path
save_directory = os.path.dirname(self.path) if not config.saveDirectory.value else config.saveDirectory.value
if self.is_image:
output_path = os.path.abspath(os.path.join(save_directory, f'{Path(self.path).stem}_no_sub.png'))
else:
output_path = os.path.abspath(os.path.join(save_directory, f'{Path(self.path).stem}_no_sub.mp4'))
return output_path
@output_path.setter
def output_path(self, value):
self._output_path = value
@cached_property
def is_image(self):
"""判断是否是图片文件"""
return is_image_file(self.path)
class TaskListComponent(QWidget):
"""任务列表组件"""
@@ -81,7 +107,7 @@ class TaskListComponent(QWidget):
layout.addWidget(self.table)
def add_task(self, video_path, output_path):
def add_task(self, video_path):
"""添加任务到列表
Args:
@@ -102,7 +128,6 @@ class TaskListComponent(QWidget):
name=file_name,
progress=0,
status=TaskStatus.PENDING,
output_path=output_path,
options={},
)
self.tasks.append(task)