-
Notifications
You must be signed in to change notification settings - Fork 4
/
start_ui_launcher.py
125 lines (91 loc) · 4.31 KB
/
start_ui_launcher.py
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
117
118
119
120
121
122
123
124
from PyQt5 import QtCore, QtGui, QtWidgets
from launcher_interface import Ui_LauncherWindow
import sys
from launcher import Launcher
from launcher_globals import *
class ApplicationWindow(QtWidgets.QMainWindow):
def __init__(self, qApp):
super(ApplicationWindow, self).__init__()
self.ui = Ui_LauncherWindow()
self.ui.setupUi(self)
self.Launcher = Launcher()
### Import UI Fonts ###
self.fontDB = QtGui.QFontDatabase()
self.fontDB.addApplicationFont(":/fonts/fonts/Anton-Regular.ttf")
self.fontDB.addApplicationFont(":/fonts/fonts/BowlbyOneSC-Regular.ttf")
### Set special case fonts ###
self.ui.launcher_state.setFont(QtGui.QFont("Anton", 14))
self.ui.launcher_status.setFont(QtGui.QFont("Anton", 14))
self.ui.pushButton.setFont(QtGui.QFont("BowlbyOneSC", 12))
# Redefine stylesheet
self.ui.launcher_state.setStyleSheet("background-color: rgba(249,249,249, 0); color: black; border-radius: 0; border: 0px solid #ffffff; padding: 0px;")
self.ui.launcher_status.setStyleSheet("background-color: rgba(249,249,249, 0); color: black; border-radius: 0; border: 0px solid #ffffff; padding: 0px;")
### UI Globals ###
self.counter = 0
self.complete_progress = 0
self.uName = False
self.pWord = False
# This is defined so that we can call back the UI from the main application
self.APP = qApp
# So we can implement hooks to control the UI
self.Launcher.setUICallbacks(self)
# Set the startup state of the UI
self.setDefaultUI()
# Attatch functions to buttons
self.ui.pushButton.clicked.connect(self.setCredentials)
def setCredentials(self):
self.uName = str(self.ui.user_input.text())
self.pWord = str(self.ui.pass_input.text())
# Check to see if we have credentials
self.Launcher.checkCredentials()
def setDefaultUI(self):
self.ui.launcher_state.setText(LAUNCHER_STATE_WAITING)
self.ui.launcher_status.setText(LAUNCHER_STATUS_LOGIN)
self.ui.pushButton.setEnabled(True)
self.ui.user_input.setDisabled(False)
self.ui.pass_input.setDisabled(False)
self.ui.user_input.setText('')
self.ui.pass_input.setText('')
# Set stylesheet for user input
self.ui.user_input.setStyleSheet("color: black; background: white; border-radius: 8; border: 2px solid #cacaca; padding: 0px; font: 12pt")
self.ui.pass_input.setStyleSheet("color: black;background: white; border-radius: 8; border: 2px solid #cacaca; padding: 0px; font: 12pt")
self.ui.progress_bar.setValue(self.counter)
self.ui.progress_bar.setMaximum(100)
def setUpdateUI(self):
self.ui.launcher_state.setText(LAUNCHER_STATE_UPDATING)
self.ui.user_input.setDisabled(True)
self.ui.pass_input.setDisabled(True)
self.ui.pushButton.setEnabled(False)
# Reset all of our local variables to zero and reset the UI
def setFailedUI(self):
self.setDefaultUI()
self.counter = 0
self.complete_progress = 0
self.uName = False
self.pWord = False
self.ui.launcher_state.setText(LAUNCHER_STATE_WAITING)
self.ui.launcher_status.setText(LAUNCHER_STATUS_FAILURE)
self.ui.progress_bar.setValue(self.counter)
self.ui.progress_bar.setMaximum(100)
def setEnterCredsUI(self):
self.ui.launcher_status.setText(LAUNCHER_STATUS_GIVE_INPUT)
def setInvalidUserPassUI(self):
self.ui.launcher_status.setText(LAUNCHER_STATUS_INVALID_UP)
def setProgressZero(self):
self.counter = 0
self.ui.progress_bar.setValue(self.counter)
self.complete_progress = len(self.Launcher.download_list) + len(self.Launcher.unzip_list)
self.ui.progress_bar.setMaximum(self.complete_progress )
def countProgress(self):
self.counter = self.counter +1
self.ui.progress_bar.setValue(self.counter)
def subtractProgressZIP(self):
self.complete_progress = self.complete_progress -1
self.ui.progress_bar.setMaximum(self.complete_progress)
def main():
app = QtWidgets.QApplication(sys.argv)
application = ApplicationWindow(app)
application.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()