-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·274 lines (223 loc) · 8.9 KB
/
Copy pathmain.py
File metadata and controls
executable file
·274 lines (223 loc) · 8.9 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
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
#!/usr/bin/env python3
"""
Progress Visualizer - Modern GUI Application
Combines visualization and editing in a single modern interface
"""
import sys
import os
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QStackedWidget
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QIcon, QPalette, QColor
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'src'))
from visualizer import VisualizerWidget
from old_visualizer import OldVisualizerWidget
from editor import EditorWidget
from released_editor import ReleasedEditorWidget
from theme_manager import theme_manager
COLORS = theme_manager.get_theme()
class MainWindow(QMainWindow):
"""Main application window with modern design"""
def __init__(self):
super().__init__()
self.setWindowTitle("Візуалізатор поступу")
self.visualizer = VisualizerWidget(self)
self.old_visualizer = OldVisualizerWidget()
self.editor = EditorWidget()
self.released_editor = ReleasedEditorWidget()
# Connect to theme changes
theme_manager.theme_changed.connect(self.on_theme_changed)
# Connect editor to visualizers
self.editor.data_changed.connect(self.on_data_changed)
self.released_editor.data_changed.connect(self.on_data_changed)
# Initial window size based on project count
# If we have few projects, we don't need a huge window
project_count = len(self.editor.data_manager.data)
if project_count < 3:
self.resize(1400, 500)
else:
self.resize(1400, 800)
# Create main widget and layout
main_widget = QWidget()
self.setCentralWidget(main_widget)
layout = QVBoxLayout(main_widget)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
# Create navigation bar
nav_bar = self.create_nav_bar()
layout.addWidget(nav_bar)
# Create stacked widget for views
self.stacked_widget = QStackedWidget()
self.stacked_widget.addWidget(self.visualizer)
self.stacked_widget.addWidget(self.old_visualizer)
self.stacked_widget.addWidget(self.editor)
self.stacked_widget.addWidget(self.released_editor)
layout.addWidget(self.stacked_widget)
# Apply custom styling
self.apply_custom_style()
def on_data_changed(self):
"""Handle data changes from editors and refresh visualizers."""
self.visualizer.refresh()
self.old_visualizer.refresh()
def create_nav_bar(self) -> QWidget:
"""Create navigation bar"""
self.nav_widget = QWidget()
self.nav_widget.setFixedHeight(50)
self.update_nav_bar_style()
layout = QHBoxLayout(self.nav_widget)
layout.setContentsMargins(10, 5, 10, 5)
layout.addStretch()
# Mechanical Theme button (New Modern)
mechanical_btn = QPushButton("Механічна💅")
mechanical_btn.setCheckable(True)
mechanical_btn.setChecked(theme_manager.current_theme_name == "mechanical")
mechanical_btn.clicked.connect(self.switch_to_mechanical)
layout.addWidget(mechanical_btn)
# Classic Theme button (Catppuccin)
classic_btn = QPushButton("Класична тема")
classic_btn.setCheckable(True)
classic_btn.setChecked(theme_manager.current_theme_name == "catppuccin")
classic_btn.clicked.connect(lambda: self.switch_to_classic())
layout.addWidget(classic_btn)
# Old view button
self.old_btn = QPushButton("Старий вигляд")
self.old_btn.setCheckable(True)
self.old_btn.clicked.connect(lambda: self.switch_view(1, self.old_btn))
layout.addWidget(self.old_btn)
# Edit button
self.edit_btn = QPushButton("Редагувати")
self.edit_btn.setCheckable(True)
self.edit_btn.clicked.connect(lambda: self.switch_view(2, self.edit_btn))
layout.addWidget(self.edit_btn)
# Released Projects button
self.released_btn = QPushButton("Релізи 📦")
self.released_btn.setCheckable(True)
self.released_btn.clicked.connect(lambda: self.switch_view(3, self.released_btn))
layout.addWidget(self.released_btn)
layout.addStretch()
self.nav_buttons = [mechanical_btn, classic_btn, self.old_btn, self.edit_btn, self.released_btn]
self.update_button_styles()
return self.nav_widget
def switch_to_mechanical(self):
theme_manager.set_theme("mechanical")
self.switch_view(0, self.nav_buttons[0])
def switch_to_classic(self):
theme_manager.set_theme("catppuccin")
self.switch_view(0, self.nav_buttons[1])
def update_nav_bar_style(self):
self.nav_widget.setStyleSheet(f"""
QWidget {{
background-color: {COLORS['mantle']};
border-bottom: 1px solid {COLORS['border']};
}}
""")
def update_button_styles(self):
for btn in self.nav_buttons:
btn.setStyleSheet(self.get_nav_button_style(btn.isChecked()))
def get_nav_button_style(self, active: bool) -> str:
"""Get navigation button style"""
if active:
return f"""
QPushButton {{
background-color: {COLORS['accent']};
color: white;
border: none;
border-radius: 6px;
padding: 8px 16px;
font-weight: bold;
text-align: center;
}}
QPushButton:hover {{
background-color: #7aa4f0;
}}
"""
else:
return f"""
QPushButton {{
background-color: transparent;
color: {COLORS['text']};
border: none;
border-radius: 6px;
padding: 8px 16px;
text-align: center;
}}
QPushButton:hover {{
background-color: {COLORS['hover']};
}}
"""
def switch_view(self, index: int, active_btn: QPushButton):
"""Switch between views"""
for btn in self.nav_buttons:
btn.setChecked(btn == active_btn)
self.update_button_styles()
self.stacked_widget.setCurrentIndex(index)
# Special case: ensuring editors/visualizers reload data
if index == 2:
self.editor.load_projects()
elif index == 3:
self.released_editor.load_released_projects()
elif index == 0:
self.visualizer.refresh()
elif index == 1:
self.old_visualizer.refresh()
def on_theme_changed(self, theme_name):
"""Handle global theme change"""
global COLORS
COLORS = theme_manager.get_theme()
self.update_nav_bar_style()
self.update_button_styles()
self.apply_custom_style()
# Re-apply global theme styles
apply_global_theme(QApplication.instance())
def apply_custom_style(self):
"""Apply custom Catppuccin Mocha colors"""
self.setStyleSheet(f"""
QMainWindow {{
background-color: {COLORS['background']};
}}
""")
def apply_global_theme(app: QApplication):
"""Apply global dark theme to the application"""
app.setStyle("Fusion")
# Set global stylesheet for consistency
app.setStyleSheet(f"""
* {{
font-family: 'Segoe UI', 'Inter', sans-serif;
}}
QToolTip {{
background-color: {COLORS['overlay']};
color: {COLORS['text']};
border: 1px solid {COLORS['border']};
border-radius: 4px;
padding: 4px;
}}
QMessageBox {{
background-color: {COLORS['surface']};
color: {COLORS['text']};
}}
QMessageBox QPushButton {{
background-color: {COLORS['accent']};
color: white;
border: none;
border-radius: 4px;
padding: 6px 16px;
min-width: 60px;
}}
QMessageBox QPushButton:hover {{
background-color: {COLORS['hover']};
}}
""")
def main():
"""Main entry point"""
# Enable high DPI scaling
QApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough
)
app = QApplication(sys.argv)
# Apply global theme
apply_global_theme(app)
# Create and show main window
window = MainWindow()
window.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()