Support inline reply
needs https://invent.kde.org/frameworks/knotifications/-/merge_requests/28
This commit is contained in:
@@ -5,11 +5,17 @@
|
||||
*/
|
||||
#include "notificationsmanager.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KNotification>
|
||||
#include "knotifications_version.h"
|
||||
#if KNOTIFICATIONS_VERSION >= QT_VERSION_CHECK(5, 81, 0)
|
||||
#include <KNotificationReplyAction>
|
||||
#endif
|
||||
|
||||
#include "controller.h"
|
||||
#include "neochatconfig.h"
|
||||
@@ -25,7 +31,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void NotificationsManager::postNotification(NeoChatRoom *room, const QString &roomName, const QString &sender, const QString &text, const QImage &icon)
|
||||
void NotificationsManager::postNotification(NeoChatRoom *room, const QString &roomName, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId)
|
||||
{
|
||||
if (!NeoChatConfig::self()->showNotifications()) {
|
||||
return;
|
||||
@@ -50,6 +56,15 @@ void NotificationsManager::postNotification(NeoChatRoom *room, const QString &ro
|
||||
Q_EMIT Controller::instance().showWindow();
|
||||
});
|
||||
|
||||
#if KNOTIFICATIONS_VERSION >= QT_VERSION_CHECK(5, 81, 0)
|
||||
std::unique_ptr<KNotificationReplyAction> replyAction(new KNotificationReplyAction(i18n("Reply")));
|
||||
replyAction->setPlaceholderText(i18n("Reply..."));
|
||||
QObject::connect(replyAction.get(), &KNotificationReplyAction::replied, [room, replyEventId](const QString &text) {
|
||||
room->postMessage(text, text, RoomMessageEvent::MsgType::Text, replyEventId, QString());
|
||||
});
|
||||
notification->setReplyAction(std::move(replyAction));
|
||||
#endif
|
||||
|
||||
notification->sendEvent();
|
||||
|
||||
m_notifications.insert(room->id(), notification);
|
||||
|
||||
Reference in New Issue
Block a user