Make notifications work
Based on d1eecf8b97.
Relevant parts from that commit message:
`QVariant.Type` has moved to `QMetaType.Type`[1][] and QMeta.Type
doesn't work with int().
`QtWebEngineCore.QWebEnginePage.Feature` doesn't work with int(), so add
it to the maps twice.
[1]: https://www.qt.io/blog/whats-new-in-qmetatype-qvariant
Also:
`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/
but that part seems to work fine now. I don't quite understand why the original
commit added an "or bool(icon.rect())", but I can't find anything breaking
things without.
This commit is contained in:
parent
4f464abd3b
commit
b56d604cfe
|
|
@ -733,7 +733,15 @@ 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)
|
||||
|
||||
try:
|
||||
# Qt 5
|
||||
target_type = QVariant.Type.UInt
|
||||
except AttributeError:
|
||||
# Qt 6
|
||||
target_type = QMetaType(QMetaType.Type.UInt.value)
|
||||
|
||||
successful = variant.convert(target_type)
|
||||
assert successful
|
||||
return variant
|
||||
|
||||
|
|
@ -993,7 +1001,10 @@ class DBusNotificationAdapter(AbstractNotificationAdapter):
|
|||
actions = []
|
||||
if self._capabilities.actions:
|
||||
actions = ['default', 'Activate'] # key, name
|
||||
return QDBusArgument(actions, QMetaType.Type.QStringList)
|
||||
return QDBusArgument(
|
||||
actions,
|
||||
qtutils.extract_enum_val(QMetaType.Type.QStringList),
|
||||
)
|
||||
|
||||
def _get_hints_arg(self, *, origin_url: QUrl, icon: QImage) -> Dict[str, Any]:
|
||||
"""Get the hints argument for present()."""
|
||||
|
|
|
|||
|
|
@ -888,9 +888,11 @@ class _WebEnginePermissions(QObject):
|
|||
|
||||
# Using 0 as WORKAROUND for:
|
||||
# https://www.riverbankcomputing.com/pipermail/pyqt/2019-July/041903.html
|
||||
# Fixed in PyQt 5.13.1
|
||||
|
||||
_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',
|
||||
|
|
@ -902,6 +904,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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue