-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
236 lines (177 loc) · 7.17 KB
/
main.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import sys
import platform
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import (QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient)
from PySide2.QtWidgets import *
from ui_functions import *
## ==> SPLASH SCREEN
from ui_splash_screen import Ui_SplashScreen
## ==> MAIN WINDOW
from ui_main import Ui_MainWindow
from decode import Ui_MainWindow as new
from intro import Ui_MainWindow as intro
## ==> GLOBALS
counter = 0
class Second(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = new()
self.ui.setupUi(self)
###checkk
self.ui.pushButton.clicked.connect(lambda: UIFunctions.decode_image(self))
self.ui.back.clicked.connect(self.backk)
self.ui.bmw.clicked.connect(lambda: UIFunctions.open_file(self))
def moveWindow(event):
# RESTORE BEFORE MOVE
if UIFunctions.returnStatus() == 1:
UIFunctions.maximize_restore(self)
# IF LEFT CLICK MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# SET TITLE BAR
#self.ui.bmw.clicked.connect(self.remove)
self.ui.title_bar.mouseMoveEvent = moveWindow
#pushButton.clicked.connect(self.clickk)
## ==> SET UI DEFINITIONS
UIFunctions.uiDefinitions(self)
## SHOW ==> MAIN WINDOW
########################################################################
self.show()
def backk(self):
self.main = Intro()
self.main.show()
self.close()
# YOUR APPLICATION
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(lambda: UIFunctions.get1(self))
self.ui.pushButton_2.clicked.connect(lambda: UIFunctions.get2(self))
self.ui.bmw.clicked.connect(lambda: UIFunctions.open_file(self))
self.ui.back.clicked.connect(self.backk)
# MOVE WINDOW
def moveWindow(event):
# RESTORE BEFORE MOVE
if UIFunctions.returnStatus() == 1:
UIFunctions.maximize_restore(self)
# IF LEFT CLICK MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# SET TITLE BAR
#self.ui.bmw.clicked.connect(self.remove)
self.ui.title_bar.mouseMoveEvent = moveWindow
#pushButton.clicked.connect(self.clickk)
## ==> SET UI DEFINITIONS
UIFunctions.uiDefinitions(self)
## SHOW ==> MAIN WINDOW
########################################################################
self.show()
## APP EVENTS
########################################################################
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
def backk(self):
self.main = Intro()
self.main.show()
self.close()
# SPLASH SCREEN
class SplashScreen(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_SplashScreen()
self.ui.setupUi(self)
## UI ==> INTERFACE CODES
########################################################################
## REMOVE TITLE BAR
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
## DROP SHADOW EFFECT
self.shadow = QGraphicsDropShadowEffect(self)
self.shadow.setBlurRadius(20)
self.shadow.setXOffset(0)
self.shadow.setYOffset(0)
self.shadow.setColor(QColor(0, 0, 0, 60))
self.ui.dropShadowFrame.setGraphicsEffect(self.shadow)
## QTIMER ==> START
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.progress)
# TIMER IN MILLISECONDS
self.timer.start(35)
# CHANGE DESCRIPTION
# Initial Text
self.ui.label_description.setText("<strong>WELCOME</strong> TO MY APPLICATION")
# Change Texts
QtCore.QTimer.singleShot(1500, lambda: self.ui.label_description.setText("<strong>LOADING</strong> MODULES"))
QtCore.QTimer.singleShot(3000, lambda: self.ui.label_description.setText("<strong>LOADING</strong> USER INTERFACE"))
## SHOW ==> MAIN WINDOW
########################################################################
self.show()
## ==> END ##
## ==> APP FUNCTIONS
########################################################################
def progress(self):
global counter
# SET VALUE TO PROGRESS BAR
self.ui.progressBar.setValue(counter)
# CLOSE SPLASH SCREE AND OPEN APP
if counter > 100:
# STOP TIMER
self.timer.stop()
# SHOW MAIN WINDOW
self.main = Intro()
self.main.show()
# CLOSE SPLASH SCREEN
self.close()
# INCREASE COUNTER
counter += 1
class Intro(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = intro()
self.ui.setupUi(self)
self.ui.pushButton_encode.clicked.connect(self.swit1)
self.ui.pushButton_decode.clicked.connect(self.swit2)
self.ui.btn_maximize.hide()
self.ui.bmw.clicked.connect(lambda: UIFunctions.open_file(self))
# MOVE WINDOW
def moveWindow(event):
# RESTORE BEFORE MOVE
if UIFunctions.returnStatus() == 1:
UIFunctions.maximize_restore(self)
# IF LEFT CLICK MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# SET TITLE BAR
#self.ui.bmw.clicked.connect(self.remove)
self.ui.title_bar.mouseMoveEvent = moveWindow
#pushButton.clicked.connect(self.clickk)
## ==> SET UI DEFINITIONS
UIFunctions.uiDefinitions(self)
## SHOW ==> MAIN WINDOW
########################################################################
self.show()
## APP EVENTS
########################################################################
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
def swit1(self):
self.main = MainWindow()
self.main.show()
self.close()
def swit2(self):
self.main = Second()
self.main.show()
self.close()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = SplashScreen()
sys.exit(app.exec_())