From cb54a2a5f9e83a5076eb501e60e88846a4aa28df Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 25 Jan 2018 09:43:11 +0900 Subject: Expose avatar URLs of Room and User as Q_PROPERTY This is needed for QML integration. Closes #155. --- room.cpp | 5 +++++ room.h | 4 ++++ user.h | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/room.cpp b/room.cpp index 71b7b228..1c9063c9 100644 --- a/room.cpp +++ b/room.cpp @@ -262,6 +262,11 @@ QString Room::topic() const return d->topic; } +QUrl Room::avatarUrl() const +{ + return d->avatar.url(); +} + QImage Room::avatar(int dimension) { return avatar(dimension, dimension); diff --git a/room.h b/room.h index 2284e8b1..5b9a1785 100644 --- a/room.h +++ b/room.h @@ -105,6 +105,7 @@ namespace QMatrixClient Q_PROPERTY(QString canonicalAlias READ canonicalAlias NOTIFY namesChanged) Q_PROPERTY(QString displayName READ displayName NOTIFY namesChanged) Q_PROPERTY(QString topic READ topic NOTIFY topicChanged) + Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY avatarChanged) Q_PROPERTY(int timelineSize READ timelineSize NOTIFY addedMessages) Q_PROPERTY(QStringList memberNames READ memberNames NOTIFY memberListChanged) Q_PROPERTY(int memberCount READ memberCount NOTIFY memberListChanged) @@ -122,6 +123,8 @@ namespace QMatrixClient Room(Connection* connection, QString id, JoinState initialJoinState); ~Room() override; + // Property accessors + Connection* connection() const; User* localUser() const; const QString& id() const; @@ -130,6 +133,7 @@ namespace QMatrixClient QString canonicalAlias() const; QString displayName() const; QString topic() const; + QUrl avatarUrl() const; Q_INVOKABLE JoinState joinState() const; Q_INVOKABLE QList usersTyping() const; QList membersLeft() const; diff --git a/user.h b/user.h index 91dfdc09..3df188a1 100644 --- a/user.h +++ b/user.h @@ -33,6 +33,7 @@ namespace QMatrixClient Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString displayName READ displayname NOTIFY nameChanged STORED false) Q_PROPERTY(QString bridgeName READ bridged NOTIFY nameChanged STORED false) + Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY avatarChanged) public: User(QString userId, Connection* connection); ~User() override; @@ -61,7 +62,7 @@ namespace QMatrixClient Q_INVOKABLE QImage avatar(int dimension); Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight); - Q_INVOKABLE QUrl avatarUrl() const; + QUrl avatarUrl() const; void processEvent(Event* event); -- cgit v1.2.3