summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-05-28 16:53:01 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-05-28 16:53:01 +0200
commitf8c2b0a7e7b7251a5ff5bf475802702c1953a266 (patch)
tree28af0a3486950f86828ece89122579ec09ab7d54
parent1830f784df18057f5e07a59256cc73b5fea91a86 (diff)
downloadqutebrowser-f8c2b0a7e7b7251a5ff5bf475802702c1953a266.tar.gz
qutebrowser-f8c2b0a7e7b7251a5ff5bf475802702c1953a266.zip
Fix version checking for notifications
We need to check for the QtWebEngine version, not for the version of Qt. Additionally, there's no need to re-check in DBusNotificationAdapter.__init__ as it never gets instantiated on older versions, so it's now an assertion instead.
-rw-r--r--qutebrowser/browser/webengine/notification.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py
index d8387e6d4..158d5b9ea 100644
--- a/qutebrowser/browser/webengine/notification.py
+++ b/qutebrowser/browser/webengine/notification.py
@@ -65,12 +65,18 @@ if TYPE_CHECKING:
from qutebrowser.config import config
from qutebrowser.misc import objects
-from qutebrowser.utils import qtutils, log, utils, debug, message
+from qutebrowser.utils import qtutils, log, utils, debug, message, version
bridge: Optional['NotificationBridgePresenter'] = None
+def _notifications_supported() -> bool:
+ """Check whether the current QtWebEngine version has notification support."""
+ versions = version.qtwebengine_versions(avoid_init=True)
+ return versions.webengine >= utils.VersionNumber(5, 14)
+
+
def init() -> None:
"""Initialize the DBus notification presenter, if applicable.
@@ -84,7 +90,8 @@ def init() -> None:
# at a later point in time. However, doing so is probably too complex compared
# to its usefulness.
return
- if not qtutils.version_check('5.14'):
+
+ if not _notifications_supported():
return
global bridge
@@ -163,7 +170,7 @@ class NotificationBridgePresenter(QObject):
def __init__(self, parent: QObject = None) -> None:
super().__init__(parent)
- assert qtutils.version_check('5.14')
+ assert _notifications_supported()
self._active_notifications: Dict[int, 'QWebEngineNotification'] = {}
self._adapter: Optional[AbstractNotificationAdapter] = None
@@ -709,8 +716,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
def __init__(self, parent: QObject = None) -> None:
super().__init__(bridge)
- if not qtutils.version_check('5.14'):
- raise Error("Notifications are not supported on Qt < 5.14")
+ assert _notifications_supported()
if utils.is_windows:
# The QDBusConnection destructor seems to cause error messages (and