diff options
author | Felix Rohrbach <fxrh@gmx.de> | 2016-05-08 18:59:11 +0200 |
---|---|---|
committer | Felix Rohrbach <fxrh@gmx.de> | 2016-05-08 18:59:11 +0200 |
commit | 1cd8802c73ee3c0cc0095f8be30a9bbf3442c3ca (patch) | |
tree | fa0f4aded71f27974c9922bd587ba78774ade46c /user.cpp | |
parent | fc95edb7a63bcacb02418c55e15a1aa21ac080cd (diff) | |
parent | 5a0e6080a6245aa2c68f254d7105f19629a5a654 (diff) | |
download | libquotient-1cd8802c73ee3c0cc0095f8be30a9bbf3442c3ca.tar.gz libquotient-1cd8802c73ee3c0cc0095f8be30a9bbf3442c3ca.zip |
Merge pull request #5 from KitsuneRal/basejob-improvement
Basejob improvement
Diffstat (limited to 'user.cpp')
-rw-r--r-- | user.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -28,7 +28,7 @@ using namespace QMatrixClient; -class User::Private: public QObject +class User::Private { public: User* q; @@ -45,8 +45,6 @@ class User::Private: public QObject QHash<QPair<int,int>,QPixmap> scaledMap; void requestAvatar(); - public slots: - void gotAvatar(KJob* job); }; User::User(QString userId, Connection* connection) @@ -135,17 +133,12 @@ void User::Private::requestAvatar() { MediaThumbnailJob* job = connection->getThumbnail(avatarUrl, requestedWidth, requestedHeight); - connect( job, &MediaThumbnailJob::result, this, &User::Private::gotAvatar ); -} - -void User::Private::gotAvatar(KJob* job) -{ - avatarOngoingRequest = false; - avatarValid = true; - avatar = - static_cast<MediaThumbnailJob*>(job)->thumbnail() - .scaled(requestedWidth, requestedHeight, - Qt::KeepAspectRatio, Qt::SmoothTransformation); - scaledMap.clear(); - emit q->avatarChanged(q); + connect( job, &MediaThumbnailJob::success, [=]() { + avatarOngoingRequest = false; + avatarValid = true; + avatar = job->thumbnail().scaled(requestedWidth, requestedHeight, + Qt::KeepAspectRatio, Qt::SmoothTransformation); + scaledMap.clear(); + emit q->avatarChanged(q); + }); } |