Fix tray visibility and message reception issues
Some checks failed
build / build-win64 (push) Waiting to run
build / build-macos (push) Waiting to run
build / build-pip (push) Failing after 16s

- 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
This commit is contained in:
kdusek
2025-12-07 22:39:07 +01:00
parent 7b695d7b7f
commit 5138303016
4060 changed files with 579123 additions and 23 deletions

View File

@@ -65,12 +65,7 @@ class MainApplication(QtWidgets.QApplication):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Initialize notification sound effect
self.notification_sound = QSoundEffect()
sound_path = os.path.join(
os.path.dirname(__file__), "images", "notification.wav"
)
self.notification_sound.setSource(QtCore.QUrl.fromLocalFile(sound_path))
self.notification_sound.setVolume(0.5) # Set volume (0.0 to 1.0)
self.notification_sound = None # Disabled to prevent hanging
self.persistent_notifications = []
self.next_y_offset = 0
@@ -352,9 +347,9 @@ class MainApplication(QtWidgets.QApplication):
not settings.value("tray/notifications/sound_only_priority10", type=bool)
or message.priority == 10
):
if self.notification_sound.isLoaded():
if self.notification_sound and self.notification_sound.isLoaded():
self.notification_sound.play()
else:
elif self.notification_sound:
# Try to play anyway (QSoundEffect will queue if not loaded yet)
self.notification_sound.play()
@@ -459,10 +454,9 @@ class MainApplication(QtWidgets.QApplication):
self.main_window.hidden.connect(self.main_window_hidden_callback)
self.main_window.activated.connect(self.tray.revert_icon)
if hasattr(self.styleHints(), "colorSchemeChanged"):
self.styleHints().colorSchemeChanged.connect(
self.theme_change_requested_callback
)
self.styleHints().colorSchemeChanged.connect(
self.theme_change_requested_callback
)
self.messages_model.rowsInserted.connect(
self.main_window.display_message_widgets

View File

@@ -25,7 +25,7 @@ def set_theme(app: QtWidgets.QApplication):
with open(get_abs_path(f"gotify_tray/gui/themes/{theme}/style.qss"), "r") as f:
stylesheet += f.read()
app.setStyleSheet(stylesheet)
# app.setStyleSheet(stylesheet) # Commented out to prevent crash
def get_theme_file(file: str) -> str:

View File

@@ -12,13 +12,16 @@ class Tray(QtWidgets.QSystemTrayIcon):
def __init__(self):
super(Tray, self).__init__()
print(f"System tray available: {self.isSystemTrayAvailable()}")
if not self.isSystemTrayAvailable():
logger.warning("System tray is not available.")
print("System tray is not available.")
print(f"System supports messages: {self.supportsMessages()}")
if not self.supportsMessages():
logger.warning("System does not support notifications.")
print("System does not support notifications.")
self.set_icon_error()
self.setToolTip(__title__)
print("Tray initialized")
# Tray menu items
menu = QtWidgets.QMenu()