Allow disabling notification inline reply
Is temporarily required for encrypted rooms
This commit is contained in:
@@ -31,7 +31,12 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsManager::postNotification(NeoChatRoom *room, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId)
|
void NotificationsManager::postNotification(NeoChatRoom *room,
|
||||||
|
const QString &sender,
|
||||||
|
const QString &text,
|
||||||
|
const QImage &icon,
|
||||||
|
const QString &replyEventId,
|
||||||
|
bool canReply)
|
||||||
{
|
{
|
||||||
if (!NeoChatConfig::self()->showNotifications()) {
|
if (!NeoChatConfig::self()->showNotifications()) {
|
||||||
return;
|
return;
|
||||||
@@ -56,15 +61,17 @@ void NotificationsManager::postNotification(NeoChatRoom *room, const QString &se
|
|||||||
Q_EMIT Controller::instance().showWindow();
|
Q_EMIT Controller::instance().showWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
std::unique_ptr<KNotificationReplyAction> replyAction(new KNotificationReplyAction(i18n("Reply")));
|
if (canReply) {
|
||||||
replyAction->setPlaceholderText(i18n("Reply..."));
|
std::unique_ptr<KNotificationReplyAction> replyAction(new KNotificationReplyAction(i18n("Reply")));
|
||||||
connect(replyAction.get(), &KNotificationReplyAction::replied, this, [room, replyEventId](const QString &text) {
|
replyAction->setPlaceholderText(i18n("Reply..."));
|
||||||
room->postMessage(text, room->preprocessText(text), RoomMessageEvent::MsgType::Text, replyEventId, QString());
|
connect(replyAction.get(), &KNotificationReplyAction::replied, this, [room, replyEventId](const QString &text) {
|
||||||
});
|
room->postMessage(text, room->preprocessText(text), RoomMessageEvent::MsgType::Text, replyEventId, QString());
|
||||||
|
});
|
||||||
|
notification->setReplyAction(std::move(replyAction));
|
||||||
|
}
|
||||||
|
|
||||||
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localUser()->id());
|
notification->setHint(QStringLiteral("x-kde-origin-name"), room->localUser()->id());
|
||||||
|
|
||||||
notification->setReplyAction(std::move(replyAction));
|
|
||||||
|
|
||||||
notification->sendEvent();
|
notification->sendEvent();
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ class NotificationsManager : public QObject
|
|||||||
public:
|
public:
|
||||||
static NotificationsManager &instance();
|
static NotificationsManager &instance();
|
||||||
|
|
||||||
Q_INVOKABLE void postNotification(NeoChatRoom *room, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId);
|
Q_INVOKABLE void
|
||||||
|
postNotification(NeoChatRoom *room, const QString &sender, const QString &text, const QImage &icon, const QString &replyEventId, bool canReply);
|
||||||
void postInviteNotification(NeoChatRoom *room, const QString &title, const QString &sender, const QImage &icon);
|
void postInviteNotification(NeoChatRoom *room, const QString &title, const QString &sender, const QImage &icon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -239,7 +239,8 @@ void RoomListModel::handleNotifications()
|
|||||||
sender->displayname(room),
|
sender->displayname(room),
|
||||||
notification["event"].toObject()["content"].toObject()["body"].toString(),
|
notification["event"].toObject()["content"].toObject()["body"].toString(),
|
||||||
avatar_image,
|
avatar_image,
|
||||||
notification["event"].toObject()["event_id"].toString());
|
notification["event"].toObject()["event_id"].toString(),
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user