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): ...@@ -18,6 +18,8 @@ class Create_Dialog(QDialog, Ui_Dialog):
def choose_root(self): def choose_root(self):
root_info = QFileDialog.getExistingDirectory(self, "选择工程文件夹", os.getcwd()) 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) self.root_input.setText(root_info)
def create_project(self): def create_project(self):
......
...@@ -13,87 +13,99 @@ ...@@ -13,87 +13,99 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<widget class="QWidget" name="gridLayoutWidget"> <layout class="QGridLayout" name="gridLayout_2">
<property name="geometry"> <item row="0" column="0">
<rect> <layout class="QGridLayout" name="gridLayout">
<x>20</x> <property name="topMargin">
<y>50</y> <number>0</number>
<width>361</width> </property>
<height>91</height> <item row="1" column="1">
</rect> <widget class="QLineEdit" name="root_input"/>
</property> </item>
<layout class="QGridLayout" name="gridLayout"> <item row="1" column="2">
<property name="topMargin"> <widget class="QPushButton" name="get_dir">
<number>0</number> <property name="text">
</property> <string>打开文件夹</string>
<item row="1" column="1"> </property>
<widget class="QLineEdit" name="root_input"/> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="0">
<widget class="QPushButton" name="get_dir"> <widget class="QLabel" name="rootLabel">
<property name="text"> <property name="text">
<string>打开文件夹</string> <string>工程文件夹</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QLabel" name="rootLabel"> <widget class="QLabel" name="nameLabel">
<property name="text"> <property name="text">
<string>工程文件夹</string> <string>工程名称</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="1">
<widget class="QLabel" name="nameLabel"> <widget class="QLineEdit" name="name_input"/>
<property name="text"> </item>
<string>工程名称</string> </layout>
</property> </item>
</widget> <item row="1" column="0">
</item> <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1,1,1,1">
<item row="0" column="1"> <item>
<widget class="QLineEdit" name="name_input"/> <spacer name="horizontalSpacer_2">
</item> <property name="orientation">
</layout> <enum>Qt::Horizontal</enum>
</widget> </property>
<widget class="QWidget" name=""> <property name="sizeHint" stdset="0">
<property name="geometry"> <size>
<rect> <width>40</width>
<x>90</x> <height>20</height>
<y>180</y> </size>
<width>201</width> </property>
<height>25</height> </spacer>
</rect> </item>
</property> <item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0"> <widget class="QPushButton" name="confirm">
<item> <property name="text">
<widget class="QPushButton" name="confirm"> <string>确认</string>
<property name="text"> </property>
<string>确认</string> </widget>
</property> </item>
</widget> <item>
</item> <spacer name="horizontalSpacer">
<item> <property name="orientation">
<spacer name="horizontalSpacer"> <enum>Qt::Horizontal</enum>
<property name="orientation"> </property>
<enum>Qt::Horizontal</enum> <property name="sizeHint" stdset="0">
</property> <size>
<property name="sizeHint" stdset="0"> <width>40</width>
<size> <height>20</height>
<width>40</width> </size>
<height>20</height> </property>
</size> </spacer>
</property> </item>
</spacer> <item>
</item> <widget class="QPushButton" name="cancel">
<item> <property name="text">
<widget class="QPushButton" name="cancel"> <string>取消</string>
<property name="text"> </property>
<string>取消</string> </widget>
</property> </item>
</widget> <item>
</item> <spacer name="horizontalSpacer_3">
</layout> <property name="orientation">
</widget> <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> </widget>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -15,42 +15,47 @@ class Ui_Dialog(object): ...@@ -15,42 +15,47 @@ class Ui_Dialog(object):
def setupUi(self, Dialog): def setupUi(self, Dialog):
Dialog.setObjectName("Dialog") Dialog.setObjectName("Dialog")
Dialog.resize(408, 238) Dialog.resize(408, 238)
self.gridLayoutWidget = QtWidgets.QWidget(Dialog) self.gridLayout_2 = QtWidgets.QGridLayout(Dialog)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 50, 361, 91)) self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(-1, 0, -1, -1)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout") 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.root_input.setObjectName("root_input")
self.gridLayout.addWidget(self.root_input, 1, 1, 1, 1) 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.get_dir.setObjectName("get_dir")
self.gridLayout.addWidget(self.get_dir, 1, 2, 1, 1) 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.rootLabel.setObjectName("rootLabel")
self.gridLayout.addWidget(self.rootLabel, 1, 0, 1, 1) 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.nameLabel.setObjectName("nameLabel")
self.gridLayout.addWidget(self.nameLabel, 0, 0, 1, 1) 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.gridLayout.addWidget(self.name_input, 0, 1, 1, 1)
self.widget = QtWidgets.QWidget(Dialog) self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.widget.setGeometry(QtCore.QRect(90, 180, 201, 25)) self.horizontalLayout = QtWidgets.QHBoxLayout()
self.widget.setObjectName("widget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setObjectName("horizontalLayout") 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) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem) 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.cancel.setObjectName("cancel")
self.horizontalLayout.addWidget(self.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(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) self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
...@@ -58,8 +63,8 @@ class Ui_Dialog(object): ...@@ -58,8 +63,8 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog): def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog")) Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.get_dir.setText(_translate("Dialog", "打开文件夹"))
self.rootLabel.setText(_translate("Dialog", "工程文件夹"))
self.nameLabel.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.confirm.setText(_translate("Dialog", "确认"))
self.cancel.setText(_translate("Dialog", "取消")) self.cancel.setText(_translate("Dialog", "取消"))
...@@ -6,110 +6,71 @@ ...@@ -6,110 +6,71 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>632</width> <width>436</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<widget class="QDialogButtonBox" name="buttonBox"> <layout class="QGridLayout" name="gridLayout">
<property name="geometry"> <item row="0" column="2">
<rect> <widget class="QPushButton" name="pushButton">
<x>30</x> <property name="text">
<y>240</y> <string>选择文件</string>
<width>341</width> </property>
<height>32</height> </widget>
</rect> </item>
</property> <item row="1" column="0">
<property name="toolTip"> <widget class="QLabel" name="label_2">
<string/> <property name="text">
</property> <string>输出表格:</string>
<property name="toolTipDuration"> </property>
<number>-1</number> </widget>
</property> </item>
<property name="orientation"> <item row="1" column="1">
<enum>Qt::Horizontal</enum> <widget class="QLineEdit" name="lineEdit_2"/>
</property> </item>
<property name="standardButtons"> <item row="1" column="2">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <widget class="QPushButton" name="pushButton_2">
</property> <property name="text">
<property name="centerButtons"> <string>输出表格路径</string>
<bool>false</bool> </property>
</property> </widget>
</widget> </item>
<widget class="QLabel" name="label"> <item row="0" column="1">
<property name="geometry"> <widget class="QLineEdit" name="lineEdit"/>
<rect> </item>
<x>20</x> <item row="0" column="0">
<y>70</y> <widget class="QLabel" name="label">
<width>72</width> <property name="text">
<height>16</height> <string>视频路径:</string>
</rect> </property>
</property> </widget>
<property name="text"> </item>
<string>视频路径:</string> <item row="2" column="1" alignment="Qt::AlignHCenter">
</property> <widget class="QDialogButtonBox" name="buttonBox">
</widget> <property name="toolTip">
<widget class="QLineEdit" name="lineEdit"> <string/>
<property name="geometry"> </property>
<rect> <property name="toolTipDuration">
<x>100</x> <number>-1</number>
<y>68</y> </property>
<width>211</width> <property name="layoutDirection">
<height>20</height> <enum>Qt::LeftToRight</enum>
</rect> </property>
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
<widget class="QPushButton" name="pushButton"> </property>
<property name="geometry"> <property name="standardButtons">
<rect> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<x>390</x> </property>
<y>63</y> <property name="centerButtons">
<width>110</width> <bool>false</bool>
<height>30</height> </property>
</rect> </widget>
</property> </item>
<property name="text"> </layout>
<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>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>
......
# -*- coding: utf-8 -*- # -*- 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 from PyQt5 import QtCore, QtGui, QtWidgets
...@@ -12,33 +14,36 @@ from PyQt5 import QtCore, QtGui, QtWidgets ...@@ -12,33 +14,36 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object): class Ui_Dialog(object):
def setupUi(self, Dialog): def setupUi(self, Dialog):
Dialog.setObjectName("Dialog") Dialog.setObjectName("Dialog")
Dialog.resize(632, 300) Dialog.resize(436, 300)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32)) self.gridLayout.setObjectName("gridLayout")
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")
self.pushButton = QtWidgets.QPushButton(Dialog) self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(390, 60, 93, 28))
self.pushButton.setObjectName("pushButton") self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 2, 1, 1)
self.label_2 = QtWidgets.QLabel(Dialog) self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(20, 130, 72, 15))
self.label_2.setObjectName("label_2") 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 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(100, 130, 211, 21))
self.lineEdit_2.setObjectName("lineEdit_2") 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 = QtWidgets.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(390, 130, 101, 31))
self.pushButton_2.setObjectName("pushButton_2") 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.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) self.buttonBox.accepted.connect(Dialog.accept)
...@@ -47,10 +52,8 @@ class Ui_Dialog(object): ...@@ -47,10 +52,8 @@ class Ui_Dialog(object):
def retranslateUi(self, Dialog): def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog")) Dialog.setWindowTitle(_translate("Dialog", "检测"))
self.label.setText(_translate("Dialog", "视频路径:")) self.label.setText(_translate("Dialog", "视频路径:"))
self.pushButton.setText(_translate("Dialog", "选择文件")) self.pushButton.setText(_translate("Dialog", "选择文件"))
self.label_2.setText(_translate("Dialog", "输出表格:")) self.label_2.setText(_translate("Dialog", "输出表格:"))
self.pushButton_2.setText(_translate("Dialog", "输出表格路径")) self.pushButton_2.setText(_translate("Dialog", "输出表格路径"))
...@@ -5,12 +5,12 @@ import cv2 ...@@ -5,12 +5,12 @@ import cv2
import qtawesome import qtawesome
from PyQt5 import QtWidgets from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QTableWidget, QTableWidgetItem, QAbstractItemView, QProgressBar, QLabel from PyQt5.QtWidgets import QMainWindow, QFileDialog, QTableWidget, QTableWidgetItem, QAbstractItemView, QProgressBar, QLabel, QApplication
from PyQt5.QtCore import QUrl, Qt, QTimer, QRect from PyQt5.QtCore import QUrl, Qt, QTimer, QRect, pyqtSignal
from PyQt5.QtMultimedia import * from PyQt5.QtMultimedia import *
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
import utils 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 management import RunThread, ProjectContext, Element
from detect_dialog import Detect_Dialog from detect_dialog import Detect_Dialog
from assemble_dialog import Assemble_Dialog from assemble_dialog import Assemble_Dialog
...@@ -28,13 +28,15 @@ import constant ...@@ -28,13 +28,15 @@ import constant
class MainWindow(QMainWindow, Ui_MainWindow): 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__() super(MainWindow, self).__init__()
self.setupUi(self) self.setupUi(self)
self.statusbar.showMessage("hello", 5000) self.statusbar.showMessage("hello", 5000)
self.projectContext = ProjectContext() self.projectContext = ProjectContext()
# 当前主执行的线程
self.threads = [] self.threads = []
# 语音合成相关组件 # 语音合成相关组件
# todo:后续改成QThread的组件 # todo:后续改成QThread的组件
self.synthesis = SynthesisProcessor() self.synthesis = SynthesisProcessor()
...@@ -85,6 +87,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -85,6 +87,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.video_timer.start(1000) # todo 作为参数配置 self.video_timer.start(1000) # todo 作为参数配置
self.refresh_tab_timer = QTimer() self.refresh_tab_timer = QTimer()
self.refresh_tab_timer.timeout.connect(self.refresh_tab_slot) self.refresh_tab_timer.timeout.connect(self.refresh_tab_slot)
""" """
状态栏相关空间 状态栏相关空间
...@@ -119,7 +122,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -119,7 +122,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.import_movie.triggered.connect(self.import_slot) self.import_movie.triggered.connect(self.import_slot)
self.import_movie.setEnabled(False) self.import_movie.setEnabled(False)
self.action_open_project.triggered.connect(self.open_project_slot) 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.triggered.connect(self.export_all)
self.action_export.setEnabled(False) self.action_export.setEnabled(False)
...@@ -129,7 +132,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -129,7 +132,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.action_redo.setEnabled(False) self.action_redo.setEnabled(False)
self.action_view_history.triggered.connect(self.view_history_slot) self.action_view_history.triggered.connect(self.view_history_slot)
self.action_operate.triggered.connect(self.operate_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.triggered.connect(self.insert_aside_from_now_slot)
self.action_insert_aside_from_now.setEnabled(False)
# 状态栏的动作 # 状态栏的动作
# self.statusbar.addPermanentWidget(self.statusbarButton, stretch=0) # self.statusbar.addPermanentWidget(self.statusbarButton, stretch=0)
...@@ -236,6 +241,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -236,6 +241,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.user_editing_aside = False self.user_editing_aside = False
self.user_editing_content = False self.user_editing_content = False
# 记录当前的所有进程
self.all_threads = []
# 更新工程信息
self.projectContext.Init(project_path)
self.update_ui()
# 重写关闭Mmainwindow窗口 # 重写关闭Mmainwindow窗口
def closeEvent(self, event): def closeEvent(self, event):
# buttonBox = QtWidgets.QMessageBox() # buttonBox = QtWidgets.QMessageBox()
...@@ -276,10 +288,24 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -276,10 +288,24 @@ class MainWindow(QMainWindow, Ui_MainWindow):
replp = QtWidgets.QMessageBox.question(self, u'警告', msg, replp = QtWidgets.QMessageBox.question(self, u'警告', msg,
QtWidgets.QMessageBox.Yes) QtWidgets.QMessageBox.Yes)
# 新建工程后,初始化工程 # 新建工程后,初始化界面
def init_project(self, project_path): 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): def import_slot(self):
...@@ -293,24 +319,39 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -293,24 +319,39 @@ class MainWindow(QMainWindow, Ui_MainWindow):
excel_name = os.path.splitext(os.path.basename(video_path))[0] 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.projectContext.excel_path = os.path.join(self.projectContext.project_base_dir, excel_name + ".xlsx")
self.action_export.setEnabled(True) self.action_export.setEnabled(True)
self.action_operate.setEnabled(True)
self.action_insert_aside_from_now.setEnabled(True)
# todo: 后续这段代码公共的可以抽出来 # todo: 后续这段代码公共的可以抽出来
# 打开某个工程
def open_project_slot(self): def open_project_slot(self):
project_path = QFileDialog.getExistingDirectory(self, "选择工程文件夹", os.getcwd()) project_path = QFileDialog.getExistingDirectory(self, "选择工程文件夹", os.getcwd())
print("[import_slot] project_path=" + project_path) print("[import_slot] project_path=" + project_path)
if project_path == "" or project_path == None: if project_path == "" or project_path == None:
return return
self.projectContext.Init(project_path) 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) self.action_export.setEnabled(True)
if self.projectContext.excel_path is not None: if self.projectContext.excel_path is not None:
self.open_excel_with_project_path() 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) self.import_movie.setEnabled(True)
else: else:
self.player.setMedia(QMediaContent(path)) # 选取视频文件 if not os.path.exists(video_path):
self.playVideo() # 播放视频 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): def start_detect(self, video_path, book_path):
"""检测旁白 """检测旁白
...@@ -387,6 +428,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -387,6 +428,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
name="detect") name="detect")
t.setDaemon(True) t.setDaemon(True)
self.threads.append(t) self.threads.append(t)
self.all_threads.append(t)
for t in self.threads: for t in self.threads:
t.start() t.start()
...@@ -549,12 +591,14 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -549,12 +591,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
audio_path = os.path.dirname(self.projectContext.excel_path) + ( audio_path = os.path.dirname(self.projectContext.excel_path) + (
"/tmp/%.2f.wav" % float(self.projectContext.aside_list[i].st_time_sec)) "/tmp/%.2f.wav" % float(self.projectContext.aside_list[i].st_time_sec))
break break
print("previewed_audio:", self.previewed_audio)
# 2、如果找到了该音频并且该次预览中没有播放过,则新起一个线程播放 # 2、如果找到了该音频并且该次预览中没有播放过,则新起一个线程播放
if audio_path != None and os.path.basename(audio_path) not in self.previewed_audio: if audio_path != None and os.path.exists(audio_path) and os.path.basename(audio_path) not in self.previewed_audio:
RunThread(funcName=self.play_audio, t = RunThread(funcName=self.play_audio,
args=(audio_path, self.previewed_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 @staticmethod
# 一条语音的最长播放时间是10秒 # 一条语音的最长播放时间是10秒
...@@ -829,6 +873,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -829,6 +873,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
name="speech_synthesis") name="speech_synthesis")
t.setDaemon(True) t.setDaemon(True)
t.start() t.start()
self.all_threads.append(t)
def is_user_editing(self): def is_user_editing(self):
return self.user_editing_content or self.user_editing_aside return self.user_editing_content or self.user_editing_aside
...@@ -1017,7 +1062,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -1017,7 +1062,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
刷新整个表格 刷新整个表格
""" """
self.set_table_to_window(need_refresh_all=False) self.set_table_to_window(need_refresh_all=False)
# 不需要加这个,因为只要itemchange,就会触发保存的
self.projectContext.save_project(False) self.projectContext.save_project(False)
def export_all(self): def export_all(self):
......
...@@ -344,8 +344,8 @@ class Ui_MainWindow(object): ...@@ -344,8 +344,8 @@ class Ui_MainWindow(object):
self.actiona_4.setObjectName("actiona_4") self.actiona_4.setObjectName("actiona_4")
self.action_view_history = QtWidgets.QAction(MainWindow) self.action_view_history = QtWidgets.QAction(MainWindow)
self.action_view_history.setObjectName("action_view_history") self.action_view_history.setObjectName("action_view_history")
self.action_refresh_tab = QtWidgets.QAction(MainWindow) # self.action_refresh_tab = QtWidgets.QAction(MainWindow)
self.action_refresh_tab.setObjectName("action_refresh_tab") # self.action_refresh_tab.setObjectName("action_refresh_tab")
self.action_operate = QtWidgets.QAction(MainWindow) self.action_operate = QtWidgets.QAction(MainWindow)
self.action_operate.setObjectName("action_operate") self.action_operate.setObjectName("action_operate")
self.action_export = QtWidgets.QAction(MainWindow) self.action_export = QtWidgets.QAction(MainWindow)
...@@ -373,8 +373,8 @@ class Ui_MainWindow(object): ...@@ -373,8 +373,8 @@ class Ui_MainWindow(object):
# self.menu_2.addAction(self.action_insert_subtitle_from_now) # self.menu_2.addAction(self.action_insert_subtitle_from_now)
self.menu_3.addAction(self.actiona_3) self.menu_3.addAction(self.actiona_3)
self.menu_3.addAction(self.actiona_4) self.menu_3.addAction(self.actiona_4)
self.menu_3.addSeparator() # self.menu_3.addSeparator()
self.menu_3.addAction(self.action_refresh_tab) # self.menu_3.addAction(self.action_refresh_tab)
self.menubar.addAction(self.menu.menuAction()) self.menubar.addAction(self.menu.menuAction())
self.menubar.addAction(self.menu_2.menuAction()) self.menubar.addAction(self.menu_2.menuAction())
self.menubar.addAction(self.menu_3.menuAction()) self.menubar.addAction(self.menu_3.menuAction())
...@@ -399,20 +399,20 @@ class Ui_MainWindow(object): ...@@ -399,20 +399,20 @@ class Ui_MainWindow(object):
self.menu.setTitle(_translate("MainWindow", "文件")) self.menu.setTitle(_translate("MainWindow", "文件"))
self.menu_2.setTitle(_translate("MainWindow", "编辑")) self.menu_2.setTitle(_translate("MainWindow", "编辑"))
self.menu_3.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.action_open_project.setText(_translate("MainWindow", "打开"))
self.import_movie.setText(_translate("MainWindow", "视频导入")) self.import_movie.setText(_translate("MainWindow", "视频导入"))
self.actions.setText(_translate("MainWindow", "内容导出")) self.actions.setText(_translate("MainWindow", "内容导出"))
self.action_save.setText(_translate("MainWindow", "保存并备份")) self.action_save.setText(_translate("MainWindow", "保存并备份"))
self.setting.setText(_translate("MainWindow", "设置"))
self.action_undo.setText(_translate("MainWindow", "撤销")) self.action_undo.setText(_translate("MainWindow", "撤销"))
self.action_redo.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_3.setText(_translate("MainWindow", "旁白区间检测"))
self.actiona_4.setText(_translate("MainWindow", "旁白音频合成")) self.actiona_4.setText(_translate("MainWindow", "旁白音频合成"))
self.action_view_history.setText(_translate("MainWindow", "----")) self.action_view_history.setText(_translate("MainWindow", "----"))
self.action_refresh_tab.setText(_translate("MainWindow", "刷新且保存表格")) # self.action_refresh_tab.setText(_translate("MainWindow", "刷新且保存表格"))
self.action_operate.setText(_translate("MainWindow", "操作表格"))
self.action_export.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_insert_subtitle_from_now.setText(_translate("MainWindow", "当前位置插入字幕"))
self.action_create.setText(_translate("MainWindow", "新建"))
This diff is collapsed.
...@@ -152,7 +152,7 @@ class ProjectContext: ...@@ -152,7 +152,7 @@ class ProjectContext:
self.records_pos = 0 self.records_pos = 0
def Init(self, project_dir): 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 return
# 有的时候路径是 '/F:/out1/test.xlsx',有的时候是'F:/out1/test.xlsx' # 有的时候路径是 '/F:/out1/test.xlsx',有的时候是'F:/out1/test.xlsx'
if project_dir[0] == '/': if project_dir[0] == '/':
...@@ -170,16 +170,15 @@ class ProjectContext: ...@@ -170,16 +170,15 @@ class ProjectContext:
return return
with open(self.conf_path, 'r', encoding='utf8') as f: with open(self.conf_path, 'r', encoding='utf8') as f:
info = json.load(f) info = json.load(f)
video_path = info["video_path"] self.video_path = info["video_path"]
excel_path = info["excel_path"] self.excel_path = info["excel_path"]
self.speaker_info = info["speaker_info"]["speaker_id"] self.speaker_info = info["speaker_info"]["speaker_id"]
self.speaker_speed = info["speaker_info"]["speaker_speed"] 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.detected = info["detection_info"]["detected"] self.nd_process = info["detection_info"]["nd_process"]
self.nd_process = info["detection_info"]["nd_process"] self.last_time = info["detection_info"]["last_time"]
self.last_time = info["detection_info"]["last_time"] self.caption_boundings = info["detection_info"]["caption_boundings"]
self.caption_boundings = info["detection_info"]["caption_boundings"] self.has_subtitle = info["detection_info"]["has_subtitle"]
self.has_subtitle = info["detection_info"]["has_subtitle"]
# 当前工程下没有配置文件,就初始化一份 # 当前工程下没有配置文件,就初始化一份
if self.conf_path != this_conf_path: if self.conf_path != this_conf_path:
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 ...@@ -11,19 +11,36 @@ import qdarkstyle
import os import os
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5' os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
project_path = None
def change_project_path(path):
global project_path
project_path = path
if __name__ == '__main__': if __name__ == '__main__':
try: try:
QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps) QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv) # app = QApplication(sys.argv)
app.setWindowIcon(QIcon("./images/eagle_2.ico")) # app.setWindowIcon(QIcon("./images/eagle_2.ico"))
mainWindow = MainWindow() # mainWindow = MainWindow()
mainWindow.setWindowTitle("无障碍电影制作软件") # mainWindow.setWindowTitle("无障碍电影制作软件")
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']))
mainWindow.show() # 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: except Exception as e:
exc_traceback = ''.join( exc_traceback = ''.join(
traceback.format_exception(*sys.exc_info())) traceback.format_exception(*sys.exc_info()))
......
...@@ -2,6 +2,10 @@ import os, sys ...@@ -2,6 +2,10 @@ import os, sys
import openpyxl import openpyxl
import subprocess import subprocess
import re import re
import threading
import time
import inspect
import ctypes
def validate_and_get_filepath(file_info): def validate_and_get_filepath(file_info):
if type(file_info[0]) == str: if type(file_info[0]) == str:
...@@ -107,6 +111,25 @@ def get_progress_with_cmd(cmd: str, state=None): ...@@ -107,6 +111,25 @@ def get_progress_with_cmd(cmd: str, state=None):
print(progress) print(progress)
print("进度:%3.2f" % (progress * 100) + "%") 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__': if __name__ == '__main__':
x = transfer_second_to_time("12000.923") x = transfer_second_to_time("12000.923")
print(x) 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