-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (49 loc) · 2.04 KB
/
main.py
File metadata and controls
63 lines (49 loc) · 2.04 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
import sys
import os
import qdarktheme
from PyQt6.QtWidgets import QApplication, QPushButton, QCheckBox, QComboBox, QSlider, QTabBar
from PyQt6.QtCore import QObject, QEvent, Qt
from PyQt6.QtGui import QIcon
from ui.main_window import MainWindow
from core.workspace import WorkspaceManager
from ui.styles import apply_application_theme
class GlobalAppFilter(QObject):
def __init__(self, state):
super().__init__()
self.state = state
def eventFilter(self, obj, event):
# Handle Global Tooltips
if event.type() == QEvent.Type.ToolTip:
if not self.state.show_tooltips:
return True # Intercept and block the tooltip event
# Handle Global Cursors for interactive elements
elif event.type() in (QEvent.Type.Polish, QEvent.Type.Show, QEvent.Type.EnabledChange):
if isinstance(obj, (QPushButton, QCheckBox, QComboBox, QSlider, QTabBar)):
if obj.isEnabled():
obj.setCursor(Qt.CursorShape.PointingHandCursor)
else:
obj.setCursor(Qt.CursorShape.ForbiddenCursor)
return super().eventFilter(obj, event)
def main():
# Fix pathing for PyInstaller executable
if getattr(sys, 'frozen', False):
os.chdir(sys._MEIPASS)
else:
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Initialize our document folders first thing
WorkspaceManager.init_workspace()
app = QApplication(sys.argv)
# Set the global application icon (Taskbar / Dock)
app.setWindowIcon(QIcon('assets/logos/logo.svg'))
# Initialize and show the main window
window = MainWindow()
window.show()
# Apply the theme (Dark or Night Vision)
apply_application_theme(window.state)
# Install global event filter to manage tooltips and cursors
app.installEventFilter(GlobalAppFilter(window.state))
window.show()
# Start the application event loop
sys.exit(app.exec())
if __name__ == "__main__":
main()