Skip to content

Commit a382381

Browse files
improve: 更新命令行参数以支持新的OP类型选择
1 parent 362fab3 commit a382381

File tree

7 files changed

+512
-130
lines changed

7 files changed

+512
-130
lines changed

GUI.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from pathlib import Path
44

55
from PyQt6 import QtWidgets
6-
from PyQt6.QtWidgets import QFileDialog, QMessageBox, QLineEdit
6+
from PyQt6.QtWidgets import QFileDialog, QLineEdit, QMessageBox
77

88
from GUI_style import Ui_AutoSubtitle
99
from verifyPath import is_path_exists_or_creatable
@@ -17,12 +17,15 @@ def __init__ (self):
1717
self.videoTypeList.addItems(["全力回避Flag酱","混血万事屋"])
1818
self.videoType = self.videoTypeList.currentIndex()
1919
self.finish = False
20-
self.newOP = True
21-
20+
self.opTpyes = ["远古OP", "旧OP", "新OP-长", "新OP-短"]
21+
self.opTpye = 2
22+
self.FlagOPcomboBox.addItems(self.opTpyes)
23+
self.FlagOPcomboBox.setCurrentIndex(2)
24+
2225
def closeEvent(self, event):
2326
if(not self.finish):
2427
sys.exit()
25-
28+
2629
def updateOpenPath(self):
2730
path = self.OpenFilePathEdit.text()
2831
if (Path(path).is_file() == False):
@@ -42,13 +45,13 @@ def updateOpenPath(self):
4245
self.openPath=path
4346
else:
4447
self.OpenFilePathEdit.clear()
45-
48+
4649
def setSavePathToDefault(self):
4750
path = self.openPath
4851
defaultSavePath = str(path).rstrip(str(path).split('.')[-1])+"ass" if path != '' else os.path.join(os.getcwd(), 'out.ass')
4952
self.SaveFilePathEdit.setText(defaultSavePath)
5053
self.updateSavePath()
51-
54+
5255
def updateSavePath(self):
5356
path = self.SaveFilePathEdit.text()
5457
if (is_path_exists_or_creatable(path) == False):
@@ -57,36 +60,36 @@ def updateSavePath(self):
5760
else:
5861
print(f"将会保存至: {path}")
5962
self.savePath=path
60-
63+
6164
def updateVideoType(self):
6265
self.videoType = self.videoTypeList.currentIndex()
6366
if(self.videoType == 0):
64-
self.FlagNewOPcheckBox.setEnabled(True)
67+
self.FlagOPcomboBox.setEnabled(True)
6568
else:
66-
self.FlagNewOPcheckBox.setEnabled(False)
69+
self.FlagOPcomboBox.setEnabled(False)
6770
print(f'当前视频类型: {str(self.videoType)}')
68-
71+
6972
def raiseOpenFile(self):
7073
filePath,openStatus=QFileDialog.getOpenFileName(self,'选择要打开的文件')
7174
if openStatus:
7275
self.OpenFilePathEdit.setText(filePath)
7376
self.updateOpenPath()
74-
77+
7578
def raiseSaveFile(self):
7679
path = self.openPath
7780
defaultSavePath = os.path.basename(path).rstrip(str(path).split('.')[-1])+"ass" if path != '' else 'out.ass'
7881
filePath,openStatus=QFileDialog.getSaveFileName(self,'选择要保存到的位置', defaultSavePath,'字幕文件 (*.ass)')
7982
if openStatus:
8083
self.SaveFilePathEdit.setText(filePath)
8184
self.updateSavePath()
82-
85+
8386
def checkForm(self,path:str):
8487
return path.split('.')[-1] in ["webm","mp4","mov","flv","mkv","m4v"]
8588

8689
def updateOPstyle(self):
87-
self.newOP = self.FlagNewOPcheckBox.isChecked()
88-
print(f'NewOP: {str(self.newOP)}')
89-
90+
self.opTpye = self.FlagOPcomboBox.currentIndex()
91+
print(f"opType: {self.opTpyes[self.opTpye]}")
92+
9093
def tryToStart(self):
9194
self.updateOpenPath()
9295
self.updateSavePath()
@@ -105,7 +108,12 @@ def runGUI():
105108
GUI_mainWindow.setFixedSize(GUI_mainWindow.width(), GUI_mainWindow.height())
106109
GUI_mainWindow.show()
107110
GUI_APP.exec()
108-
return GUI_mainWindow.openPath,GUI_mainWindow.savePath,GUI_mainWindow.videoType,GUI_mainWindow.newOP
111+
return (
112+
GUI_mainWindow.openPath,
113+
GUI_mainWindow.savePath,
114+
GUI_mainWindow.videoType,
115+
GUI_mainWindow.opTpye,
116+
)
109117

110118
if __name__ == "__main__":
111-
print(runGUI())
119+
print(runGUI())

GUI_style.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class Ui_AutoSubtitle(object):
1313
def setupUi(self, AutoSubtitle):
1414
AutoSubtitle.setObjectName("AutoSubtitle")
15-
AutoSubtitle.resize(635, 204)
15+
AutoSubtitle.resize(635, 205)
1616
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)
1717
sizePolicy.setHorizontalStretch(0)
1818
sizePolicy.setVerticalStretch(0)
@@ -65,7 +65,7 @@ def setupUi(self, AutoSubtitle):
6565
self.videoTypeList.setObjectName("videoTypeList")
6666
self.Title_2 = QtWidgets.QLabel(parent=self.centralwidget)
6767
self.Title_2.setEnabled(True)
68-
self.Title_2.setGeometry(QtCore.QRect(360, 10, 251, 21))
68+
self.Title_2.setGeometry(QtCore.QRect(230, 40, 141, 21))
6969
font = QtGui.QFont()
7070
font.setFamily("等线")
7171
font.setPointSize(13)
@@ -82,10 +82,19 @@ def setupUi(self, AutoSubtitle):
8282
font.setKerning(True)
8383
self.setSavePathToDefaultButton.setFont(font)
8484
self.setSavePathToDefaultButton.setObjectName("setSavePathToDefaultButton")
85-
self.FlagNewOPcheckBox = QtWidgets.QCheckBox(parent=self.centralwidget)
86-
self.FlagNewOPcheckBox.setGeometry(QtCore.QRect(510, 11, 101, 20))
87-
self.FlagNewOPcheckBox.setChecked(True)
88-
self.FlagNewOPcheckBox.setObjectName("FlagNewOPcheckBox")
85+
self.FlagOPcomboBox = QtWidgets.QComboBox(parent=self.centralwidget)
86+
self.FlagOPcomboBox.setGeometry(QtCore.QRect(530, 10, 71, 22))
87+
self.FlagOPcomboBox.setObjectName("FlagOPcomboBox")
88+
self.Title_3 = QtWidgets.QLabel(parent=self.centralwidget)
89+
self.Title_3.setEnabled(True)
90+
self.Title_3.setGeometry(QtCore.QRect(370, 10, 151, 21))
91+
font = QtGui.QFont()
92+
font.setFamily("等线")
93+
font.setPointSize(11)
94+
font.setKerning(True)
95+
font.setStyleStrategy(QtGui.QFont.StyleStrategy.PreferDefault)
96+
self.Title_3.setFont(font)
97+
self.Title_3.setObjectName("Title_3")
8998
AutoSubtitle.setCentralWidget(self.centralwidget)
9099

91100
self.retranslateUi(AutoSubtitle)
@@ -96,8 +105,8 @@ def setupUi(self, AutoSubtitle):
96105
self.SaveFilePathEdit.editingFinished.connect(AutoSubtitle.updateSavePath) # type: ignore
97106
self.videoTypeList.currentIndexChanged['int'].connect(AutoSubtitle.updateVideoType) # type: ignore
98107
self.setSavePathToDefaultButton.clicked.connect(AutoSubtitle.setSavePathToDefault) # type: ignore
99-
self.FlagNewOPcheckBox.stateChanged['int'].connect(AutoSubtitle.updateOPstyle) # type: ignore
100108
self.OpenFilePathEdit.dropAccepted.connect(AutoSubtitle.updateOpenPath) # type: ignore
109+
self.FlagOPcomboBox.currentIndexChanged['int'].connect(AutoSubtitle.updateOPstyle) # type: ignore
101110
QtCore.QMetaObject.connectSlotsByName(AutoSubtitle)
102111

103112
def retranslateUi(self, AutoSubtitle):
@@ -111,5 +120,5 @@ def retranslateUi(self, AutoSubtitle):
111120
self.SaveFilePathEdit.setPlaceholderText(_translate("AutoSubtitle", "请选择轴保存路径"))
112121
self.Title_2.setText(_translate("AutoSubtitle", " 请选择视频类型"))
113122
self.setSavePathToDefaultButton.setText(_translate("AutoSubtitle", "默认"))
114-
self.FlagNewOPcheckBox.setText(_translate("AutoSubtitle", "Flag系列新OP"))
123+
self.Title_3.setText(_translate("AutoSubtitle", "请选择Flag系列OP类型"))
115124
from DragAcceptableQLine import DragAcceptableQLine

GUI_style.ui

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>635</width>
10-
<height>204</height>
10+
<height>205</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -152,9 +152,9 @@
152152
</property>
153153
<property name="geometry">
154154
<rect>
155-
<x>360</x>
156-
<y>10</y>
157-
<width>251</width>
155+
<x>230</x>
156+
<y>40</y>
157+
<width>141</width>
158158
<height>21</height>
159159
</rect>
160160
</property>
@@ -191,21 +191,39 @@
191191
<string>默认</string>
192192
</property>
193193
</widget>
194-
<widget class="QCheckBox" name="FlagNewOPcheckBox">
194+
<widget class="QComboBox" name="FlagOPcomboBox">
195195
<property name="geometry">
196196
<rect>
197-
<x>510</x>
198-
<y>11</y>
199-
<width>101</width>
200-
<height>20</height>
197+
<x>530</x>
198+
<y>10</y>
199+
<width>71</width>
200+
<height>22</height>
201201
</rect>
202202
</property>
203-
<property name="text">
204-
<string>Flag系列新OP</string>
205-
</property>
206-
<property name="checked">
203+
</widget>
204+
<widget class="QLabel" name="Title_3">
205+
<property name="enabled">
207206
<bool>true</bool>
208207
</property>
208+
<property name="geometry">
209+
<rect>
210+
<x>370</x>
211+
<y>10</y>
212+
<width>151</width>
213+
<height>21</height>
214+
</rect>
215+
</property>
216+
<property name="font">
217+
<font>
218+
<family>等线</family>
219+
<pointsize>11</pointsize>
220+
<stylestrategy>PreferDefault</stylestrategy>
221+
<kerning>true</kerning>
222+
</font>
223+
</property>
224+
<property name="text">
225+
<string>请选择Flag系列OP类型</string>
226+
</property>
209227
</widget>
210228
</widget>
211229
</widget>
@@ -334,34 +352,34 @@
334352
</hints>
335353
</connection>
336354
<connection>
337-
<sender>FlagNewOPcheckBox</sender>
338-
<signal>stateChanged(int)</signal>
355+
<sender>OpenFilePathEdit</sender>
356+
<signal>dropAccepted()</signal>
339357
<receiver>AutoSubtitle</receiver>
340-
<slot>updateOPstyle()</slot>
358+
<slot>updateOpenPath()</slot>
341359
<hints>
342360
<hint type="sourcelabel">
343-
<x>584</x>
344-
<y>27</y>
361+
<x>292</x>
362+
<y>85</y>
345363
</hint>
346364
<hint type="destinationlabel">
347-
<x>624</x>
348-
<y>4</y>
365+
<x>293</x>
366+
<y>47</y>
349367
</hint>
350368
</hints>
351369
</connection>
352370
<connection>
353-
<sender>OpenFilePathEdit</sender>
354-
<signal>dropAccepted()</signal>
371+
<sender>FlagOPcomboBox</sender>
372+
<signal>currentIndexChanged(int)</signal>
355373
<receiver>AutoSubtitle</receiver>
356-
<slot>updateOpenPath()</slot>
374+
<slot>updateOPstyle()</slot>
357375
<hints>
358376
<hint type="sourcelabel">
359-
<x>292</x>
360-
<y>85</y>
377+
<x>594</x>
378+
<y>20</y>
361379
</hint>
362380
<hint type="destinationlabel">
363-
<x>293</x>
364-
<y>47</y>
381+
<x>618</x>
382+
<y>20</y>
365383
</hint>
366384
</hints>
367385
</connection>

0 commit comments

Comments
 (0)