Support inline reply
needs https://invent.kde.org/frameworks/knotifications/-/merge_requests/28
This commit is contained in:
@@ -69,7 +69,8 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
avatar_image = this->avatar(128);
|
||||
}
|
||||
|
||||
NotificationsManager::instance().postNotification(this, displayName(), sender->displayname(this), eventToString(*lastEvent), avatar_image);
|
||||
NotificationsManager::instance().postNotification(this, displayName(), sender->displayname(this),
|
||||
eventToString(*lastEvent), avatar_image, !lastEvent->id().isEmpty() ? lastEvent->id() : lastEvent->transactionId());
|
||||
});
|
||||
|
||||
connect(this, &Room::aboutToAddHistoricalMessages, this, &NeoChatRoom::readMarkerLoadedChanged);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,7 +22,7 @@ class NotificationsManager : public QObject
|
||||
public:
|
||||
static NotificationsManager &instance();
|
||||
|
||||
Q_INVOKABLE void postNotification(NeoChatRoom *room, const QString &roomName, const QString &sender, const QString &text, const QImage &icon);
|
||||
Q_INVOKABLE void postNotification(NeoChatRoom *room, const QString &roomName, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId);
|
||||
|
||||
private:
|
||||
NotificationsManager(QObject *parent = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user