-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
69 lines (55 loc) · 1.93 KB
/
main.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
import os
import sys
import logging
from PySide6.QtWidgets import QApplication
from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QPalette
from core.main_window import MainWindow
name = "DEEF-Lite-Media-Player"
version = "2.1.1-beta"
author = "deeffest"
website = "deeffest.pythonanywhere.com"
def setup_logging():
log_dir = os.path.join(os.path.expanduser("~"), name, "logs")
if not os.path.exists(log_dir):
os.makedirs(log_dir)
log_file = os.path.join(log_dir, "app.log")
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.FileHandler(log_file, encoding='utf-8'),
logging.StreamHandler(sys.stdout)
]
)
def is_dark_theme(app):
color_scheme = app.styleHints().colorScheme()
return color_scheme == Qt.ColorScheme.Dark
def customize_palette(app, is_dark):
palette = app.palette()
if is_dark:
highlight_color = QColor(0, 99, 177)
highlighted_text_color = QColor(255, 255, 255)
else:
highlight_color = QColor(145, 201, 247)
highlighted_text_color = QColor(0, 0, 0)
palette.setColor(QPalette.Highlight, highlight_color)
palette.setColor(QPalette.HighlightedText, highlighted_text_color)
app.setPalette(palette)
if __name__ == "__main__":
setup_logging()
os.environ['QT_MEDIA_BACKEND'] = "ffmpeg"
app = QApplication(sys.argv)
app.setApplicationName(name)
app.setApplicationVersion(version)
app.setOrganizationName(author)
app.setOrganizationDomain(website)
app.setStyle("Fusion")
is_dark = is_dark_theme(app)
customize_palette(app, is_dark)
media_paths = None
if len(sys.argv) > 1:
media_paths = sys.argv[1:]
window = MainWindow(app, "dark" if is_dark else "light", media_paths)
window.show()
sys.exit(app.exec())