summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/webengine/notification.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/browser/webengine/notification.py')
-rw-r--r--qutebrowser/browser/webengine/notification.py30
1 files changed, 14 insertions, 16 deletions
diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py
index 55dcbff37..ce1ff342e 100644
--- a/qutebrowser/browser/webengine/notification.py
+++ b/qutebrowser/browser/webengine/notification.py
@@ -49,20 +49,18 @@ import itertools
import functools
import subprocess
from typing import Any, List, Dict, Optional, Iterator, Type, TYPE_CHECKING
-from qutebrowser.qt import widgets
if TYPE_CHECKING:
# putting these behind TYPE_CHECKING also means this module is importable
# on installs that don't have these
- from qutebrowser.qt import webenginewidgets, webenginecore, QWebEngineNotification
- from qutebrowser.qt import QWebEngineProfile
+ from qutebrowser.qt import webenginewidgets, webenginecore
from qutebrowser.config import config
from qutebrowser.misc import objects
from qutebrowser.utils import (
qtutils, log, utils, debug, message, objreg, resources,
)
-from qutebrowser.qt import gui, dbus, core, sip
+from qutebrowser.qt import widgets, gui, dbus, core, sip
bridge: Optional['NotificationBridgePresenter'] = None
@@ -153,7 +151,7 @@ class AbstractNotificationAdapter(core.QObject):
def present(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
*,
replaces_id: Optional[int],
) -> int:
@@ -197,7 +195,7 @@ class NotificationBridgePresenter(core.QObject):
def __init__(self, parent: core.QObject = None) -> None:
super().__init__(parent)
- self._active_notifications: Dict[int, 'QWebEngineNotification'] = {}
+ self._active_notifications: Dict[int, 'webenginecore.QWebEngineNotification'] = {}
self._adapter: Optional[AbstractNotificationAdapter] = None
config.instance.changed.connect(self._init_adapter)
@@ -257,11 +255,11 @@ class NotificationBridgePresenter(core.QObject):
candidates["auto"] = candidates["libnotify"]
return candidates[setting]
- def install(self, profile: "QWebEngineProfile") -> None:
+ def install(self, profile: "webenginewidgets.QWebEngineProfile") -> None:
"""Set the profile to use this bridge as the presenter."""
profile.setNotificationPresenter(self.present)
- def present(self, qt_notification: "QWebEngineNotification") -> None:
+ def present(self, qt_notification: "webenginecore.QWebEngineNotification") -> None:
"""Show a notification using the configured adapter.
Lazily initializes a suitable adapter if none exists yet.
@@ -297,7 +295,7 @@ class NotificationBridgePresenter(core.QObject):
def _find_replaces_id(
self,
- new_notification: "QWebEngineNotification",
+ new_notification: "webenginecore.QWebEngineNotification",
) -> Optional[int]:
"""Find an existing notification to replace.
@@ -357,7 +355,7 @@ class NotificationBridgePresenter(core.QObject):
notification.click()
self._focus_first_matching_tab(notification)
- def _focus_first_matching_tab(self, notification: "QWebEngineNotification") -> None:
+ def _focus_first_matching_tab(self, notification: "webenginecore.QWebEngineNotification") -> None:
for win_id in objreg.window_registry:
tabbedbrowser = objreg.get("tabbed-browser", window=win_id, scope="window")
for idx, tab in enumerate(tabbedbrowser.widgets()):
@@ -437,7 +435,7 @@ class SystrayNotificationAdapter(AbstractNotificationAdapter):
def present(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
*,
replaces_id: Optional[int],
) -> int:
@@ -499,7 +497,7 @@ class MessagesNotificationAdapter(AbstractNotificationAdapter):
def present(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
*,
replaces_id: Optional[int],
) -> int:
@@ -518,7 +516,7 @@ class MessagesNotificationAdapter(AbstractNotificationAdapter):
def on_web_closed(self, _notification_id: int) -> None:
"""We can't close messages."""
- def _format_message(self, qt_notification: "QWebEngineNotification") -> str:
+ def _format_message(self, qt_notification: "webenginecore.QWebEngineNotification") -> str:
title = html.escape(qt_notification.title())
body = html.escape(qt_notification.message())
hint = "" if qt_notification.icon().isNull() else " (image not shown)"
@@ -559,7 +557,7 @@ class HerbeNotificationAdapter(AbstractNotificationAdapter):
def present(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
*,
replaces_id: Optional[int],
) -> int:
@@ -580,7 +578,7 @@ class HerbeNotificationAdapter(AbstractNotificationAdapter):
def _message_lines(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
) -> Iterator[str]:
"""Get the lines to display for this notification."""
yield qt_notification.title()
@@ -1006,7 +1004,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
def present(
self,
- qt_notification: "QWebEngineNotification",
+ qt_notification: "webenginecore.QWebEngineNotification",
*,
replaces_id: Optional[int],
) -> int: