This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
/
profileForm.py
205 lines (178 loc) · 7.98 KB
/
profileForm.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
from PySide.QtGui import *
from PySide.QtUiTools import *
from EditProfileStudent import editProfileUI
from sendMessageForm import sendMessageUI
from changePasswordForm import changePasswordUI
class profileUI(QMainWindow):
def __init__(self,parent = None):
QMainWindow.__init__(self,None)
self.setMinimumSize(900,600)
self.setWindowTitle("Profile")
palette = QPalette()
palette.setBrush(QPalette.Background,QBrush(QPixmap("resources/images/programBackground.png")))
self.setPalette(palette)
self.bar = QPixmap("resources/images/topBarBackground.png")
self.parent = parent
self.UIinit()
def UIinit(self):
loader = QUiLoader()
form = loader.load("resources/UI/profile.ui",None)
self.setCentralWidget(form)
#Upper Bar
self.bar_group = form.findChild(QLabel,"barLabel")
self.bar_group.setPixmap(self.bar)
self.home_button = form.findChild(QPushButton,"homeButton")
self.profile_button = form.findChild(QPushButton,"profileButton")
self.grade_button = form.findChild(QPushButton,"gradeButton")
self.course_button = form.findChild(QPushButton,"courseButton")
self.temp = form.findChild(QPushButton, "temp")
self.temp2 = form.findChild(QPushButton, "temp2")
#page properties
self.home_button = form.findChild(QPushButton, "homeButton")
self.edit_button = form.findChild(QPushButton, "editButton")
self.changepassword_button = form.findChild(QPushButton, "changePasswordButton")
self.status = form.findChild(QLabel,"status")
self.id = form.findChild(QLabel,"id")
self.name = form.findChild(QLabel,"name")
self.surname = form.findChild(QLabel,"surname")
self.email = form.findChild(QLabel,"email")
self.faculty = form.findChild(QLabel,"faculty")
self.major = form.findChild(QLabel,"major")
self.year = form.findChild(QLabel,"year")
self.student_status = form.findChild(QLabel,"sstatus")
self.address = form.findChild(QLabel,"address")
self.profile_pic = form.findChild(QLabel, "profile_pic")
#Upper Bar pressed
self.home_button.clicked.connect(self.goHome)
self.profile_button.clicked.connect(self.goProfile)
self.grade_button.clicked.connect(self.goGrade)
self.course_button.clicked.connect(self.goCourse)
self.temp.clicked.connect(self.goTemp)
self.temp2.clicked.connect(self.goTemp2)
self.edit_button.clicked.connect(self.editProfile)
self.changepassword_button.clicked.connect(self.changePassword)
def goHome(self):
self.parent.changePageLoginSection("home")
def goProfile(self):
self.parent.changePageLoginSection("profile")
def goGrade(self):
data = self.parent.getCurrentUser()
if (data.type() == "STUDENT"):
self.parent.changePageLoginSection("studentGrade")
elif (data.type() == "PROFESSOR"):
self.parent.changePageLoginSection("grade")
elif (data.type() == "ADMIN"):
self.parent.changePageLoginSection("addfaculties")
def goCourse(self):
data = self.parent.getCurrentUser()
if (data.type() == "STUDENT"):
self.parent.changePageLoginSection("studentCourse")
elif (data.type() == "PROFESSOR"):
self.parent.changePageLoginSection("course")
elif (data.type() == "ADMIN"):
self.parent.changePageLoginSection("addmajor")
def goTemp(self):
data = self.parent.getCurrentUser()
if (data.type() == "STUDENT"):
self.createM = sendMessageUI(parent = self.parent)
self.createM.show()
elif (data.type() == "PROFESSOR"):
self.createM = sendMessageUI(parent = self.parent)
self.createM.show()
elif (data.type() == "ADMIN"):
self.parent.changePageLoginSection("addcourse")
def goTemp2(self):
data = self.parent.getCurrentUser()
if (data.type() == "STUDENT"):
self.parent.changePageLoginSection("login")
elif (data.type() == "PROFESSOR"):
self.parent.changePageLoginSection("login")
elif (data.type() == "ADMIN"):
self.parent.changePageLoginSection("otherOption")
def editProfile(self):
self.edit = editProfileUI(parent = self.parent)
self.edit.updatePage()
self.edit.show()
def changePassword(self):
self.change = changePasswordUI(parent=self.parent)
self.change.show()
def updatePage(self):
data = self.parent.getCurrentUser()
if(data.type() == "STUDENT"):
self.id.setText(data.getID())
self.name.setText(data.getName())
self.surname.setText(data.getSurname())
self.email.setText(data.getEmail())
self.faculty.setText(data.getFacultyName())
self.major.setText(data.getMajorName())
self.year.setText(data.year)
self.address.setText(data.getAddress())
# change Button Name
self.grade_button.setText("Grades")
self.course_button.setText("Courses")
self.temp.setText("Message")
self.temp2.setText("Logout")
# Status
status = data.getStatus()
if (status == 0):
self.student_status.setText("Learning")
elif (status == 1):
self.student_status.setText("Probation")
elif (status == 2):
self.student_status.setText("Retired")
elif (status == 3):
self.student_status.setText("Withdrawn")
elif (status == 4):
self.student_status.setText("Suspended")
elif (status == 5):
self.student_status.setText("Alumni/Withdrawn")
else:
self.student_status.setText("Unknown")
elif (data.type() == "PROFESSOR"):
self.id.setText(data.getID())
self.name.setText(data.getName())
self.surname.setText(data.getSurname())
self.email.setText(data.getEmail())
self.faculty.setText(data.getFacultyName())
self.major.setText(data.getMajorName())
self.year.setText(data.getYear())
self.address.setText(data.getAddress())
# change Button Name
self.grade_button.setText("Grades")
self.course_button.setText("Courses")
self.temp.setText("Message")
self.temp2.setText("Logout")
# Status
status = data.getStatus()
if (status == 0):
self.student_status.setText("Lecturer")
elif (status == 1):
self.student_status.setText("Assist. Prof.")
elif (status == 2):
self.student_status.setText("Assoc. Prof.")
elif (status == 3):
self.student_status.setText("Professor.")
elif (status == 4):
self.student_status.setText("Suspended")
elif (status == 5):
self.student_status.setText("Retired")
else:
self.student_status.setText("Unknown")
elif (data.type() == "ADMIN"):
self.id.setText(data.getID())
self.name.setText(data.getName())
self.surname.setText(data.getSurname())
self.email.setText(data.getEmail())
self.faculty.setText(data.getFacultyName())
self.major.setText(data.getMajorName())
self.year.setText(data.getYear())
self.address.setText(data.getAddress())
# change Button Name
self.grade_button.setText("Faculties")
self.course_button.setText("Majors")
self.temp.setText("Courses")
self.temp2.setText("Other options")
# Status
self.student_status.setText("Admin")
self.profile_pic.setPixmap(QPixmap(data.pictureGen()))
data.pictureDataProtect()