From 0b7bee1e2600ee80554aa85b18d30ca1964535a0 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 6 May 2016 21:31:14 +0900 Subject: Use lambda captures instead of throwing job pointers around --- user.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'user.cpp') diff --git a/user.cpp b/user.cpp index f9529db3..5018fe83 100644 --- a/user.cpp +++ b/user.cpp @@ -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,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(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); + }); } -- cgit v1.2.3