Make clicking on notifications open the room they're coming from
Implements #28
This commit is contained in:
committed by
Nicolas Fella
parent
5b39cd4ae8
commit
e1775f94c6
@@ -223,6 +223,8 @@ Kirigami.ApplicationWindow {
|
|||||||
onGlobalErrorOccured: showPassiveNotification(error + ": " + detail)
|
onGlobalErrorOccured: showPassiveNotification(error + ": " + detail)
|
||||||
|
|
||||||
onShowWindow: root.showWindow()
|
onShowWindow: root.showWindow()
|
||||||
|
|
||||||
|
onOpenRoom: roomManager.enterRoom(room)
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomListModel {
|
RoomListModel {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class QKeySequences;
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
|
||||||
|
class NeoChatRoom;
|
||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
|
|
||||||
class Controller : public QObject
|
class Controller : public QObject
|
||||||
@@ -109,6 +111,7 @@ Q_SIGNALS:
|
|||||||
void aboutDataChanged();
|
void aboutDataChanged();
|
||||||
void passwordStatus(Controller::PasswordStatus _t1);
|
void passwordStatus(Controller::PasswordStatus _t1);
|
||||||
void showWindow();
|
void showWindow();
|
||||||
|
void openRoom(NeoChatRoom *room);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void logout(Quotient::Connection *conn, bool serverSideLogout);
|
void logout(Quotient::Connection *conn, bool serverSideLogout);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationsManager::instance().postNotification(id(), lastEvent->id(), displayName(), sender->displayname(this), eventToString(*lastEvent), avatar(128));
|
NotificationsManager::instance().postNotification(this, lastEvent->id(), displayName(), sender->displayname(this), eventToString(*lastEvent), avatar(128));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &Room::aboutToAddHistoricalMessages,
|
connect(this, &Room::aboutToAddHistoricalMessages,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <KNotification>
|
#include <KNotification>
|
||||||
|
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
|
#include "controller.h"
|
||||||
|
|
||||||
NotificationsManager &NotificationsManager::instance()
|
NotificationsManager &NotificationsManager::instance()
|
||||||
{
|
{
|
||||||
@@ -24,7 +25,7 @@ NotificationsManager::NotificationsManager(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsManager::postNotification(const QString &roomid, const QString &eventid, const QString &roomname, const QString &sender, const QString &text, const QImage &icon)
|
void NotificationsManager::postNotification(NeoChatRoom *room, const QString &eventid, const QString &roomname, const QString &sender, const QString &text, const QImage &icon)
|
||||||
{
|
{
|
||||||
if (!NeoChatConfig::self()->showNotifications()) {
|
if (!NeoChatConfig::self()->showNotifications()) {
|
||||||
return;
|
return;
|
||||||
@@ -42,7 +43,14 @@ void NotificationsManager::postNotification(const QString &roomid, const QString
|
|||||||
|
|
||||||
notification->setText(text.toHtmlEscaped());
|
notification->setText(text.toHtmlEscaped());
|
||||||
notification->setPixmap(img);
|
notification->setPixmap(img);
|
||||||
|
|
||||||
|
notification->setDefaultAction(i18n("Open NeoChat in this room"));
|
||||||
|
connect(notification, &KNotification::defaultActivated, this, [this, room]() {
|
||||||
|
Q_EMIT Controller::instance().openRoom(room);
|
||||||
|
Q_EMIT Controller::instance().showWindow();
|
||||||
|
});
|
||||||
|
|
||||||
notification->sendEvent();
|
notification->sendEvent();
|
||||||
|
|
||||||
m_notifications.insert(roomid, notification);
|
m_notifications.insert(room->id(), notification);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <KNotification>
|
#include <KNotification>
|
||||||
|
|
||||||
|
#include "neochatroom.h"
|
||||||
|
|
||||||
class NotificationsManager : public QObject
|
class NotificationsManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -19,7 +21,7 @@ class NotificationsManager : public QObject
|
|||||||
public:
|
public:
|
||||||
static NotificationsManager &instance();
|
static NotificationsManager &instance();
|
||||||
|
|
||||||
Q_INVOKABLE void postNotification(const QString &roomId, const QString &eventId, const QString &roomName, const QString &senderName, const QString &text, const QImage &icon);
|
Q_INVOKABLE void postNotification(NeoChatRoom *roomId, const QString &eventId, const QString &roomName, const QString &senderName, const QString &text, const QImage &icon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NotificationsManager(QObject *parent = nullptr);
|
NotificationsManager(QObject *parent = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user