diff options
author | KitsuneRal <Kitsune-Ral@users.sf.net> | 2016-10-17 07:25:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 07:25:30 +0900 |
commit | b44ad3573d21c456014d7983669acc31dd6eebdf (patch) | |
tree | 9281918022181ec6eb3b28b0fe6dcbef572233e1 /jobs/mediathumbnailjob.cpp | |
parent | 6536124821c1df791a69a58de21a71322d9363f6 (diff) | |
parent | f2cfd4691d4830f57ebaea08b9aa9a4db3aad537 (diff) | |
download | libquotient-b44ad3573d21c456014d7983669acc31dd6eebdf.tar.gz libquotient-b44ad3573d21c456014d7983669acc31dd6eebdf.zip |
Merge pull request #43 from Fxrh/kitsune-request-params
Merged as amended.
Diffstat (limited to 'jobs/mediathumbnailjob.cpp')
-rw-r--r-- | jobs/mediathumbnailjob.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index 975a533d..dee06372 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -25,21 +25,21 @@ using namespace QMatrixClient; class MediaThumbnailJob::Private { public: - QUrl url; QPixmap thumbnail; - QSize requestedSize; - ThumbnailType thumbnailType; }; MediaThumbnailJob::MediaThumbnailJob(ConnectionData* data, QUrl url, QSize requestedSize, ThumbnailType thumbnailType) - : BaseJob(data, JobHttpType::GetJob, "MediaThumbnailJob") + : BaseJob(data, JobHttpType::GetJob, "MediaThumbnailJob", + QString("/_matrix/media/v1/thumbnail/%1%2").arg(url.host(), url.path()), + Query( + { { "width", QString::number(requestedSize.width()) } + , { "height", QString::number(requestedSize.height()) } + , { "method", + thumbnailType == ThumbnailType::Scale ? "scale" : "crop" } + })) , d(new Private) -{ - d->url = url; - d->requestedSize = requestedSize; - d->thumbnailType = thumbnailType; -} +{ } MediaThumbnailJob::~MediaThumbnailJob() { @@ -51,23 +51,6 @@ QPixmap MediaThumbnailJob::thumbnail() return d->thumbnail; } -QString MediaThumbnailJob::apiPath() const -{ - return QString("/_matrix/media/v1/thumbnail/%1%2").arg(d->url.host()).arg(d->url.path()); -} - -QUrlQuery MediaThumbnailJob::query() const -{ - QUrlQuery query; - query.addQueryItem("width", QString::number(d->requestedSize.width())); - query.addQueryItem("height", QString::number(d->requestedSize.height())); - if( d->thumbnailType == ThumbnailType::Scale ) - query.addQueryItem("method", "scale"); - else - query.addQueryItem("method", "crop"); - return query; -} - BaseJob::Status MediaThumbnailJob::parseReply(QByteArray data) { if( !d->thumbnail.loadFromData(data) ) |