-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
62 lines (45 loc) · 1.73 KB
/
Copy pathmain.py
File metadata and controls
62 lines (45 loc) · 1.73 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
import os
import sys
import traceback
from pathlib import Path
from PySide6 import QtWidgets
from widgets import MainWindow
def _configure_portable_runtime():
"""Set portable defaults without overriding studio/user configuration."""
documents = Path.home() / "Documents"
os.environ.setdefault("FRAMEDECK_PROFILE_ROOT", str(documents))
def _install_crash_log():
"""Write startup/runtime errors to a file for windowed builds."""
log_dir = Path(os.environ["FRAMEDECK_PROFILE_ROOT"]) / "framedeck" / "logs"
def handle_exception(exc_type, exc_value, exc_traceback):
log_dir.mkdir(parents=True, exist_ok=True)
log_file = log_dir / "framedeck-crash.log"
log_file.write_text(
"".join(traceback.format_exception(exc_type, exc_value, exc_traceback)),
encoding="utf-8",
)
sys.__excepthook__(exc_type, exc_value, exc_traceback)
sys.excepthook = handle_exception
def main():
"""
Application entry point.
"""
_configure_portable_runtime()
_install_crash_log()
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName("FrameDeck")
app.setOrganizationName("FrameDeck")
window = MainWindow()
window.show()
# Files passed from Explorer (Open with / drag onto EXE) become one local
# playlist, in the same order supplied by Windows. With no files, the
# optional (default-off) restore preference decides whether to reopen the
# last session or leave the workspace empty.
media_paths = [path for path in sys.argv[1:] if Path(path).is_file()]
if media_paths:
window.import_media_files(media_paths)
else:
window.restore_last_session()
sys.exit(app.exec())
if __name__ == "__main__":
main()