-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
162 lines (130 loc) · 5.5 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
import sys
import platform
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtWidgets import QMessageBox
from PySide2.QtCore import (QCoreApplication, QPropertyAnimation, QDate, Qt,
QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, QEvent)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase,
QIcon, QKeySequence, QLinearGradient, QPalette, QPixmap, QPainter, QRadialGradient)
from PySide2.QtWidgets import *
# ==> Splash Screen
from splash_screen import Ui_SplashScreen
# ==> Login Screen
from ui_login import Ui_LoginWindow
# ==> Main content
from ui_main_content import Ui_Maincontent
# ==> import function file
from ui_function import *
# ==>Globals
counter = 0
# main content window
class Maincontent(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_Maincontent()
self.ui.setupUi(self)
def movewindow(event):
#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.title_bar_frame.mouseMoveEvent = movewindow
# toggle button
self.ui.btn_toggle.clicked.connect(lambda : UIContentFunction.toggleMenu(self,200,True))
# Home Page
self.ui.btn_home.clicked.connect(lambda : self.ui.pages_widget.setCurrentWidget(self.ui.home_page))
# New Entry
self.ui.btn_new_entry.clicked.connect(lambda : self.ui.pages_widget.setCurrentWidget(self.ui.new_entry_page))
# Search
self.ui.btn_Search.clicked.connect(lambda : self.ui.pages_widget.setCurrentWidget(self.ui.search_page))
#app functions
UIContentFunction.uidefinition(self)
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
# login window
class LoginWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_LoginWindow()
self.ui.setupUi(self)
#move Window
def movewindow(event):
#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.title_bar.mouseMoveEvent = movewindow
#app function
UIFunction.uidefinition(self)
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
#validity check
def check(self):
if self.ui.username.text() == "amanasr" and self.ui.password.text() == "9119831111":
self.main = Maincontent()
self.main.show()
self.close()
elif self.ui.username.text() == "" or self.ui.password.text() == "":
msg = QMessageBox()
msg.setWindowTitle("Annanya Communication Error")
msg.setText("Username or Password is Empty")
msg.setIcon(QMessageBox.Critical)
msg.setStandardButtons(QMessageBox.Retry|QMessageBox.Close)
x = msg.exec_()
else:
msg = QMessageBox()
msg.setWindowTitle("Annanya Communication Error")
msg.setText("Username or Password is incorrect")
msg.setIcon(QMessageBox.Critical)
msg.setStandardButtons(QMessageBox.Retry|QMessageBox.Close)
x = msg.exec_()
class SplashScreen(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_SplashScreen()
self.ui.setupUi(self)
# UI==> Interface Code
##########################################################
# remove titlebar
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.drop_shadow_frame.setGraphicsEffect(self.shadow)
# Qtimer==>start
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.progress)
# timer in millisecond
self.timer.start(35)
##initate text
self.ui.label_descripition.setText("<strong>Welcome</strong>")
QtCore.QTimer.singleShot(1500,lambda: self.ui.label_descripition.setText("<strong>Loading</strong> Database"))
QtCore.QTimer.singleShot(3000,lambda: self.ui.label_descripition.setText("<strong>Loading</strong> User Interface"))
# show ==> main window
self.show()
# ==> APP Function
def progress(self):
global counter
self.ui.progressBar.setValue(counter)
# stop splash Screen
if counter > 100:
self.timer.stop()
#show login window
self.main = LoginWindow()
self.main.show()
#close splash screen
self.close()
# increaseing timer
counter += 1
if __name__ == "__main__":
app = QApplication(sys.argv)
window = SplashScreen()
sys.exit(app.exec_())