diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-01-07 10:44:59 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-01-07 10:44:59 +0100 |
commit | 4b4c321397e0681f306eade889e0fab6dbbe94f5 (patch) | |
tree | befea6b86fc0cfb5df1fca770a45611e8c531e80 /src/notifications | |
parent | Explicitly mention, if call support is enabled at build time (diff) | |
download | nheko-4b4c321397e0681f306eade889e0fab6dbbe94f5.tar.xz |
Allow inline replies from notifications on linux
Diffstat (limited to 'src/notifications')
-rw-r--r-- | src/notifications/Manager.h | 2 | ||||
-rw-r--r-- | src/notifications/ManagerLinux.cpp | 42 |
2 files changed, 34 insertions, 10 deletions
diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h index e6be5953..b5347bd6 100644 --- a/src/notifications/Manager.h +++ b/src/notifications/Manager.h @@ -36,6 +36,7 @@ public: signals: void notificationClicked(const QString roomId, const QString eventId); + void sendNotificationReply(const QString roomId, const QString eventId, const QString body); public slots: void removeNotification(const QString &roomId, const QString &eventId); @@ -58,6 +59,7 @@ private: private slots: void actionInvoked(uint id, QString action); void notificationClosed(uint id, uint reason); + void notificationReplied(uint id, QString reply); }; #if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index b9eca1a8..b5e9a6a4 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -28,6 +28,12 @@ NotificationsManager::NotificationsManager(QObject *parent) "NotificationClosed", this, SLOT(notificationClosed(uint, uint))); + QDBusConnection::sessionBus().connect("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + "NotificationReplied", + this, + SLOT(notificationReplied(uint, QString))); } void @@ -56,14 +62,19 @@ NotificationsManager::showNotification(const QString summary, hints["image-data"] = image; hints["sound-name"] = "message-new-instant"; QList<QVariant> argumentList; - argumentList << "nheko"; // app_name - argumentList << (uint)0; // replace_id - argumentList << ""; // app_icon - argumentList << summary; // summary - argumentList << text; // body - argumentList << (QStringList("default") << "reply"); // actions - argumentList << hints; // hints - argumentList << (int)-1; // timeout in ms + argumentList << "nheko"; // app_name + argumentList << (uint)0; // replace_id + argumentList << ""; // app_icon + argumentList << summary; // summary + argumentList << text; // body + // The list of actions has always the action name and then a localized version of that + // action. Currently we just use an empty string for that. + // TODO(Nico): Look into what to actually put there. + argumentList << (QStringList("default") << "" + << "inline-reply" + << ""); // actions + argumentList << hints; // hints + argumentList << (int)-1; // timeout in ms static QDBusInterface notifyApp("org.freedesktop.Notifications", "/org/freedesktop/Notifications", @@ -121,9 +132,20 @@ NotificationsManager::removeNotification(const QString &roomId, const QString &e void NotificationsManager::actionInvoked(uint id, QString action) { - if (action == "default" && notificationIds.contains(id)) { + if (notificationIds.contains(id)) { + roomEventId idEntry = notificationIds[id]; + if (action == "default") { + emit notificationClicked(idEntry.roomId, idEntry.eventId); + } + } +} + +void +NotificationsManager::notificationReplied(uint id, QString reply) +{ + if (notificationIds.contains(id)) { roomEventId idEntry = notificationIds[id]; - emit notificationClicked(idEntry.roomId, idEntry.eventId); + emit sendNotificationReply(idEntry.roomId, idEntry.eventId, reply); } } |