summary refs log tree commit diff
path: root/include/AvatarProvider.h
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-25 15:59:47 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-25 15:59:47 +0300
commit72d5d6d2863a4e7c56089bb966ae9181e22e1b91 (patch)
treeeccdf668c865bd95edc7c71349f153f6b1a1c99c /include/AvatarProvider.h
parentLink with pthread on Linux (diff)
downloadnheko-72d5d6d2863a4e7c56089bb966ae9181e22e1b91.tar.xz
Show avatars in the completion popup
Diffstat (limited to 'include/AvatarProvider.h')
-rw-r--r--include/AvatarProvider.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/AvatarProvider.h b/include/AvatarProvider.h

index f3441290..95a5765d 100644 --- a/include/AvatarProvider.h +++ b/include/AvatarProvider.h
@@ -25,9 +25,12 @@ class MatrixClient; class TimelineItem; +//! Saved cache data per user. struct AvatarData { + //! The avatar image of the user. QImage img; + //! The url that was used to download the avatar. QUrl url; }; @@ -37,17 +40,22 @@ class AvatarProvider : public QObject public: static void init(QSharedPointer<MatrixClient> client); - static void resolve(const QString &userId, std::function<void(QImage)> callback); + //! The callback is called with the downloaded avatar for the given user + //! or the avatar is downloaded first and then saved for re-use. + static void resolve(const QString &userId, + QObject *receiver, + std::function<void(QImage)> callback); + //! Used to initialize the mapping user -> avatar url. static void setAvatarUrl(const QString &userId, const QUrl &url); - - static void clear(); + //! Remove all saved data. + static void clear() { avatars_.clear(); }; private: + //! Update the cache with the downloaded avatar. static void updateAvatar(const QString &uid, const QImage &img); static QSharedPointer<MatrixClient> client_; using UserID = QString; static std::map<UserID, AvatarData> avatars_; - static std::map<UserID, std::vector<std::function<void(QImage)>>> toBeResolved_; };