mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-30 07:18:28 +00:00
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:
parent
37cdd78bda
commit
b50073d281
@ -107,13 +107,22 @@ NotificationData::NotificationData(
|
||||
if (capabilities.contains(qsl("actions"))) {
|
||||
_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(),
|
||||
SIGNAL(ActionInvoked(uint, QString)),
|
||||
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"))) {
|
||||
@ -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,
|
||||
const NotificationData::ImageData &imageData) {
|
||||
argument.beginStructure();
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
private slots:
|
||||
void notificationClosed(uint id);
|
||||
void notificationClicked(uint id);
|
||||
void notificationReplied(uint id, const QString &text);
|
||||
};
|
||||
|
||||
using Notification = std::shared_ptr<NotificationData>;
|
||||
|
Loading…
Reference in New Issue
Block a user