Commit dbd553fd authored by 翟艳秋(20软)'s avatar 翟艳秋(20软)

feat: make the dialogs adaptive and modify the reaction of create project

parent 3f1a5604
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'd:\AddCaption\cur_version\accessibility_movie_2\create_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(408, 238)
self.gridLayoutWidget = QtWidgets.QWidget(Dialog)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 50, 361, 91))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.root_input = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.root_input.setObjectName("root_input")
self.gridLayout.addWidget(self.root_input, 1, 1, 1, 1)
self.get_dir = QtWidgets.QPushButton(self.gridLayoutWidget)
self.get_dir.setObjectName("get_dir")
self.gridLayout.addWidget(self.get_dir, 1, 2, 1, 1)
self.rootLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.rootLabel.setObjectName("rootLabel")
self.gridLayout.addWidget(self.rootLabel, 1, 0, 1, 1)
self.nameLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.nameLabel.setObjectName("nameLabel")
self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 1)
self.name_input = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.name_input.setObjectName("name_input")
self.gridLayout.addWidget(self.name_input, 0, 1, 1, 1)
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setGeometry(QtCore.QRect(90, 180, 201, 25))
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.confirm = QtWidgets.QPushButton(self.widget)
self.confirm.setObjectName("confirm")
self.horizontalLayout.addWidget(self.confirm)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.cancel = QtWidgets.QPushButton(self.widget)
self.cancel.setObjectName("cancel")
self.horizontalLayout.addWidget(self.cancel)
self.horizontalLayout.setStretch(0, 1)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.get_dir.setText(_translate("Dialog", "打开文件夹"))
self.rootLabel.setText(_translate("Dialog", "工程文件夹"))
self.nameLabel.setText(_translate("Dialog", "工程名称"))
self.confirm.setText(_translate("Dialog", "确认"))
self.cancel.setText(_translate("Dialog", "取消"))
......@@ -18,6 +18,8 @@ class Create_Dialog(QDialog, Ui_Dialog):
def choose_root(self):
root_info = QFileDialog.getExistingDirectory(self, "选择工程文件夹", os.getcwd())
if len(self.root_input.text()) != 0 and len(root_info) == 0:
return
self.root_input.setText(root_info)
def create_project(self):
......
......@@ -13,87 +13,99 @@
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>361</width>
<height>91</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QLineEdit" name="root_input"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="get_dir">
<property name="text">
<string>打开文件夹</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="rootLabel">
<property name="text">
<string>工程文件夹</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>工程名称</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name_input"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>90</x>
<y>180</y>
<width>201</width>
<height>25</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0">
<item>
<widget class="QPushButton" name="confirm">
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancel">
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
</layout>
</widget>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QLineEdit" name="root_input"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="get_dir">
<property name="text">
<string>打开文件夹</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="rootLabel">
<property name="text">
<string>工程文件夹</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>工程名称</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name_input"/>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="confirm">
<property name="text">
<string>确认</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancel">
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
......
......@@ -15,42 +15,47 @@ class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(408, 238)
self.gridLayoutWidget = QtWidgets.QWidget(Dialog)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 50, 361, 91))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout_2 = QtWidgets.QGridLayout(Dialog)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setContentsMargins(-1, 0, -1, -1)
self.gridLayout.setObjectName("gridLayout")
self.root_input = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.name_input = QtWidgets.QLineEdit(Dialog)
self.name_input.setObjectName("name_input")
self.root_input = QtWidgets.QLineEdit(Dialog)
self.root_input.setObjectName("root_input")
self.gridLayout.addWidget(self.root_input, 1, 1, 1, 1)
self.get_dir = QtWidgets.QPushButton(self.gridLayoutWidget)
self.get_dir = QtWidgets.QPushButton(Dialog)
self.get_dir.setObjectName("get_dir")
self.gridLayout.addWidget(self.get_dir, 1, 2, 1, 1)
self.rootLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.rootLabel = QtWidgets.QLabel(Dialog)
self.rootLabel.setObjectName("rootLabel")
self.gridLayout.addWidget(self.rootLabel, 1, 0, 1, 1)
self.nameLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.nameLabel = QtWidgets.QLabel(Dialog)
self.nameLabel.setObjectName("nameLabel")
self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 1)
self.name_input = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.name_input.setObjectName("name_input")
self.gridLayout.addWidget(self.name_input, 0, 1, 1, 1)
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setGeometry(QtCore.QRect(90, 180, 201, 25))
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.confirm = QtWidgets.QPushButton(self.widget)
self.confirm.setObjectName("confirm")
self.horizontalLayout.addWidget(self.confirm)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.cancel = QtWidgets.QPushButton(self.widget)
self.confirm = QtWidgets.QPushButton(Dialog)
self.confirm.setObjectName("confirm")
self.horizontalLayout.addWidget(self.confirm)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem1)
self.cancel = QtWidgets.QPushButton(Dialog)
self.cancel.setObjectName("cancel")
self.horizontalLayout.addWidget(self.cancel)
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem2)
self.horizontalLayout.setStretch(0, 1)
self.horizontalLayout.setStretch(1, 1)
self.horizontalLayout.setStretch(2, 1)
self.horizontalLayout.setStretch(3, 1)
self.horizontalLayout.setStretch(4, 1)
self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
......@@ -58,8 +63,8 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.get_dir.setText(_translate("Dialog", "打开文件夹"))
self.rootLabel.setText(_translate("Dialog", "工程文件夹"))
self.nameLabel.setText(_translate("Dialog", "工程名称"))
self.rootLabel.setText(_translate("Dialog", "工程文件夹"))
self.get_dir.setText(_translate("Dialog", "打开文件夹"))
self.confirm.setText(_translate("Dialog", "确认"))
self.cancel.setText(_translate("Dialog", "取消"))
......@@ -6,110 +6,71 @@
<rect>
<x>0</x>
<y>0</y>
<width>632</width>
<width>436</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="toolTip">
<string/>
</property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>72</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>视频路径:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>100</x>
<y>68</y>
<width>211</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>390</x>
<y>63</y>
<width>110</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>选择文件</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>72</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>输出表格:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2">
<property name="geometry">
<rect>
<x>100</x>
<y>128</y>
<width>211</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>390</x>
<y>123</y>
<width>110</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>输出表格路径</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>选择文件</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>输出表格:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>输出表格路径</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>视频路径:</string>
</property>
</widget>
</item>
<item row="2" column="1" alignment="Qt::AlignHCenter">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="toolTip">
<string/>
</property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
......
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'detect_dialog.ui'
# Form implementation generated from reading ui file 'd:\AddCaption\cur_version\accessibility_movie_2\detect_dialog.ui'
#
# Created by: PyQt5 UI code generator 5.12
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -12,33 +14,36 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(632, 300)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
self.buttonBox.setToolTip("")
self.buttonBox.setToolTipDuration(-1)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(False)
self.buttonBox.setObjectName("buttonBox")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 70, 72, 15))
self.label.setObjectName("label")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(100, 70, 211, 21))
self.lineEdit.setObjectName("lineEdit")
Dialog.resize(436, 300)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(390, 60, 93, 28))
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 2, 1, 1)
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 130, 72, 15))
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(100, 130, 211, 21))
self.lineEdit_2.setObjectName("lineEdit_2")
self.gridLayout.addWidget(self.lineEdit_2, 1, 1, 1, 1)
self.pushButton_2 = QtWidgets.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(390, 130, 101, 31))
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout.addWidget(self.pushButton_2, 1, 2, 1, 1)
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setObjectName("lineEdit")
self.gridLayout.addWidget(self.lineEdit, 0, 1, 1, 1)
self.label = QtWidgets.QLabel(Dialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setToolTip("")
self.buttonBox.setToolTipDuration(-1)
self.buttonBox.setLayoutDirection(QtCore.Qt.LeftToRight)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setCenterButtons(False)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 2, 1, 1, 1, QtCore.Qt.AlignHCenter)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
......@@ -47,10 +52,8 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
Dialog.setWindowTitle(_translate("Dialog", "检测"))
self.label.setText(_translate("Dialog", "视频路径:"))
self.pushButton.setText(_translate("Dialog", "选择文件"))
self.label_2.setText(_translate("Dialog", "输出表格:"))
self.pushButton_2.setText(_translate("Dialog", "输出表格路径"))
......@@ -5,12 +5,12 @@ import cv2
import qtawesome
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QTableWidget, QTableWidgetItem, QAbstractItemView, QProgressBar, QLabel
from PyQt5.QtCore import QUrl, Qt, QTimer, QRect
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QTableWidget, QTableWidgetItem, QAbstractItemView, QProgressBar, QLabel, QApplication
from PyQt5.QtCore import QUrl, Qt, QTimer, QRect, pyqtSignal
from PyQt5.QtMultimedia import *
from PyQt5.QtGui import QIcon
import utils
from utils import validate_and_get_filepath
from utils import validate_and_get_filepath, stop_thread
from management import RunThread, ProjectContext, Element
from detect_dialog import Detect_Dialog
from assemble_dialog import Assemble_Dialog
......@@ -28,13 +28,15 @@ import constant
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
EXIT_CODE_REBOOT = -12345678
renew_signal = pyqtSignal(str)
def __init__(self, project_path):
super(MainWindow, self).__init__()
self.setupUi(self)
self.statusbar.showMessage("hello", 5000)
self.projectContext = ProjectContext()
# 当前主执行的线程
self.threads = []
# 语音合成相关组件
# todo:后续改成QThread的组件
self.synthesis = SynthesisProcessor()
......@@ -85,6 +87,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.video_timer.start(1000) # todo 作为参数配置
self.refresh_tab_timer = QTimer()
self.refresh_tab_timer.timeout.connect(self.refresh_tab_slot)
"""
状态栏相关空间
......@@ -119,7 +122,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.import_movie.triggered.connect(self.import_slot)
self.import_movie.setEnabled(False)
self.action_open_project.triggered.connect(self.open_project_slot)
self.action_refresh_tab.triggered.connect(self.refresh_tab_slot)
# self.action_refresh_tab.triggered.connect(self.refresh_tab_slot)
self.action_export.triggered.connect(self.export_all)
self.action_export.setEnabled(False)
......@@ -129,7 +132,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_redo.setEnabled(False)
self.action_view_history.triggered.connect(self.view_history_slot)
self.action_operate.triggered.connect(self.operate_slot)
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.statusbar.addPermanentWidget(self.statusbarButton, stretch=0)
......@@ -236,6 +241,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.user_editing_aside = False
self.user_editing_content = False
# 记录当前的所有进程
self.all_threads = []
# 更新工程信息
self.projectContext.Init(project_path)
self.update_ui()
# 重写关闭Mmainwindow窗口
def closeEvent(self, event):
# buttonBox = QtWidgets.QMessageBox()
......@@ -276,10 +288,24 @@ class MainWindow(QMainWindow, Ui_MainWindow):
replp = QtWidgets.QMessageBox.question(self, u'警告', msg,
QtWidgets.QMessageBox.Yes)
# 新建工程后,初始化工程
# 新建工程后,初始化界面
def init_project(self, project_path):
self.projectContext.Init(project_path)
self.import_movie.setEnabled(True)
# 如果目前界面中正在处理其他工程,需要让用户确认是否退出当前界面
replp = QtWidgets.QMessageBox.question(self, u'警告', u'是否退出当前工程?',
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
if replp == QtWidgets.QMessageBox.Yes:
self.projectContext.save_project(False)
print("emit close Event")
# 把其他进程结束掉
for t in self.all_threads:
if t.is_alive():
stop_thread(t)
# 把project_path传递给start,在mainwindow初始化的时候传参进来
self.renew_signal.emit(project_path)
# 关闭当前窗口,刷新得到一个新窗口
QApplication.exit(MainWindow.EXIT_CODE_REBOOT)
# 导入视频
def import_slot(self):
......@@ -293,24 +319,39 @@ class MainWindow(QMainWindow, Ui_MainWindow):
excel_name = os.path.splitext(os.path.basename(video_path))[0]
self.projectContext.excel_path = os.path.join(self.projectContext.project_base_dir, excel_name + ".xlsx")
self.action_export.setEnabled(True)
self.action_operate.setEnabled(True)
self.action_insert_aside_from_now.setEnabled(True)
# todo: 后续这段代码公共的可以抽出来
# 打开某个工程
def open_project_slot(self):
project_path = QFileDialog.getExistingDirectory(self, "选择工程文件夹", os.getcwd())
print("[import_slot] project_path=" + project_path)
if project_path == "" or project_path == None:
return
self.projectContext.Init(project_path)
self.update_ui()
def update_ui(self):
if self.projectContext.project_base_dir is None:
return
self.action_export.setEnabled(True)
if self.projectContext.excel_path is not None:
self.open_excel_with_project_path()
if self.projectContext.video_path is None:
self.action_operate.setEnabled(True)
# 如果这个工程之前没有检测的视频,那么就需要将导入视频的按钮设置为可点,否则就直接导入对应的视频
video_path = self.projectContext.video_path
if video_path is None:
self.import_movie.setEnabled(True)
else:
self.player.setMedia(QMediaContent(path)) # 选取视频文件
self.playVideo() # 播放视频
if not os.path.exists(video_path):
self.prompt_dialog.show_dialog_signal.emit(f"该工程原检测的视频对应路径{video_path}目前已失效,请导入新的视频重新开始检测或移动视频到对应位置,并重新启动工程")
self.import_movie.setEnabled(True)
else:
self.player.setMedia(QMediaContent(QUrl(video_path))) # 选取视频文件
self.playVideo() # 播放视频
self.action_insert_aside_from_now.setEnabled(True)
def start_detect(self, video_path, book_path):
"""检测旁白
......@@ -387,6 +428,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
name="detect")
t.setDaemon(True)
self.threads.append(t)
self.all_threads.append(t)
for t in self.threads:
t.start()
......@@ -549,12 +591,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
audio_path = os.path.dirname(self.projectContext.excel_path) + (
"/tmp/%.2f.wav" % float(self.projectContext.aside_list[i].st_time_sec))
break
print("previewed_audio:", self.previewed_audio)
# 2、如果找到了该音频并且该次预览中没有播放过,则新起一个线程播放
if audio_path != None and os.path.basename(audio_path) not in self.previewed_audio:
RunThread(funcName=self.play_audio,
if audio_path != None and os.path.exists(audio_path) and os.path.basename(audio_path) not in self.previewed_audio:
t = RunThread(funcName=self.play_audio,
args=(audio_path, self.previewed_audio),
name="play_audio").start()
name="play_audio")
t.start()
self.all_threads.append(t)
print("previewed_audio:", self.previewed_audio)
@staticmethod
# 一条语音的最长播放时间是10秒
......@@ -829,6 +873,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
name="speech_synthesis")
t.setDaemon(True)
t.start()
self.all_threads.append(t)
def is_user_editing(self):
return self.user_editing_content or self.user_editing_aside
......@@ -1017,7 +1062,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
刷新整个表格
"""
self.set_table_to_window(need_refresh_all=False)
# 不需要加这个,因为只要itemchange,就会触发保存的
self.projectContext.save_project(False)
def export_all(self):
......
......@@ -344,8 +344,8 @@ class Ui_MainWindow(object):
self.actiona_4.setObjectName("actiona_4")
self.action_view_history = QtWidgets.QAction(MainWindow)
self.action_view_history.setObjectName("action_view_history")
self.action_refresh_tab = QtWidgets.QAction(MainWindow)
self.action_refresh_tab.setObjectName("action_refresh_tab")
# self.action_refresh_tab = QtWidgets.QAction(MainWindow)
# self.action_refresh_tab.setObjectName("action_refresh_tab")
self.action_operate = QtWidgets.QAction(MainWindow)
self.action_operate.setObjectName("action_operate")
self.action_export = QtWidgets.QAction(MainWindow)
......@@ -373,8 +373,8 @@ class Ui_MainWindow(object):
# self.menu_2.addAction(self.action_insert_subtitle_from_now)
self.menu_3.addAction(self.actiona_3)
self.menu_3.addAction(self.actiona_4)
self.menu_3.addSeparator()
self.menu_3.addAction(self.action_refresh_tab)
# self.menu_3.addSeparator()
# self.menu_3.addAction(self.action_refresh_tab)
self.menubar.addAction(self.menu.menuAction())
self.menubar.addAction(self.menu_2.menuAction())
self.menubar.addAction(self.menu_3.menuAction())
......@@ -399,20 +399,20 @@ class Ui_MainWindow(object):
self.menu.setTitle(_translate("MainWindow", "文件"))
self.menu_2.setTitle(_translate("MainWindow", "编辑"))
self.menu_3.setTitle(_translate("MainWindow", "功能按键"))
self.setting.setText(_translate("MainWindow", "设置"))
self.action_create.setText(_translate("MainWindow", "新建"))
self.action_open_project.setText(_translate("MainWindow", "打开"))
self.import_movie.setText(_translate("MainWindow", "视频导入"))
self.actions.setText(_translate("MainWindow", "内容导出"))
self.action_save.setText(_translate("MainWindow", "保存并备份"))
self.setting.setText(_translate("MainWindow", "设置"))
self.action_undo.setText(_translate("MainWindow", "撤销"))
self.action_redo.setText(_translate("MainWindow", "重做"))
self.action_insert_aside_from_now.setText(_translate("MainWindow", "当前位置插入旁白"))
self.action_operate.setText(_translate("MainWindow", "操作表格"))
self.actiona_3.setText(_translate("MainWindow", "旁白区间检测"))
self.actiona_4.setText(_translate("MainWindow", "旁白音频合成"))
self.action_view_history.setText(_translate("MainWindow", "----"))
self.action_refresh_tab.setText(_translate("MainWindow", "刷新且保存表格"))
self.action_operate.setText(_translate("MainWindow", "操作表格"))
# self.action_refresh_tab.setText(_translate("MainWindow", "刷新且保存表格"))
self.action_export.setText(_translate("MainWindow", "导出"))
self.action_insert_aside_from_now.setText(_translate("MainWindow", "当前位置插入旁白"))
# self.action_insert_subtitle_from_now.setText(_translate("MainWindow", "当前位置插入字幕"))
self.action_create.setText(_translate("MainWindow", "新建"))
This diff is collapsed.
......@@ -152,7 +152,7 @@ class ProjectContext:
self.records_pos = 0
def Init(self, project_dir):
if len(project_dir) == 0 or project_dir is None:
if project_dir is None or not os.path.exists(project_dir):
return
# 有的时候路径是 '/F:/out1/test.xlsx',有的时候是'F:/out1/test.xlsx'
if project_dir[0] == '/':
......@@ -170,16 +170,15 @@ class ProjectContext:
return
with open(self.conf_path, 'r', encoding='utf8') as f:
info = json.load(f)
video_path = info["video_path"]
excel_path = info["excel_path"]
self.video_path = info["video_path"]
self.excel_path = info["excel_path"]
self.speaker_info = info["speaker_info"]["speaker_id"]
self.speaker_speed = info["speaker_info"]["speaker_speed"]
if video_path == self.video_path and excel_path == self.excel_path:
self.detected = info["detection_info"]["detected"]
self.nd_process = info["detection_info"]["nd_process"]
self.last_time = info["detection_info"]["last_time"]
self.caption_boundings = info["detection_info"]["caption_boundings"]
self.has_subtitle = info["detection_info"]["has_subtitle"]
self.detected = info["detection_info"]["detected"]
self.nd_process = info["detection_info"]["nd_process"]
self.last_time = info["detection_info"]["last_time"]
self.caption_boundings = info["detection_info"]["caption_boundings"]
self.has_subtitle = info["detection_info"]["has_subtitle"]
# 当前工程下没有配置文件,就初始化一份
if self.conf_path != this_conf_path:
self.conf_path = this_conf_path
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,19 +11,36 @@ import qdarkstyle
import os
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
project_path = None
def change_project_path(path):
global project_path
project_path = path
if __name__ == '__main__':
try:
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/eagle_2.ico"))
mainWindow = MainWindow()
mainWindow.setWindowTitle("无障碍电影制作软件")
apply_stylesheet(app, theme='dark_amber.xml')
# app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB']))
mainWindow.show()
# app = QApplication(sys.argv)
# app.setWindowIcon(QIcon("./images/eagle_2.ico"))
# mainWindow = MainWindow()
# mainWindow.setWindowTitle("无障碍电影制作软件")
# apply_stylesheet(app, theme='dark_amber.xml')
# # app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB']))
# mainWindow.show()
# sys.exit(app.exec_())
currentExitCode = MainWindow.EXIT_CODE_REBOOT
sys.exit(app.exec_())
while currentExitCode == MainWindow.EXIT_CODE_REBOOT:
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/eagle_2.ico"))
mainWindow = MainWindow(project_path)
mainWindow.setWindowTitle("无障碍电影制作软件")
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']))
mainWindow.show()
currentExitCode = app.exec_()
app = None
except Exception as e:
exc_traceback = ''.join(
traceback.format_exception(*sys.exc_info()))
......
......@@ -2,6 +2,10 @@ import os, sys
import openpyxl
import subprocess
import re
import threading
import time
import inspect
import ctypes
def validate_and_get_filepath(file_info):
if type(file_info[0]) == str:
......@@ -107,6 +111,25 @@ def get_progress_with_cmd(cmd: str, state=None):
print(progress)
print("进度:%3.2f" % (progress * 100) + "%")
def _async_raise(tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")
def stop_thread(thread):
_async_raise(thread.ident, SystemExit)
if __name__ == '__main__':
x = transfer_second_to_time("12000.923")
print(x)
......
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