Skip to content
Snippets Groups Projects
Commit 4b4c3213 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Allow inline replies from notifications on linux

parent 236bf09a
No related branches found
No related tags found
No related merge requests found
Pipeline #294 failed
...@@ -282,6 +282,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) ...@@ -282,6 +282,14 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
room_list_->highlightSelectedRoom(roomid); room_list_->highlightSelectedRoom(roomid);
activateWindow(); activateWindow();
}); });
connect(&notificationsManager,
&NotificationsManager::sendNotificationReply,
this,
[this](const QString &roomid, const QString &eventid, const QString &body) {
view_manager_->queueReply(roomid, eventid, body);
room_list_->highlightSelectedRoom(roomid);
activateWindow();
});
setGroupViewState(userSettings_->groupView()); setGroupViewState(userSettings_->groupView());
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
signals: signals:
void notificationClicked(const QString roomId, const QString eventId); void notificationClicked(const QString roomId, const QString eventId);
void sendNotificationReply(const QString roomId, const QString eventId, const QString body);
public slots: public slots:
void removeNotification(const QString &roomId, const QString &eventId); void removeNotification(const QString &roomId, const QString &eventId);
...@@ -58,6 +59,7 @@ private: ...@@ -58,6 +59,7 @@ private:
private slots: private slots:
void actionInvoked(uint id, QString action); void actionInvoked(uint id, QString action);
void notificationClosed(uint id, uint reason); void notificationClosed(uint id, uint reason);
void notificationReplied(uint id, QString reply);
}; };
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) #if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
......
...@@ -28,6 +28,12 @@ NotificationsManager::NotificationsManager(QObject *parent) ...@@ -28,6 +28,12 @@ NotificationsManager::NotificationsManager(QObject *parent)
"NotificationClosed", "NotificationClosed",
this, this,
SLOT(notificationClosed(uint, uint))); SLOT(notificationClosed(uint, uint)));
QDBusConnection::sessionBus().connect("org.freedesktop.Notifications",
"/org/freedesktop/Notifications",
"org.freedesktop.Notifications",
"NotificationReplied",
this,
SLOT(notificationReplied(uint, QString)));
} }
void void
...@@ -56,14 +62,19 @@ NotificationsManager::showNotification(const QString summary, ...@@ -56,14 +62,19 @@ NotificationsManager::showNotification(const QString summary,
hints["image-data"] = image; hints["image-data"] = image;
hints["sound-name"] = "message-new-instant"; hints["sound-name"] = "message-new-instant";
QList<QVariant> argumentList; QList<QVariant> argumentList;
argumentList << "nheko"; // app_name argumentList << "nheko"; // app_name
argumentList << (uint)0; // replace_id argumentList << (uint)0; // replace_id
argumentList << ""; // app_icon argumentList << ""; // app_icon
argumentList << summary; // summary argumentList << summary; // summary
argumentList << text; // body argumentList << text; // body
argumentList << (QStringList("default") << "reply"); // actions // The list of actions has always the action name and then a localized version of that
argumentList << hints; // hints // action. Currently we just use an empty string for that.
argumentList << (int)-1; // timeout in ms // 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", static QDBusInterface notifyApp("org.freedesktop.Notifications",
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
...@@ -121,9 +132,20 @@ NotificationsManager::removeNotification(const QString &roomId, const QString &e ...@@ -121,9 +132,20 @@ NotificationsManager::removeNotification(const QString &roomId, const QString &e
void void
NotificationsManager::actionInvoked(uint id, QString action) 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]; roomEventId idEntry = notificationIds[id];
emit notificationClicked(idEntry.roomId, idEntry.eventId); emit sendNotificationReply(idEntry.roomId, idEntry.eventId, reply);
} }
} }
......
...@@ -42,6 +42,7 @@ public slots: ...@@ -42,6 +42,7 @@ public slots:
void openFileSelection(); void openFileSelection();
bool uploading() const { return uploading_; } bool uploading() const { return uploading_; }
void callButton(); void callButton();
void message(QString body);
QObject *completerFor(QString completerName); QObject *completerFor(QString completerName);
...@@ -54,7 +55,6 @@ signals: ...@@ -54,7 +55,6 @@ signals:
void uploadingChanged(bool value); void uploadingChanged(bool value);
private: private:
void message(QString body);
void emote(QString body); void emote(QString body);
void command(QString name, QString args); void command(QString name, QString args);
void image(const QString &filename, void image(const QString &filename,
......
...@@ -508,6 +508,18 @@ TimelineViewManager::initWithMessages(const std::vector<QString> &roomIds) ...@@ -508,6 +508,18 @@ TimelineViewManager::initWithMessages(const std::vector<QString> &roomIds)
addRoom(roomId); addRoom(roomId);
} }
void
TimelineViewManager::queueReply(const QString &roomid,
const QString &repliedToEvent,
const QString &replyBody)
{
auto room = models.find(roomid);
if (room != models.end()) {
room.value()->setReply(repliedToEvent);
room.value()->input()->message(replyBody);
}
}
void void
TimelineViewManager::queueReactionMessage(const QString &reactedEvent, const QString &reactionKey) TimelineViewManager::queueReactionMessage(const QString &reactedEvent, const QString &reactionKey)
{ {
......
...@@ -120,6 +120,9 @@ public slots: ...@@ -120,6 +120,9 @@ public slots:
} }
void updateColorPalette(); void updateColorPalette();
void queueReply(const QString &roomid,
const QString &repliedToEvent,
const QString &replyBody);
void queueReactionMessage(const QString &reactedEvent, const QString &reactionKey); void queueReactionMessage(const QString &reactedEvent, const QString &reactionKey);
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallInvite &); void queueCallMessage(const QString &roomid, const mtx::events::msg::CallInvite &);
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallCandidates &); void queueCallMessage(const QString &roomid, const mtx::events::msg::CallCandidates &);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment