aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avatar.cpp5
-rw-r--r--avatar.h1
-rw-r--r--room.cpp9
-rw-r--r--room.h3
-rw-r--r--user.cpp5
-rw-r--r--user.h3
6 files changed, 24 insertions, 2 deletions
diff --git a/avatar.cpp b/avatar.cpp
index 44cad4e5..040bf9bb 100644
--- a/avatar.cpp
+++ b/avatar.cpp
@@ -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
diff --git a/avatar.h b/avatar.h
index 28c16e4d..4d476ea5 100644
--- a/avatar.h
+++ b/avatar.h
@@ -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);
diff --git a/room.cpp b/room.cpp
index d79363a3..bc7c083e 100644
--- a/room.cpp
+++ b/room.cpp
@@ -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 {};
}
diff --git a/room.h b/room.h
index d2962d95..b908a763 100644
--- a/room.h
+++ b/room.h
@@ -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;
diff --git a/user.cpp b/user.cpp
index 8b662acb..b0890b61 100644
--- a/user.cpp
+++ b/user.cpp
@@ -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();
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*)