-
Notifications
You must be signed in to change notification settings - Fork 0
/
ITTOOLS.py
181 lines (158 loc) · 7.36 KB
/
ITTOOLS.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
from PyQt5 import QtWidgets, QtGui
from design import Ui_MainWindow
from dialogs.install_plugin_dialog import install_plugin
from dialogs.activate_plugin_dialog import activate_plugin
from dialogs.remove_plugin_dialog import remove_plugin
from libs import sqlCoder as sql
from widgets.plugin_design import Ui_Plugin
from dialogs.install_plugin_dialog import install_plugin
import time
import threading
import sys
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET = """QPushButton {
border: 0px;
color: #C2C2C2;
font: 25px "Verdana";
}
QPushButton::hover {
color: white;
}
"""
CLICKED_TOP_MENU_PANEL_BUTTON_STYLESHEET = """QPushButton {
border: 0px;
color: white;
font: 25px "Verdana";
}
QPushButton::hover {
color: white;
}
"""
class MainWindow(Ui_MainWindow):
def __init__(self):
super().__init__()
self.MainWindow = QtWidgets.QMainWindow()
ui = super()
ui.setupUi(self.MainWindow)
# Setup sql
sql.initTable()
# Update plugin info
sql.updateDB()
self.is_db_updating = True
self.db_updating_thread = threading.Thread(target=self.db_updating)
self.db_updating_thread.start()
self.add_functions_to_top_menu_panel_buttons()
self.add_functions_to_left_menu_panel_buttons()
def db_updating(self):
while self.is_db_updating:
sql.updateDB()
time.sleep(1)
def add_functions_to_top_menu_panel_buttons(self):
def show_whats_new_frame():
self.whats_new_btn.setStyleSheet(
CLICKED_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.whats_new_frame.raise_()
def show_eternal_arts_frame():
self.whats_new_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_btn.setStyleSheet(
CLICKED_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_frame.raise_()
def show_credits_frame():
self.whats_new_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_btn.setStyleSheet(
CLICKED_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_frame.raise_()
def show_about_frame():
self.whats_new_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_btn.setStyleSheet(
CLICKED_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_frame.raise_()
self.whats_new_btn.clicked.connect(show_whats_new_frame)
self.eternal_arts_btn.clicked.connect(show_eternal_arts_frame)
self.credits_btn.clicked.connect(show_credits_frame)
self.about_btn.clicked.connect(show_about_frame)
def add_functions_to_left_menu_panel_buttons(self):
self.show_plugins_btn.clicked.connect(self.show_show_plugins_frame)
self.install_plugin_btn.clicked.connect(
self.show_install_plugin_dialog)
self.activate_plugin_btn.clicked.connect(
self.show_activate_plugin_dialog)
self.remove_plugin_btn.clicked.connect(self.show_remove_plugin_dialog)
self.exit_btn.clicked.connect(self.MainWindow.close)
def show_show_plugins_frame(self):
self.set_base_stylesheet_to_top_menu_panel_buttons()
self.install.clicked.connect(
lambda: install_plugin.Dialog.install_plugin(self.plugin_input.text(), self))
self.show_plugins_frame.raise_()
for widget in self.plugins_area_content.children():
widget.setParent(None)
y_move = 2
for name, version, image in sql.getPluginsList():
Plugin = QtWidgets.QWidget(self.plugins_area_content)
ui = Ui_Plugin()
ui.setupUi(Plugin)
try:
icon = QtGui.QPixmap(f"plugins/{name}/{image}")
ui.icon.setPixmap(icon)
except FileNotFoundError:
icon = QtGui.QPixmap("images/icons/ITTOOLS_icon.ico")
ui.icon.setPixmap(icon)
ui.name.setText(name)
ui.version.setText(version)
ui.remove.clicked.connect(
lambda: remove_plugin.Dialog.remove_plugin(name, self))
ui.activate.clicked.connect(
lambda: activate_plugin.Dialog.activate_plugin(name))
Plugin.move(2, y_move)
y_move += Plugin.height() + 10
Plugin.show()
if Plugin.y() >= self.plugins_area_content.height():
self.plugins.setFixedWidth(
self.plugins_area_content.width() + 5)
self.plugins_area_content.setFixedHeight(
y_move + Plugin.height())
def show_install_plugin_dialog(self):
self.set_base_stylesheet_to_top_menu_panel_buttons()
install_plugin.Window = self
dialog = install_plugin.Dialog()
dialog.Dialog.exec_()
def show_activate_plugin_dialog(self):
self.set_base_stylesheet_to_top_menu_panel_buttons()
dialog = activate_plugin.Dialog()
dialog.Dialog.exec_()
def show_remove_plugin_dialog(self):
self.set_base_stylesheet_to_top_menu_panel_buttons()
remove_plugin.Window = self
dialog = remove_plugin.Dialog()
dialog.Dialog.exec_()
def set_base_stylesheet_to_top_menu_panel_buttons(self):
self.whats_new_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.eternal_arts_btn.setStyleSheet(
BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.credits_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
self.about_btn.setStyleSheet(BASE_TOP_MENU_PANEL_BUTTON_STYLESHEET)
# self.settings_btn.setStyleSheet(
# BASE_TOP_MENU_PANEL_SETTINGS_BUTTON_STYLESHEET)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.MainWindow.show()
window.is_db_updating = False
sys.exit(app.exec_())