aboutsummaryrefslogtreecommitdiff
path: root/avatar.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 14:46:18 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 14:46:18 +0900
commitcbfe29b3435fbe47fee268facbe6a82000fce0ad (patch)
treee922f1a1505ff1d0a3cdaca56ed5fd151c3aa410 /avatar.cpp
parentb1dd0e7ea87842fb5ff9deb14beb3474136b06f3 (diff)
parenta4a1129385731c3999a6d5986a24fc069938245c (diff)
downloadlibquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.tar.gz
libquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'avatar.cpp')
-rw-r--r--avatar.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/avatar.cpp b/avatar.cpp
index f5101ddb..b2f50a67 100644
--- a/avatar.cpp
+++ b/avatar.cpp
@@ -24,8 +24,38 @@
using namespace QMatrixClient;
+class Avatar::Private
+{
+ public:
+ Private(Connection* c, QIcon di) : _connection(c), _defaultIcon(di) { }
+ QPixmap get(int width, int height, Avatar::notifier_t notifier);
+
+ Connection* _connection;
+ const QIcon _defaultIcon;
+ QUrl _url;
+ QPixmap _originalPixmap;
+
+ std::vector<QPair<QSize, QPixmap>> _scaledPixmaps;
+
+ QSize _requestedSize;
+ bool _valid = false;
+ MediaThumbnailJob* _ongoingRequest = nullptr;
+ std::vector<notifier_t> notifiers;
+};
+
+Avatar::Avatar(Connection* connection, QIcon defaultIcon)
+ : d(new Private { connection, std::move(defaultIcon) })
+{ }
+
+Avatar::~Avatar() = default;
+
QPixmap Avatar::get(int width, int height, Avatar::notifier_t notifier)
{
+ return d->get(width, height, notifier);
+}
+
+QPixmap Avatar::Private::get(int width, int height, Avatar::notifier_t notifier)
+{
QSize size(width, height);
// FIXME: Alternating between longer-width and longer-height requests
@@ -73,12 +103,15 @@ QPixmap Avatar::get(int width, int height, Avatar::notifier_t notifier)
return pixmap;
}
+QUrl Avatar::url() const { return d->_url; }
+
bool Avatar::updateUrl(const QUrl& newUrl)
{
- if (newUrl == _url)
+ if (newUrl == d->_url)
return false;
- _url = newUrl;
- _valid = false;
+ d->_url = newUrl;
+ d->_valid = false;
return true;
}
+