Commit a41348f6 authored by xuanweiace's avatar xuanweiace

优化1:对话框取消后不抹掉文本

优化2:只有旁白tab可编辑 功能1:打开未完成的工程,询问是否继续检测 功能2:主窗口标题,显示工程名 修复1:同时多次运行旁白检测造成的bug
parent 37fd21ce
......@@ -46,7 +46,7 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
def openFile(self):
file_info = QFileDialog.getOpenFileNames(self, '选择视频', os.getcwd(), "All Files(*);;Text Files(*.txt)")
file_name, ok = validate_and_get_filepath(file_info)
if ok:
if ok and file_name != "":
self.lineEdit.setText(file_name)
def openTableFile(self):
......@@ -58,15 +58,14 @@ class Assemble_Dialog(QDialog, Ui_Dialog):
print(file_info)
file_name, ok = validate_and_get_filepath(file_info)
print(file_name, ok)
if ok:
if ok and file_name != "":
self.lineEdit_2.setText(file_name)
def start_assemble(self):
print("start_assemble")
video_path = self.lineEdit.text()
# 现在是默认 输出的音频和字幕路径和视频路径一致
audio_dir = os.path.dirname(self.lineEdit.text())
# audio_dir = replace_path_suffix(self.lineEdit.text(), "")
# 默认 输出的音频是工程目录+/output
audio_dir = self.projectContext.project_base_dir+"output/"
sheet_path = self.lineEdit_2.text()
speaker_info = self.lineEdit_3.text()
speed_info = self.lineEdit_4.text()
......
......@@ -6,7 +6,7 @@ from PyQt5.QtWidgets import *;
from detect_dialog_ui import Ui_Dialog
from utils import validate_and_get_filepath, replace_path_suffix
from prompt_dialog import Prompt_Dialog
class Detect_Dialog(QDialog, Ui_Dialog):
......@@ -22,7 +22,7 @@ class Detect_Dialog(QDialog, Ui_Dialog):
self.pushButton.clicked.connect(self.openFile)
self.pushButton_2.clicked.connect(self.openTableFile)
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).clicked.connect(self.start_detect)
self.prompt_dialog = Prompt_Dialog()
def init_self(self):
self.lineEdit.setText(self.projectContext.video_path)
self.lineEdit_2.setText(self.projectContext.excel_path)
......@@ -31,9 +31,8 @@ class Detect_Dialog(QDialog, Ui_Dialog):
root_dir = os.getcwd() if self.projectContext.video_path is None else os.path.dirname(self.projectContext.video_path)
file_info = QFileDialog.getOpenFileNames(self, '选择视频', root_dir, "Video Files(*.mp4 *.rmvb *mkv *avi)")
file_name, ok = validate_and_get_filepath(file_info)
if ok:
if ok and file_name != "":
self.lineEdit.setText(file_name)
self.lineEdit_2.setText(replace_path_suffix(file_info[0][0], ".xlsx"))
def openTableFile(self):
now_path = os.path.join(os.getcwd(), self.lineEdit.text())
......@@ -43,7 +42,7 @@ class Detect_Dialog(QDialog, Ui_Dialog):
print(file_info)
file_name, ok = validate_and_get_filepath(file_info)
print(file_name, ok)
if ok:
if ok and file_name != "":
self.lineEdit_2.setText(file_name)
def start_detect(self):
......@@ -53,9 +52,10 @@ class Detect_Dialog(QDialog, Ui_Dialog):
# 版本2.0:
# 在主窗口启动时,就启动一个QThread,专门接收该信号并进行检测,
# 发出该信号后,由QThread和主窗口同时接收,然后让他俩通过信号交互即可。
self.start_detect_signal.emit(self.lineEdit.text(), self.lineEdit_2.text())
if self.lineEdit.text()!="" and self.lineEdit_2.text()!="":
self.start_detect_signal.emit(self.lineEdit.text(), self.lineEdit_2.text())
else:
self.prompt_dialog.show_with_msg("检测路径不能为空")
if __name__ == '__main__':
app = QApplication(sys.argv)
......
......@@ -66,6 +66,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 提示框
self.prompt_dialog = Prompt_Dialog()
self.continue_detect_prompt_dialog = Prompt_Dialog(self.continue_detect)
# 操作框
self.operation_dialog = Operation_Dialog(self)
......@@ -137,6 +138,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_operate.setEnabled(False)
self.action_insert_aside_from_now.triggered.connect(self.insert_aside_from_now_slot)
self.action_insert_aside_from_now.setEnabled(False)
self.insert_aside_from_now_btn.clicked.connect(self.insert_aside_from_now_slot)
"""
视频相关信息
......@@ -251,6 +253,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 更新工程信息
self.projectContext.Init(project_path)
# 如果嗅探到旁白检测未完成,则询问是否继续
if self.projectContext.detected == True and self.projectContext.nd_process < 1:
self.continue_detect_prompt_dialog.show_with_msg("您的上次任务未完成,是否继续检测?")
self.update_ui()
# 重写关闭Mmainwindow窗口
......@@ -314,7 +319,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
QApplication.exit(MainWindow.EXIT_CODE_REBOOT)
else:
# 直接在当前界面刷新
project_name = os.path.basename(project_path)
self.setWindowTitle(f"无障碍电影制作软件(当前工程为:{project_name})")
self.projectContext.Init(project_path)
if self.projectContext.detected == True and self.projectContext.nd_process < 1:
self.continue_detect_prompt_dialog.show_with_msg("您的上次任务未完成,是否继续检测?")
self.update_ui()
......@@ -367,6 +376,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.playVideo() # 播放视频
self.action_insert_aside_from_now.setEnabled(True)
def continue_detect(self):
print(f"继续检测,video_path={self.projectContext.video_path}, book_path={self.projectContext.excel_path}")
self.start_detect(self.projectContext.video_path, self.projectContext.excel_path)
def start_detect(self, video_path, book_path):
"""检测旁白
......@@ -376,6 +388,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
函数运行过程中实时监测函数的运行情况,如果发现函数报错,则中断线程,弹出报错窗口,否则等待函数正常结束,并更新UI中的组件。
"""
# 检查是否已有线程在运行旁白检测
if self.threads != []:
self.show_warning_msg_box("请勿重复检测!")
return
# 检测各种输入的合理性
if len(video_path) == 0:
self.show_warning_msg_box("请输入视频文件路径")
......@@ -758,8 +774,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
# 只有Content页的字幕列和 Aside页的字幕列 可编辑
def checkIfTableItemCanChange(self, table: QTableWidget, i: int, j: int):
if table.objectName() == self.all_tableWidget.objectName() and j in constant.Content.ActivateColumns:
return True
# if table.objectName() == self.all_tableWidget.objectName() and j in constant.Content.ActivateColumns:
# return True
if table.objectName() == self.pb_tableWidget.objectName() and j in constant.Aside.ActivateColumns:
return True
return False
......@@ -1043,6 +1059,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.label_2.setText(cur_time + "/" + duration_time)
# video_timer触发timeout信号的时候,会执行该函数,修改高亮行
def change_table_select_rows(self):
cur_time = self.player.position() / 1000
if self.curTab == 0:
......@@ -1051,18 +1068,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if utils.trans_to_seconds(all_elements[i].st_time_sec) <= cur_time:
self.all_tableWidget.selectRow(i)
break
elif self.curTab == 1:
subtitle_list = self.projectContext.subtitle_list
for i in range(len(subtitle_list) - 1, -1, -1):
if utils.trans_to_seconds(subtitle_list[i].st_time_sec) <= cur_time:
self.zm_tableWidget.selectRow(i)
break
else:
aside_list = self.projectContext.aside_list
for i in range(len(aside_list) - 1, -1, -1):
if utils.trans_to_seconds(aside_list[i].st_time_sec) <= cur_time:
self.pb_tableWidget.selectRow(i)
break
# elif self.curTab == 1:
# subtitle_list = self.projectContext.subtitle_list
# for i in range(len(subtitle_list) - 1, -1, -1):
# if utils.trans_to_seconds(subtitle_list[i].st_time_sec) <= cur_time:
# self.zm_tableWidget.selectRow(i)
# break
# else:
# aside_list = self.projectContext.aside_list
# for i in range(len(aside_list) - 1, -1, -1):
# if utils.trans_to_seconds(aside_list[i].st_time_sec) <= cur_time:
# self.pb_tableWidget.selectRow(i)
# break
def player_change_slot(self, new_duration: int):
# 在【打开工程】操作的时候,设置sld_video的最大值为电影秒数。
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>924</width>
<height>763</height>
<width>944</width>
<height>712</height>
</rect>
</property>
<property name="windowTitle">
......@@ -23,13 +23,13 @@
}</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="8">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="5,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="5,2">
<item>
<layout class="QHBoxLayout" name="shuiping" stretch="3,5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="8,1,1">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="8,1,0">
<item>
<widget class="myVideoWidget" name="wgt_video" native="true">
<property name="minimumSize">
......@@ -144,7 +144,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="2,1,2,1,1,1">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="2,1,0,1,1,1">
<item>
<widget class="QLabel" name="label_2">
<property name="maximumSize">
......@@ -324,18 +324,11 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0,0">
<layout class="QHBoxLayout" name="horizontalLayout_6" stretch="0">
<item>
<widget class="QPushButton" name="pickStart">
<widget class="QPushButton" name="insert_aside_from_now_btn">
<property name="text">
<string>选择开始时间</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pickEnd">
<property name="text">
<string>选择终止时间</string>
<string>当前位置插入旁白</string>
</property>
</widget>
</item>
......@@ -420,7 +413,7 @@
</item>
<item>
<widget class="QWidget" name="verticalWidget_2" native="true">
<layout class="QVBoxLayout" name="chuizhi">
<layout class="QVBoxLayout" name="chuizhi" stretch="1,2,1,2">
<item>
<widget class="QLabel" name="zm_label">
<property name="sizePolicy">
......@@ -505,19 +498,6 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="pb_label">
<property name="sizePolicy">
......@@ -584,8 +564,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>924</width>
<height>22</height>
<width>944</width>
<height>26</height>
</rect>
</property>
<widget class="QMenu" name="menu">
......@@ -617,8 +597,8 @@
<property name="title">
<string>功能按键</string>
</property>
<addaction name="actiona_3"/>
<addaction name="actiona_4"/>
<addaction name="action_3"/>
<addaction name="action_4"/>
<addaction name="separator"/>
<addaction name="action_refresh_tab"/>
</widget>
......@@ -662,12 +642,12 @@
<string>重做</string>
</property>
</action>
<action name="actiona_3">
<action name="action_3">
<property name="text">
<string>旁白区间检测</string>
</property>
</action>
<action name="actiona_4">
<action name="action_4">
<property name="text">
<string>旁白音频合成</string>
</property>
......
This diff is collapsed.
......@@ -160,6 +160,8 @@ class ProjectContext:
self.project_base_dir = project_dir
self.load_conf()
def load_conf(self):
this_conf_path = os.path.join(self.project_base_dir, 'conf.ini') if self.project_base_dir is not None else self.conf_path
# 如果当前工程里还没有对应的配置文件,那么选择使用全局的配置文件进行初始化,否则就使用当前工程的配置文件
......
......@@ -20,14 +20,15 @@ class Prompt_Dialog(QDialog, Ui_Dialog):
#开始检测信号,传参分别是movie路径和输出表格路径
show_dialog_signal = pyqtSignal(str)
def __init__(self):
def __init__(self, ok_func = None):
super(Prompt_Dialog, self).__init__()
self.setupUi(self)
self.setWindowTitle("提示框")
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setText("确认")
self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setText("取消")
self.show_dialog_signal.connect(self.show_with_msg)
if ok_func != None:
self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).clicked.connect(ok_func)
def show_with_msg(self, msg):
self.label.setText(msg)
self.show()
\ No newline at end of file
......@@ -34,7 +34,11 @@ if __name__ == '__main__':
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/eagle_2.ico"))
mainWindow = MainWindow(project_path)
mainWindow.setWindowTitle("无障碍电影制作软件")
if project_path == None or project_path == "":
mainWindow.setWindowTitle(f"无障碍电影制作软件(请打开或新建工程)")
else:
project_name = os.path.basename(project_path)
mainWindow.setWindowTitle(f"无障碍电影制作软件(当前工程为:{project_name})")
mainWindow.renew_signal.connect(change_project_path)
apply_stylesheet(app, theme='dark_amber.xml')
# app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB']))
......
......@@ -51,9 +51,9 @@ class SynthesisProcessor(QWidget):
if len(audio_dir) == 0:
self.show_warning_signal.emit("请选择音频存放路径")
return
elif not os.path.exists(audio_dir):
self.show_warning_signal.emit("当前音频存放路径有误,请检查一遍")
return
# elif not os.path.exists(audio_dir):
# self.show_warning_signal.emit("当前音频存放路径有误,请检查一遍")
# return
if len(caption_path) == 0:
self.show_warning_signal.emit("请选择字幕文件存放路径")
return
......@@ -76,7 +76,7 @@ class SynthesisProcessor(QWidget):
self.threads = threads
from speech_synthesis import ss_and_export
t = RunThread(funcName=ss_and_export,
args=(video_path, sheet_path, audio_dir + "output/", speed,
args=(video_path, sheet_path, audio_dir, speed,
caption_path, speaker_name, state),
name="ssAndExport")
t.setDaemon(True)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment