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:59:08 +0200
commitc7c5d14585f2e8fca34659e6f8c586dd5b767109 (patch)
tree221e5df69926bc00c193d672ad05f31429ab6ccb
parentff0fe25ebb21f00dd8e921d1e1a0b17ae8d6f051 (diff)
downloadqutebrowser-c7c5d14585f2e8fca34659e6f8c586dd5b767109.tar.gz
qutebrowser-c7c5d14585f2e8fca34659e6f8c586dd5b767109.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. (cherry picked from commit f8c2b0a7e7b7251a5ff5bf475802702c1953a266)
-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