Add message filtering by priority and subject, with CRITICAL always visible

- Implement MessagesProxyModel for client-side filtering
- Add priority filter buttons (LOW 0-3, NORMAL 4-8, HIGH 9, CRITICAL 10 always shown)
- Add subject filter menu with checkable actions for message titles
- Add Remove Filters button to reset all filters
- Restore priority 10 persistent notification setting in options
- Fix settings dialog errors and update UI layouts
- Ensure CRITICAL priority messages cannot be filtered out but can toggle persistent pop-ups
This commit is contained in:
kdusek
2025-12-01 18:02:05 +01:00
parent 09f85c5902
commit 4c3b6925e5
11 changed files with 422 additions and 221 deletions

View File

@@ -34,6 +34,7 @@ from .models import (
ApplicationProxyModel,
MessagesModel,
MessagesModelItem,
MessagesProxyModel,
MessageItemDataRole,
)
from .widgets import ImagePopup, MainWindow, MessageWidget, SettingsDialog, Tray
@@ -92,11 +93,17 @@ class MainApplication(QtWidgets.QApplication):
self.downloader = Downloader()
self.messages_model = MessagesModel()
self.messages_proxy_model = MessagesProxyModel()
self.messages_proxy_model.setSourceModel(self.messages_model)
self.messages_proxy_model.update_unique_titles() # Ensure initial update
self.application_model = ApplicationModel()
self.application_proxy_model = ApplicationProxyModel(self.application_model)
self.main_window = MainWindow(
self.application_model, self.application_proxy_model, self.messages_model
self.application_model,
self.application_proxy_model,
self.messages_model,
self.messages_proxy_model,
)
self.main_window.show() # The initial .show() is necessary to get the correct sizes when adding MessageWigets
QtCore.QTimer.singleShot(0, self.main_window.hide)
@@ -112,6 +119,13 @@ class MainApplication(QtWidgets.QApplication):
self.watchdog = ServerConnectionWatchdogTask(self.gotify_client)
self.link_callbacks()
self.main_window.priority_filter_changed.connect(
self.on_priority_filter_changed
)
self.main_window.subject_filter_changed.connect(self.on_subject_filter_changed)
self.messages_proxy_model.unique_titles_updated.connect(
self.main_window.update_subject_filters
)
self.init_shortcuts()
self.gotify_client.listen()
@@ -199,6 +213,12 @@ class MainApplication(QtWidgets.QApplication):
else:
self.gotify_client.stop()
def on_priority_filter_changed(self, priorities: set[int]):
self.messages_proxy_model.set_allowed_priorities(priorities)
def on_subject_filter_changed(self, titles: set[str]):
self.messages_proxy_model.set_allowed_titles(titles)
def abort_get_messages_task(self):
"""
Abort any tasks that will result in new messages getting appended to messages_model