Compare commits

..

1 Commits

Author SHA1 Message Date
kdusek
7b695d7b7f 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
2025-12-06 04:00:10 +01:00
11 changed files with 64 additions and 14 deletions

View File

@@ -7,6 +7,16 @@ $ pip install -r requirements.txt
$ pip install pyinstaller $ pip install pyinstaller
``` ```
**Alternative: System packages (Debian/Ubuntu)**
If you prefer to use system packages instead of pip, install the required PyQt6 packages:
```shell
$ apt install python3-pyqt6 python3-pyqt6.qtwebsockets python3-pyqt6.qtmultimedia
```
Note: This may require specific Python versions and may not include the latest features.
Currently it's only possible to create installer packages from the pyinstaller output. For any target platform, first create the executable with pyinstaller: Currently it's only possible to create installer packages from the pyinstaller output. For any target platform, first create the executable with pyinstaller:
```shell ```shell

View File

@@ -8,7 +8,7 @@ logo = "gotify_tray/gui/images/logo.ico" if platform.system() != "Darwin" else "
a = Analysis(['gotify_tray/__main__.py'], a = Analysis(['gotify_tray/__main__.py'],
pathex=[os.getcwd()], pathex=[os.getcwd()],
binaries=[('/lib/x86_64-linux-gnu/libpython3.10.so', '.'), ('/lib/x86_64-linux-gnu/libpython3.10.so.1', '.')], binaries=[('/lib/x86_64-linux-gnu/libpython3.12.so', '.'), ('/lib/x86_64-linux-gnu/libpython3.12.so.1', '.')],
datas=[('gotify_tray/gui/images', 'gotify_tray/gui/images'), ('gotify_tray/gui/themes', 'gotify_tray/gui/themes')], datas=[('gotify_tray/gui/images', 'gotify_tray/gui/images'), ('gotify_tray/gui/themes', 'gotify_tray/gui/themes')],
hiddenimports=[], hiddenimports=[],
hookspath=[], hookspath=[],

View File

@@ -1,11 +1,21 @@
def main(): def main():
import os
import sys import sys
if "--version" in sys.argv: if "--version" in sys.argv:
from gotify_tray.__version__ import __version__ from gotify_tray.__version__ import __version__
print(__version__) print(__version__)
else: 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 from gotify_tray.gui import start_gui
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.hidden.connect(self.main_window_hidden_callback)
self.main_window.activated.connect(self.tray.revert_icon) self.main_window.activated.connect(self.tray.revert_icon)
self.styleHints().colorSchemeChanged.connect( if hasattr(self.styleHints(), "colorSchemeChanged"):
self.theme_change_requested_callback self.styleHints().colorSchemeChanged.connect(
) self.theme_change_requested_callback
)
self.messages_model.rowsInserted.connect( self.messages_model.rowsInserted.connect(
self.main_window.display_message_widgets 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' # 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 # 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. # 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' # 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 # 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. # 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' # 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 # 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. # 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' # 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 # 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. # 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 return False
if self.text_filter: if self.text_filter:
title = (message.title or "").lower() 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: if self.text_filter not in title and self.text_filter not in msg:
return False return False
return True return True

View File

@@ -3,14 +3,21 @@ from gotify_tray.utils import get_abs_path
themes = { themes = {
QtCore.Qt.ColorScheme.Dark: "dark", 2: "dark", # Dark
QtCore.Qt.ColorScheme.Light: "light", 1: "light", # Light
QtCore.Qt.ColorScheme.Unknown: "light", 0: "light", # Unknown
} }
def set_theme(app: QtWidgets.QApplication): 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 = "" stylesheet = ""
with open(get_abs_path(f"gotify_tray/gui/themes/base.qss"), "r") as f: 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: def get_theme_file(file: str) -> str:
app = QtCore.QCoreApplication.instance() 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}") return get_abs_path(f"gotify_tray/gui/themes/{theme}/{file}")

15
run.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Check if virtual environment exists
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
echo "Installing dependencies..."
source venv/bin/activate
pip install -r requirements.txt
else
source venv/bin/activate
fi
# Run the application
python -m gotify_tray