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