forked from NoodleGodz/Final-Project-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
232 lines (189 loc) · 8.63 KB
/
main.py
File metadata and controls
232 lines (189 loc) · 8.63 KB
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
# IMPORT PACKAGES AND MODULES
# ///////////////////////////////////////////////////////////////
from pyclbr import Function
from gui.uis.windows.main_window.functions_main_window import *
import sys
import os
# IMPORT QT CORE
# ///////////////////////////////////////////////////////////////
from qt_core import *
# IMPORT SETTINGS
# ///////////////////////////////////////////////////////////////
from gui.core.json_settings import Settings
# IMPORT PY ONE DARK WINDOWS
# ///////////////////////////////////////////////////////////////
# MAIN WINDOW
from gui.uis.windows.main_window import *
# IMPORT PY ONE DARK WIDGETS
# ///////////////////////////////////////////////////////////////
from gui.widgets import *
# RANDOMNESS
import random
# ADJUST QT FONT DPI FOR HIGHT SCALE AN 4K MONITOR
# ///////////////////////////////////////////////////////////////
os.environ["QT_FONT_DPI"] = "96"
# os.environ["QT_SCALE_FACTOR"] = "0.5"
# MAIN WINDOW
# ///////////////////////////////////////////////////////////////
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# SETUP MAIN WINDOw
# Load widgets from "gui\uis\main_window\ui_main.py"
# ///////////////////////////////////////////////////////////////
self.ui = UI_MainWindow()
self.ui.setup_ui(self)
# LOAD SETTINGS
# ///////////////////////////////////////////////////////////////
settings = Settings()
self.settings = settings.items
# SETUP MAIN WINDOW
# ///////////////////////////////////////////////////////////////
self.hide_grips = True # Show/Hide resize grips
SetupMainWindow.setup_gui(self)
# POST-SETUP
if not builtins.is_logged:
MainFunctions.get_left_menu_btn(self, "btn_login").set_icon(Functions.set_svg_icon("icon_lock.svg"))
# SHOW MAIN WINDOW
# ///////////////////////////////////////////////////////////////
self.show()
# LEFT MENU BTN IS CLICKED
# Run function when btn is clicked
# Check funtion by object name / btn_id
# ///////////////////////////////////////////////////////////////
def btn_clicked(self):
# GET BT CLICKED
btn = SetupMainWindow.setup_btns(self)
# TITLE BAR MENU
# ///////////////////////////////////////////////////////////////
if MainFunctions.right_column_is_visible(self):
MainFunctions.toggle_right_column(self)
# top_btn_setting = MainFunctions.get_title_bar_btn(self, "btn_top_settings")
if btn.objectName() == "btn_login":
self.ui.left_menu.select_only_one(btn.objectName())
if builtins.is_logged:
MainFunctions.set_page(self, self.ui.load_pages.page_0)
else:
MainFunctions.set_page(self, self.ui.load_pages.page_1)
if btn.objectName() == "btn_stat":
if not builtins.is_logged:
msgBox = QMessageBox()
msgBox.setWindowTitle("Statistics Dashboard")
msgBox.setIcon(QMessageBox.Critical)
msgBox.setText("Access denied. Please login.")
msgBox.exec()
else:
self.ui.left_menu.select_only_one(btn.objectName())
MainFunctions.set_page(self, self.ui.load_pages.page_2)
if btn.objectName() == "btn_manage":
if not builtins.is_logged:
msgBox = QMessageBox()
msgBox.setWindowTitle("Customers Management")
msgBox.setIcon(QMessageBox.Critical)
msgBox.setText("Access denied. Please login.")
msgBox.exec()
else:
self.ui.left_menu.select_only_one(btn.objectName())
MainFunctions.set_page(self, self.ui.load_pages.page_3)
if btn.objectName() == "btn_info" or btn.objectName() == "btn_close_left_column":
if not MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
else:
if btn.objectName() == "btn_close_left_column":
self.ui.left_menu.deselect_all_tab()
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
if btn.objectName() != "btn_close_left_column":
MainFunctions.set_left_column_menu(
self,
menu = self.ui.left_column.menus.menu_2,
title = "About",
icon_path = Functions.set_svg_icon("icon_info.svg")
)
if btn.objectName() == "btn_setting" or btn.objectName() == "btn_close_left_column":
if not MainFunctions.left_column_is_visible(self):
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
else:
if btn.objectName() == "btn_close_left_column":
self.ui.left_menu.deselect_all_tab()
MainFunctions.toggle_left_column(self)
self.ui.left_menu.select_only_one_tab(btn.objectName())
if btn.objectName() != "btn_close_left_column":
MainFunctions.set_left_column_menu(
self,
menu = self.ui.left_column.menus.menu_1,
title = "Settings",
icon_path = Functions.set_svg_icon("icon_settings.svg")
)
if btn.objectName() == "btn_rate":
text, ok = QInputDialog().getMultiLineText(
self,
"Feedback",
"What do you think about this client?",
"",
)
if ok:
msgBox = QMessageBox()
msgBox.setWindowTitle("Feedback")
msgBox.setIcon(QMessageBox.Information)
msgBox.setText("Thank you for sending! Your opinion will be sent to /dev/null for everyone!")
msgBox.exec()
if btn.objectName() == "btn_motd":
msgBox = QMessageBox()
msgBox.setWindowTitle("Message of the Day")
msgBox.setIcon(QMessageBox.Information)
msgBox.setText(
random.choice(builtins.motds)
)
msgBox.exec()
# # SETTINGS TITLE BAR
# if btn.objectName() == "btn_top_settings":
# # Toogle Active
# if not MainFunctions.right_column_is_visible(self):
# btn.set_active(True)
# # Show / Hide
# MainFunctions.toggle_right_column(self)
# else:
# btn.set_active(False)
# # Show / Hide
# MainFunctions.toggle_right_column(self)
# # Get Left Menu Btn
# top_settings = MainFunctions.get_left_menu_btn(self, "btn_info")
# top_settings.set_active_tab(False)
# # Get Left Menu Btn
# top_settings = MainFunctions.get_left_menu_btn(self, "btn_setting")
# top_settings.set_active_tab(False)
# DEBUG
print(f"Button {btn.objectName()}, clicked!")
# LEFT MENU BTN IS RELEASED
# Run function when btn is released
# Check funtion by object name / btn_id
# ///////////////////////////////////////////////////////////////
def btn_released(self):
# GET BT CLICKED
btn = SetupMainWindow.setup_btns(self)
# DEBUG
print(f"Button {btn.objectName()}, released!")
# RESIZE EVENT
# ///////////////////////////////////////////////////////////////
def resizeEvent(self, event):
SetupMainWindow.resize_grips(self)
# MOUSE CLICK EVENTS
# ///////////////////////////////////////////////////////////////
def mousePressEvent(self, event):
# SET DRAG POS WINDOW
self.dragPos = event.globalPos()
# SETTINGS WHEN TO START
# Set the initial class and also additional parameters of the "QApplication" class
# ///////////////////////////////////////////////////////////////
if __name__ == "__main__":
# APPLICATION
# ///////////////////////////////////////////////////////////////
app = QApplication(sys.argv)
app.setWindowIcon(QIcon("icon.ico"))
window = MainWindow()
# EXEC APP
# ///////////////////////////////////////////////////////////////
sys.exit(app.exec())