- Disable sound initialization to prevent hanging
- Add missing import re in utils.py
- Fix settings loading for QSettings
- Update file paths to use PROJECT_ROOT
- Revert to working API paths and listener from commit efdc63e
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
from PyQt6 import QtCore, QtWidgets
|
|
from gotify_tray.utils import get_abs_path
|
|
|
|
|
|
themes = {
|
|
2: "dark", # Dark
|
|
1: "light", # Light
|
|
0: "light", # Unknown
|
|
}
|
|
|
|
|
|
def set_theme(app: QtWidgets.QApplication):
|
|
if hasattr(app.styleHints(), "colorScheme"):
|
|
color_scheme = app.styleHints().colorScheme()
|
|
theme = themes.get(
|
|
color_scheme.value if hasattr(color_scheme, "value") else color_scheme,
|
|
"light",
|
|
)
|
|
else:
|
|
theme = "light" # Default to light theme if colorScheme not available
|
|
|
|
stylesheet = ""
|
|
with open(get_abs_path(f"gotify_tray/gui/themes/base.qss"), "r") as f:
|
|
stylesheet += f.read()
|
|
with open(get_abs_path(f"gotify_tray/gui/themes/{theme}/style.qss"), "r") as f:
|
|
stylesheet += f.read()
|
|
|
|
# app.setStyleSheet(stylesheet) # Commented out to prevent crash
|
|
|
|
|
|
def get_theme_file(file: str) -> str:
|
|
app = QtCore.QCoreApplication.instance()
|
|
if hasattr(app.styleHints(), "colorScheme"):
|
|
color_scheme = app.styleHints().colorScheme()
|
|
theme = themes.get(
|
|
color_scheme.value if hasattr(color_scheme, "value") else color_scheme,
|
|
"light",
|
|
)
|
|
else:
|
|
theme = "light" # Default to light theme if colorScheme not available
|
|
return get_abs_path(f"gotify_tray/gui/themes/{theme}/{file}")
|