From 0ce284eeca96ac92524a390837b551bebb5431cc Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 26 Oct 2017 19:53:24 +0300 Subject: Move out the avatar code from User Avatars are also a property of rooms, and the supporting code is basically the same. The only thing different will be emitted signals, and the cleanest thing to support that (aside from making Avatar a QObject) seems to be to parameterise the thumbnail-updating logic with a continuation invoked upon completion of the thumbnail job. --- user.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'user.h') diff --git a/user.h b/user.h index 79a6f5db..aee6ec3e 100644 --- a/user.h +++ b/user.h @@ -30,7 +30,7 @@ namespace QMatrixClient Q_OBJECT public: User(QString userId, Connection* connection); - virtual ~User(); + ~User() override; /** * Returns the id of the user @@ -54,12 +54,11 @@ namespace QMatrixClient QPixmap avatar(int requestedWidth, int requestedHeight); - const QUrl& avatarUrl() const; + QUrl avatarUrl() const; void processEvent(Event* event); public slots: - void requestAvatar(); void rename(const QString& newName); signals: -- cgit v1.2.3 From 0fb7adfcaa5dffee4efd0a34a2a4fd655fe5c709 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 27 Oct 2017 15:19:07 +0300 Subject: Support m.room.avatar events The events are detected in /sync output, and avatars for rooms are loaded from respective URLs. Clients can use Room::avatar() method to request a pixmap of a certain size, and react to avatarChanged() in order to update the UI when new pixmaps/avatars arrive. avatarChanged() signal is overloaded with two tasks - the first firing merely indicates that a new avatar is available (without actual pixmap yet available) while the second firing means that an actual pixmap has arrived (all this is entirely transparent for clients, they just should update their pixmaps from Room::avatar() every time when Room::avatarChanged() is emitted). --- user.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'user.h') diff --git a/user.h b/user.h index aee6ec3e..148ed64d 100644 --- a/user.h +++ b/user.h @@ -20,6 +20,7 @@ #include #include +#include "avatar.h" namespace QMatrixClient { @@ -52,6 +53,7 @@ namespace QMatrixClient */ Q_INVOKABLE QString bridged() const; + Avatar& avatarObject(); QPixmap avatar(int requestedWidth, int requestedHeight); QUrl avatarUrl() const; -- cgit v1.2.3