Implement inline-reply

On supported notification servers (currently only KDE Plasma 5.18+) this
action will create a reply text field inside the notification.
This commit is contained in:
kbroulik 2020-01-21 13:27:50 +01:00 committed by John Preston
parent 37cdd78bda
commit b50073d281
2 changed files with 23 additions and 4 deletions

View File

@ -107,13 +107,22 @@ NotificationData::NotificationData(
if (capabilities.contains(qsl("actions"))) { if (capabilities.contains(qsl("actions"))) {
_actions << qsl("default") << QString(); _actions << qsl("default") << QString();
// icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
_actions << qsl("mail-reply-sender")
<< tr::lng_notification_reply(tr::now);
connect(_notificationInterface.get(), connect(_notificationInterface.get(),
SIGNAL(ActionInvoked(uint, QString)), SIGNAL(ActionInvoked(uint, QString)),
this, SLOT(notificationClicked(uint))); this, SLOT(notificationClicked(uint)));
if (capabilities.contains(qsl("inline-reply"))) {
_actions << qsl("inline-reply")
<< tr::lng_notification_reply(tr::now);
connect(_notificationInterface.get(),
SIGNAL(NotificationReplied(uint,QString)),
this, SLOT(notificationReplied(uint,QString)));
} else {
// icon name according to https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
_actions << qsl("mail-reply-sender")
<< tr::lng_notification_reply(tr::now);
}
} }
if (capabilities.contains(qsl("action-icons"))) { if (capabilities.contains(qsl("action-icons"))) {
@ -236,6 +245,15 @@ void NotificationData::notificationClicked(uint id) {
} }
} }
void NotificationData::notificationReplied(uint id, const QString &text) {
if (id == _notificationId) {
const auto manager = _manager;
crl::on_main(manager, [=] {
manager->notificationReplied(_peerId, _msgId, { text, {} });
});
}
}
QDBusArgument &operator<<(QDBusArgument &argument, QDBusArgument &operator<<(QDBusArgument &argument,
const NotificationData::ImageData &imageData) { const NotificationData::ImageData &imageData) {
argument.beginStructure(); argument.beginStructure();

View File

@ -70,6 +70,7 @@ private:
private slots: private slots:
void notificationClosed(uint id); void notificationClosed(uint id);
void notificationClicked(uint id); void notificationClicked(uint id);
void notificationReplied(uint id, const QString &text);
}; };
using Notification = std::shared_ptr<NotificationData>; using Notification = std::shared_ptr<NotificationData>;