diff options
-rw-r--r-- | avatar.cpp | 5 | ||||
-rw-r--r-- | avatar.h | 1 | ||||
-rw-r--r-- | room.cpp | 9 | ||||
-rw-r--r-- | room.h | 3 | ||||
-rw-r--r-- | user.cpp | 5 | ||||
-rw-r--r-- | user.h | 3 |
6 files changed, 24 insertions, 2 deletions
@@ -62,6 +62,11 @@ QImage Avatar::get(int width, int height, notifier_t notifier) const return d->get({width, height}, notifier); } +QString Avatar::mediaId() const +{ + return d->_url.authority() + d->_url.path(); +} + QImage Avatar::Private::get(QSize size, Avatar::notifier_t notifier) const { // FIXME: Alternating between longer-width and longer-height requests @@ -38,6 +38,7 @@ namespace QMatrixClient QImage get(int dimension, notifier_t notifier) const; QImage get(int w, int h, notifier_t notifier) const; + QString mediaId() const; QUrl url() const; bool updateUrl(const QUrl& newUrl); @@ -263,6 +263,11 @@ QString Room::topic() const return d->topic; } +QString Room::avatarMediaId() const +{ + return d->avatar.mediaId(); +} + QUrl Room::avatarUrl() const { return d->avatar.url(); @@ -284,8 +289,8 @@ QImage Room::avatar(int width, int height) auto theOtherOneIt = d->membersMap.begin(); if (theOtherOneIt.value() == localUser()) ++theOtherOneIt; - return theOtherOneIt.value()->avatarObject() - .get(width, height, [=] { emit avatarChanged(); }); + return (*theOtherOneIt)->avatarObject() + .get(width, height, [=] { emit avatarChanged(); }); } return {}; } @@ -104,7 +104,9 @@ 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(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged STORED false) 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) @@ -132,6 +134,7 @@ namespace QMatrixClient QString canonicalAlias() const; QString displayName() const; QString topic() const; + QString avatarMediaId() const; QUrl avatarUrl() const; Q_INVOKABLE JoinState joinState() const; Q_INVOKABLE QList<User*> usersTyping() const; @@ -145,6 +145,11 @@ QImage User::avatar(int width, int height) return d->avatar.get(width, height, [=] { emit avatarChanged(this); }); } +QString User::avatarMediaId() const +{ + return d->avatar.mediaId(); +} + QUrl User::avatarUrl() const { return d->avatar.url(); @@ -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*) |