Fix compatibility issues with Qt/PyQt6 versions
Some checks failed
build / build-win64 (push) Waiting to run
build / build-macos (push) Waiting to run
build / build-pip (push) Failing after 11s

- Add null check for message.message in search filter
- Handle missing colorScheme/colorSchemeChanged methods for older Qt versions
- Add display check to prevent hanging in headless environments
- Update build documentation with system package alternative
- Update PyInstaller spec for Python 3.12
- Improve run.sh script with venv management
This commit is contained in:
kdusek
2025-12-06 04:00:10 +01:00
parent 2b3d9eb07f
commit 7b695d7b7f
11 changed files with 64 additions and 14 deletions

View File

@@ -1,11 +1,21 @@
def main():
import os
import sys
if "--version" in sys.argv:
from gotify_tray.__version__ import __version__
print(__version__)
else:
# Check for display before importing GUI modules
if not os.environ.get("DISPLAY"):
print(
"Error: No display environment detected. This application requires a graphical desktop environment to run.",
file=sys.stderr,
)
sys.exit(1)
from gotify_tray.gui import start_gui
start_gui()

View File

@@ -459,9 +459,10 @@ class MainApplication(QtWidgets.QApplication):
self.main_window.hidden.connect(self.main_window_hidden_callback)
self.main_window.activated.connect(self.tray.revert_icon)
self.styleHints().colorSchemeChanged.connect(
self.theme_change_requested_callback
)
if hasattr(self.styleHints(), "colorSchemeChanged"):
self.styleHints().colorSchemeChanged.connect(
self.theme_change_requested_callback
)
self.messages_model.rowsInserted.connect(
self.main_window.display_message_widgets

View File

@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_main.ui'
#
# Created by: PyQt6 UI code generator 6.9.1
# Created by: PyQt6 UI code generator 6.10.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.

View File

@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_message.ui'
#
# Created by: PyQt6 UI code generator 6.9.1
# Created by: PyQt6 UI code generator 6.10.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.

View File

@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_server.ui'
#
# Created by: PyQt6 UI code generator 6.9.1
# Created by: PyQt6 UI code generator 6.10.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.

View File

@@ -1,6 +1,6 @@
# Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_settings.ui'
#
# Created by: PyQt6 UI code generator 6.9.1
# Created by: PyQt6 UI code generator 6.10.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.

View File

@@ -65,7 +65,7 @@ class MessagesProxyModel(QtCore.QSortFilterProxyModel):
return False
if self.text_filter:
title = (message.title or "").lower()
msg = message.message.lower()
msg = (message.message or "").lower()
if self.text_filter not in title and self.text_filter not in msg:
return False
return True

View File

@@ -3,14 +3,21 @@ from gotify_tray.utils import get_abs_path
themes = {
QtCore.Qt.ColorScheme.Dark: "dark",
QtCore.Qt.ColorScheme.Light: "light",
QtCore.Qt.ColorScheme.Unknown: "light",
2: "dark", # Dark
1: "light", # Light
0: "light", # Unknown
}
def set_theme(app: QtWidgets.QApplication):
theme = themes.get(app.styleHints().colorScheme(), "light")
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:
@@ -23,5 +30,12 @@ def set_theme(app: QtWidgets.QApplication):
def get_theme_file(file: str) -> str:
app = QtCore.QCoreApplication.instance()
theme = themes.get(app.styleHints().colorScheme(), "light")
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}")