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

@@ -2,8 +2,9 @@ import os
import platform
import re
import subprocess
from pathlib import Path
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
from typing import Iterator
from PyQt6 import QtWidgets
@@ -20,7 +21,11 @@ def verify_server(force_new: bool = False, enable_import: bool = True) -> bool:
url = settings.value("Server/url", type=str)
token = settings.value("Server/client_token", type=str)
print(f"Server URL: {url}")
print(f"Server token: {'*' * len(token) if token else None}")
if not url or not token or force_new:
print("Showing server config dialog")
dialog = ServerInfoDialog(url, token, enable_import)
if dialog.exec():
settings.setValue("Server/url", dialog.line_url.text())
@@ -29,10 +34,13 @@ def verify_server(force_new: bool = False, enable_import: bool = True) -> bool:
else:
return False
else:
print("Server already configured")
return True
def process_messages(messages: list[gotify.GotifyMessageModel]) -> Iterator[gotify.GotifyMessageModel]:
def process_messages(
messages: list[gotify.GotifyMessageModel],
) -> Iterator[gotify.GotifyMessageModel]:
downloader = Downloader()
for message in messages:
if image_url := extract_image(message.message):
@@ -59,7 +67,7 @@ def convert_links(text):
def extract_image(s: str) -> str | None:
"""If `s` contains only an image URL, this function returns that URL.
This function also extracts a URL in the `![](<url>)` markdown image format.
This function also extracts a URL in the `![](<url>)` markdown image format.
"""
s = s.strip()
@@ -77,9 +85,7 @@ def extract_image(s: str) -> str | None:
def get_abs_path(s) -> str:
h = Path(__file__).parent.parent
p = Path(s)
return os.path.join(h, p).replace("\\", "/")
return os.path.join(PROJECT_ROOT, s)
def open_file(filename: str):
@@ -101,6 +107,7 @@ def get_icon(name: str) -> str:
return get_abs_path(f"gotify_tray/gui/images/{name}.png")
def update_widget_property(widget: QtWidgets.QWidget, property: str, value: str):
widget.setProperty(property, value)
widget.style().unpolish(widget)