-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
89 lines (67 loc) · 2.76 KB
/
Copy pathinterface.py
File metadata and controls
89 lines (67 loc) · 2.76 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
import sys
import ctypes
from PySide6.QtGui import QFont
from PySide6.QtWidgets import QApplication, QMessageBox, QDialog
from controllers.system_tray_app import SystemTrayController
from models.security_manager import SecurityManager
from views.setup_wizard import SetupWizard
EXIT_CODE_SETUP_CANCEL = 100
def is_admin():
"""Check if the script has Admin rights."""
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
def check_and_create_vault():
"""Checks if security vault exists, if not, runs setup wizard."""
if SecurityManager.vault_exists():
return True
wizard = SetupWizard()
if wizard.exec() == QDialog.Accepted:
admin_pwd, privacy_pwd = wizard.get_passwords()
success = SecurityManager.create_vault(admin_pwd, privacy_pwd)
if success:
QMessageBox.information(None, "Setup Complete", "Security vault created successfully!")
return True
else:
QMessageBox.critical(None, "Setup Failed", "Failed to create security vault.")
return False
else:
QMessageBox.warning(None, "Setup Cancelled", "Setup was cancelled.")
return False
def main():
# 1. Check Admin Privileges (Required for ICMP)
if not is_admin():
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
sys.exit(0)
# 2. Initialize Qt Application
app = QApplication(sys.argv)
from PySide6.QtGui import QFontDatabase, QFont
import resources_rc # This imports the compiled QRC
font_id = QFontDatabase.addApplicationFont(":/fonts/SUSE")
if font_id == -1:
print("⚠️ WARNING: Failed to load SUSE font from QRC. Falling back to default.")
else:
families = QFontDatabase.applicationFontFamilies(font_id)
print(f"✅ SUSE Font Loaded from QRC: {families}")
# Apply optimal rendering settings globally
app_font = QFont("SUSE", 10)
app_font.setStyleStrategy(
QFont.StyleStrategy.PreferQuality | QFont.StyleStrategy.PreferAntialias
)
app_font.setHintingPreference(QFont.HintingPreference.PreferNoHinting)
app.setFont(app_font)
print("✅ Font rendering optimized (PreferQuality + NoHinting)")
with open("cafesentinel_styles.qss", "r") as f:
app.setStyleSheet(f.read())
app.setQuitOnLastWindowClosed(False)
# 3. Check/Create Security Vault
if not check_and_create_vault():
sys.exit(EXIT_CODE_SETUP_CANCEL)
# 4. Launch the System Tray Controller
# (The controller now handles Watchdog monitoring automatically via QTimer)
controller = SystemTrayController(app)
# 5. Run the application
sys.exit(app.exec())
if __name__ == "__main__":
main()