-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexportAllWindow.py
More file actions
116 lines (103 loc) · 4 KB
/
exportAllWindow.py
File metadata and controls
116 lines (103 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from uip import ui_exportAllWindow
from PySide6 import QtWidgets
import path_saver, os, exportingWindow, api
class ExportAllWindow(ui_exportAllWindow.Ui_Dialog, QtWidgets.QDialog):
SAFE_QSS = """QPushButton{
padding-left:21px;
padding-right:21px;
padding-top:10.5px;
padding-bottom:10.5px;
background-color: rgb(13, 110, 253);
color: rgb(255, 255, 255);
}
QPushButton:hover{
background-color: rgb(11, 94, 215);
}
QPushButton:disabled{
color: rgb(175, 177, 180);
background-color: rgb(43, 86, 180);
}"""
DANGER_QSS = """QPushButton{
padding-left:21px;
padding-right:21px;
padding-top:10.5px;
padding-bottom:10.5px;
background-color: rgb(220, 53, 69);
color: rgb(255, 255, 255);
}
QPushButton:hover{
background-color: rgb(187, 45, 59);
}"""
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setupUi(self)
self.exporting_window = None
self.connectSignals()
def connectSignals(self):
self.pushButton_sel_dir.clicked.connect(self.select_dir)
self.lineEdit.textChanged.connect(self.checkDangerAndEnabled)
self.checkBox_create_subdir.checkStateChanged.connect(
self.checkDangerAndEnabled
)
self.pushButton_export_project.clicked.connect(self.export_unity_project)
def export_unity_project(self):
self.exporting_window = exportingWindow.ExportingWindow(self)
self.exporting_window.setModal(True)
self.exporting_window.show()
api.export_unity_project(
self.lineEdit.text(),
self.checkBox_create_subdir.isChecked(),
self.parent().port,
)
def export_primary_content(self):
self.exporting_window = exportingWindow.ExportingWindow(self)
self.exporting_window.setModal(True)
self.exporting_window.show()
api._export_primary_content(
self.lineEdit.text(),
self.checkBox_create_subdir.isChecked(),
self.parent().port,
)
def select_dir(self):
dir_path = QtWidgets.QFileDialog.getExistingDirectory(
self, "Select Directory...", dir=path_saver.get_last_export_path()
)
if not dir_path:
return # 取消了
path_saver.save_last_export_path(dir_path)
self.lineEdit.setText(dir_path)
def checkDangerAndEnabled(self):
if self.isButtonsEnabled():
self.pushButton_export_prim_content.setEnabled(True)
self.pushButton_export_project.setEnabled(True)
else:
self.pushButton_export_prim_content.setStyleSheet(self.SAFE_QSS)
self.pushButton_export_prim_content.setEnabled(False)
self.pushButton_export_project.setStyleSheet(self.SAFE_QSS)
self.pushButton_export_project.setEnabled(False)
self.label_danger.setStyleSheet("color:rgba(255,255,255,0)")
return
if self.isDanger():
self.pushButton_export_prim_content.setStyleSheet(self.DANGER_QSS)
self.pushButton_export_project.setStyleSheet(self.DANGER_QSS)
self.label_danger.setStyleSheet("color:black")
else:
self.pushButton_export_prim_content.setStyleSheet(self.SAFE_QSS)
self.pushButton_export_project.setStyleSheet(self.SAFE_QSS)
self.label_danger.setStyleSheet("color:rgba(255,255,255,0)")
def isDanger(self) -> bool:
isEmpty = not len(os.listdir(self.lineEdit.text()))
if not isEmpty:
if self.checkBox_create_subdir.isChecked():
return False
return not isEmpty
return False
def isButtonsEnabled(self) -> bool:
if "C:" == self.lineEdit.text().strip("/").strip("\\"):
return False
return os.path.isdir(self.lineEdit.text())
if __name__ == "__main__":
qa = QtWidgets.QApplication(list())
eaw = ExportAllWindow()
eaw.show()
qa.exec()