-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_firebase_off.py
303 lines (247 loc) · 11.8 KB
/
main_firebase_off.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
import sys
import webbrowser
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 *
import modules.app_modules_firebase
# GUI FILE
from modules.app_modules_firebase import *
## ==> GLOBALS
counter = 0
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
########################################################################
# START - WINDOW ATTRIBUTES
########################################################################
# REMOVE ==> STANDARD TITLE BAR
UIFunctions.removeTitleBar(True)
## ==> END ##
# SET ==> WINDOW TITLE
self.setWindowTitle('Crypto - Firebase')
UIFunctions.labelTitle(self, 'Crypto - Firebase')
UIFunctions.labelDescription(self, 'Home Page')
## ==> END ##
# WINDOW SIZE ==> DEFAULT SIZE
startSize = QSize(800, 620)
self.resize(startSize)
self.setMinimumSize(startSize)
# UIFunctions.enableMaximumSize(self, 500, 720)
## ==> END ##
# ==> CREATE MENUS
########################################################################
# ==> TOGGLE MENU SIZE
self.ui.btn_toggle_menu.clicked.connect(
lambda: UIFunctions.toggleMenu(self, 220, True))
## ==> END ##
# ==> ADD CUSTOM MENUS
self.ui.stackedWidget.setMinimumWidth(20)
UIFunctions.addNewMenu(self, "Add User", "btn_new_user",
"url(:/16x16/icons/16x16/cil-user-follow.png)", True)
UIFunctions.addNewMenu(self, "HOME", "btn_home",
"url(:/16x16/icons/16x16/cil-home.png)", True)
# UIFunctions.addNewMenu(self, "Custom Widgets", "btn_signout", "url(:/16x16/icons/16x16/cil-cil-exit-to-app.png)", False)
## ==> END ##
# START MENU => SELECTION
UIFunctions.selectStandardMenu(self, "btn_new_user")
## ==> END ##
# ==> START PAGE
self.ui.stackedWidget.setCurrentWidget(self.ui.signUp)
self.ui.label_top_info_1.setText('Registration')
self.ui.label_top_info_2.setText('| Form')
## ==> END ##
# ==> FORM PAGE
self.ui.gotoReg.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget
(self.ui.signUp))
self.ui.gotoSign.clicked.connect(lambda: self.ui.stackedWidget.setCurrentWidget
(self.ui.signIn))
## ==> END ##
# USER ICON ==> SHOW HIDE
UIFunctions.userIcon(self, "Crypto", "", True)
## ==> END ##
########################################################################
# #
## START -------------- BUTTON CLICK FUCNCTION -----------------------##
# #
## ##
########################################################################
self.ui.addBtn.clicked.connect(lambda: Firebase.addtoTable(self))
self.ui.loginBtn.clicked.connect(lambda: Firebase.signin(self))
self.ui.regBtn.clicked.connect(lambda: Firebase.signup(self))
self.ui.moveUpBtn.clicked.connect(lambda: Firebase.moveUp(self))
self.ui.moveDownBtn.clicked.connect(lambda: Firebase.moveDown(self))
self.ui.deleteBtn.clicked.connect(lambda: Firebase.deleteRow(self))
self.ui.copyBtn.clicked.connect(lambda: Firebase.copyPass(self))
self.ui.updateBtn.clicked.connect(lambda: Firebase.updateRow(self))
self.ui.delDBBtn.clicked.connect(lambda: Firebase.delDB(self))
self.ui.button_credits.clicked.connect(lambda: webbrowser.open('http://viswa2k.tk'))
self.ui.tableWidget.doubleClicked.connect(lambda: Firebase.showHint(self))
self.ui.tableWidget.clicked.connect(lambda: Firebase.removeLabel(self))
# ==> MOVE WINDOW / MAXIMIZE / RESTORE
########################################################################
def moveWindow(event):
# IF MAXIMIZED CHANGE TO NORMAL
if UIFunctions.returStatus() == 1:
UIFunctions.maximize_restore(self)
# MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# WIDGET TO MOVE
self.ui.frame_label_top_btns.mouseMoveEvent = moveWindow
## ==> END ##
# ==> LOAD DEFINITIONS
########################################################################
UIFunctions.uiDefinitions(self)
## ==> END ##
########################################################################
# END - WINDOW ATTRIBUTES
############################## ---/--/--- ##############################
# ==> QTableWidget RARAMETERS
########################################################################
self.ui.tableWidget.horizontalHeader().setSectionResizeMode(
QtWidgets.QHeaderView.Stretch)
delegate = ReadOnlyDelegate(self)
self.ui.tableWidget.setItemDelegateForColumn(0, delegate)
self.ui.tableWidget.setItemDelegateForColumn(1, delegate)
## ==> END ##
########################################################################
# #
## END --------------- WIDGETS FUNCTIONS/PARAMETERS ----------------- ##
# #
############################## ---/--/--- ##############################
# SHOW ==> MAIN WINDOW
########################################################################
self.show()
## ==> END ##
########################################################################
# MENUS ==> DYNAMIC MENUS FUNCTIONS
########################################################################
def Button(self):
# GET BT CLICKED
btnWidget = self.sender()
# PAGE HOME
if btnWidget.objectName() == "btn_home":
self.ui.stackedWidget.setCurrentWidget(self.ui.home_page)
UIFunctions.resetStyle(self, "btn_home")
UIFunctions.labelPage(self, "Welcome")
btnWidget.setStyleSheet(
UIFunctions.selectMenu(btnWidget.styleSheet()))
if Firebase.signed == False:
self.ui.alertLabel.setText('[!!] Login to see data')
self.ui.tableWidget.setRowCount(0)
self.ui.tableWidget.setColumnCount(3)
# PAGE NEW USER
if btnWidget.objectName() == "btn_new_user":
self.ui.stackedWidget.setCurrentWidget(self.ui.signUp)
UIFunctions.resetStyle(self, "btn_new_user")
UIFunctions.labelPage(self, "New User")
btnWidget.setStyleSheet(
UIFunctions.selectMenu(btnWidget.styleSheet()))
# PAGE WIDGETS
if btnWidget.objectName() == "btn_signout":
self.ui.stackedWidget.setCurrentWidget(self.ui.signIn)
UIFunctions.resetStyle(self, "btn_signout")
UIFunctions.labelPage(self, "Welcome")
btnWidget.setStyleSheet(
UIFunctions.selectMenu(btnWidget.styleSheet()))
for item in self.ui.tableWidget.selectedItems():
item.setText('')
self.ui.tableWidget.setRowCount(0)
self.ui.tableWidget.setColumnCount(3)
btnWidget.deleteLater()
## ==> END ##
########################################################################
# START ==> APP EVENTS
########################################################################
# EVENT ==> MOUSE CLICK
########################################################################
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
if event.buttons() == Qt.LeftButton:
# print('Mouse click: LEFT CLICK')
self.ui.alertLabel.setText('')
self.ui.errorInLabel.setText('')
self.ui.errorUpLabel.setText('')
# if event.buttons() == Qt.RightButton:
# print('Mouse click: RIGHT CLICK')
# if event.buttons() == Qt.MidButton:
# print('Mouse click: MIDDLE BUTTON')
## ==> END ##
# EVENT ==> RESIZE EVENT
########################################################################
def resizeEvent(self, event):
self.resizeFunction()
return super(MainWindow, self).resizeEvent(event)
def resizeFunction(self):
print('Height: ' + str(self.height()) +
' | Width: ' + str(self.width()))
## ==> END ##
########################################################################
# END ==> APP EVENTS
############################## ---/--/--- ##############################
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(25)
# CHANGE DESCRIPTION
# Initial Text
self.ui.label_description.setText("<strong>STRONG</strong> ENCRYPTIONS")
# Change Texts
QtCore.QTimer.singleShot(2500, lambda: self.ui.label_description.setText("<strong>LOADING</strong> DATABASE"))
QtCore.QTimer.singleShot(3500, 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 = MainWindow()
self.main.show()
# CLOSE SPLASH SCREEN
self.close()
# INCREASE COUNTER
counter += 1
class ReadOnlyDelegate(QStyledItemDelegate):
def createEditor(self, parent, option, index):
print('createEditor event fired')
return
if __name__ == "__main__":
app = QApplication(sys.argv)
QtGui.QFontDatabase.addApplicationFont('fonts/segoeui.ttf')
QtGui.QFontDatabase.addApplicationFont('fonts/segoeuib.ttf')
window = SplashScreen()
sys.exit(app.exec_())