summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorJimmy <jimmy@spalge.com>2021-10-03 17:10:13 +1300
committerJimmy <jimmy@spalge.com>2021-10-03 17:26:51 +1300
commitd1eecf8b97f14a36850f8a03a2279e1f8f2f6c75 (patch)
treef0a599ffaa311d923e8cb5711eeff93606996bc9 /qutebrowser
parentb4d49deac795b95ff45901cf41beac04cd680276 (diff)
downloadqutebrowser-d1eecf8b97f14a36850f8a03a2279e1f8f2f6c75.tar.gz
qutebrowser-d1eecf8b97f14a36850f8a03a2279e1f8f2f6c75.zip
Make notifications mostly work.
`QVariant.Type` has moved to `QMetaType.Type`[1][] and QMeta.Type doesn't work with int(). `QImage(':/icons/qutebrowser-64x64.png')` yields and empty QImage. This is not fixed but things don't crash because of it anymore. For instance the "Title & Body" test on https://web-push-book.gauntface.com/demos/notification-examples/ `QtWebEngineCore.QWebEnginePage.Feature` doesn't work with int(), so add it to the maps twice. `for s in scripts` was from a previous hack [1]: https://www.qt.io/blog/whats-new-in-qmetatype-qvariant
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/browser/webengine/notification.py9
-rw-r--r--qutebrowser/browser/webengine/webenginetab.py4
-rw-r--r--qutebrowser/utils/debug.py4
3 files changed, 11 insertions, 6 deletions
diff --git a/qutebrowser/browser/webengine/notification.py b/qutebrowser/browser/webengine/notification.py
index 0749724e8..9c7012337 100644
--- a/qutebrowser/browser/webengine/notification.py
+++ b/qutebrowser/browser/webengine/notification.py
@@ -679,7 +679,7 @@ class _ServerCapabilities:
def _as_uint32(x: int) -> QVariant:
"""Convert the given int to an uint32 for DBus."""
variant = QVariant(x)
- successful = variant.convert(QVariant.Type.UInt)
+ successful = variant.convert(QMetaType(QMetaType.Type.UInt.value))
assert successful
return variant
@@ -934,7 +934,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
actions = []
if self._capabilities.actions:
actions = ['default', 'Activate'] # key, name
- actions_arg = QDBusArgument(actions, QMetaType.Type.QStringList)
+ actions_arg = QDBusArgument(actions, QMetaType.Type.QStringList.value)
origin_url_str = qt_notification.origin().toDisplayString()
hints: Dict[str, Any] = {
@@ -949,7 +949,7 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
hints["x-kde-origin-name"] = origin_url_str
icon = qt_notification.icon()
- if icon.isNull():
+ if icon.isNull() or not bool(icon.rect()):
filename = ':/icons/qutebrowser-64x64.png'
icon = QImage(filename)
@@ -1028,6 +1028,9 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
# SIP >= 5.3.0.
size = qimage.byteCount()
+ if size == 0:
+ return None
+
# Despite the spec not mandating this, many notification daemons mandate that
# the last scanline does not have any padding bytes.
#
diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py
index e19bb0ccd..48991dc31 100644
--- a/qutebrowser/browser/webengine/webenginetab.py
+++ b/qutebrowser/browser/webengine/webenginetab.py
@@ -845,6 +845,7 @@ class _WebEnginePermissions(QObject):
_options = {
0: 'content.notifications.enabled',
+ QWebEnginePage.Feature.Notifications: 'content.notifications.enabled',
QWebEnginePage.Feature.Geolocation: 'content.geolocation',
QWebEnginePage.Feature.MediaAudioCapture: 'content.media.audio_capture',
QWebEnginePage.Feature.MediaVideoCapture: 'content.media.video_capture',
@@ -856,6 +857,7 @@ class _WebEnginePermissions(QObject):
_messages = {
0: 'show notifications',
+ QWebEnginePage.Feature.Notifications: 'show notifications',
QWebEnginePage.Feature.Geolocation: 'access your location',
QWebEnginePage.Feature.MediaAudioCapture: 'record audio',
QWebEnginePage.Feature.MediaVideoCapture: 'record video',
@@ -1046,7 +1048,7 @@ class _WebEngineScripts(QObject):
def _remove_js(self, name):
"""Remove an early QWebEngineScript."""
scripts = self._widget.page().scripts()
- for s in scripts.find(f'_qute_{name}'):
+ for script in scripts.find(f'_qute_{name}'):
scripts.remove(script)
def init(self):
diff --git a/qutebrowser/utils/debug.py b/qutebrowser/utils/debug.py
index 0f5eda757..be186e4ea 100644
--- a/qutebrowser/utils/debug.py
+++ b/qutebrowser/utils/debug.py
@@ -125,7 +125,7 @@ def qenum_key(base: Type[_EnumValueType],
meta_obj = base.staticMetaObject # type: ignore[union-attr]
idx = meta_obj.indexOfEnumerator(klass.__name__)
meta_enum = meta_obj.enumerator(idx)
- ret = meta_enum.valueToKey(int(value)) # type: ignore[arg-type]
+ ret = meta_enum.valueToKey(value.value) # type: ignore[arg-type]
except AttributeError:
ret = None
@@ -135,7 +135,7 @@ def qenum_key(base: Type[_EnumValueType],
ret = name
break
else:
- ret = '0x{:04x}'.format(int(value)) # type: ignore[arg-type]
+ ret = '0x{:04x}'.format(value.value) # type: ignore[arg-type]
if add_base and hasattr(base, '__name__'):
return '.'.join([base.__name__, ret])