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. --- user.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'user.h') 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 From 3a913f33853c675a1051460bc36278be20a4c941 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 25 Jan 2018 19:45:08 +0900 Subject: Room, User: const-tighten up the code, set QObject names To make debugging (including QML debugging) more convenient. --- user.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user.h') diff --git a/user.h b/user.h index 3df188a1..4f48f20c 100644 --- a/user.h +++ b/user.h @@ -58,7 +58,7 @@ namespace QMatrixClient */ QString bridged() const; - const Avatar& avatarObject(); + const Avatar& avatarObject() const; Q_INVOKABLE QImage avatar(int dimension); Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight); -- cgit v1.2.3 From 80f7e44e1a9056fc55147718dd2812eb93925ec1 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 25 Jan 2018 19:48:08 +0900 Subject: Room, User: expose avatarMediaId(); declare User for the metatype system To make it easy to use User objects and fetch room and user avatars from QML. Closes #155. --- user.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'user.h') diff --git a/user.h b/user.h index 4f48f20c..8a2c53d9 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(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged STORED false) Q_PROPERTY(QUrl avatarUrl READ avatarUrl NOTIFY avatarChanged) public: User(QString userId, Connection* connection); @@ -62,6 +63,7 @@ namespace QMatrixClient Q_INVOKABLE QImage avatar(int dimension); Q_INVOKABLE QImage avatar(int requestedWidth, int requestedHeight); + QString avatarMediaId() const; QUrl avatarUrl() const; void processEvent(Event* event); @@ -84,3 +86,4 @@ namespace QMatrixClient Private* d; }; } +Q_DECLARE_METATYPE(QMatrixClient::User*) -- cgit v1.2.3