diff options
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/mediathumbnailjob.cpp | 20 | ||||
-rw-r--r-- | jobs/mediathumbnailjob.h | 9 |
2 files changed, 8 insertions, 21 deletions
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index 9337549e..d768d253 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -18,22 +18,11 @@ #include "mediathumbnailjob.h" -#include <QtNetwork/QNetworkReply> -#include <QtCore/QDebug> - using namespace QMatrixClient; -MediaThumbnailJob::MediaThumbnailJob(QUrl url, QSize requestedSize, - ThumbnailType thumbnailType) - : BaseJob(HttpVerb::Get, "MediaThumbnailJob", - QStringLiteral("/_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" } - })) +MediaThumbnailJob::MediaThumbnailJob(QUrl url, QSize requestedSize) + : GetContentThumbnailJob(url.host(), url.path().mid(1), + requestedSize.width(), requestedSize.height()) { } QImage MediaThumbnailJob::thumbnail() const @@ -49,7 +38,8 @@ QImage MediaThumbnailJob::scaledThumbnail(QSize toSize) const BaseJob::Status MediaThumbnailJob::parseReply(QNetworkReply* reply) { - if( !_thumbnail.loadFromData(reply->readAll()) ) + GetContentThumbnailJob::parseReply(reply); + if( !_thumbnail.loadFromData(content()) ) { qCDebug(JOBS) << "MediaThumbnailJob: could not read image data"; } diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h index 2d6853c7..66960b75 100644 --- a/jobs/mediathumbnailjob.h +++ b/jobs/mediathumbnailjob.h @@ -18,19 +18,16 @@ #pragma once -#include "basejob.h" +#include "generated/content-repo.h" #include <QtGui/QPixmap> namespace QMatrixClient { - enum class ThumbnailType {Crop, Scale}; - - class MediaThumbnailJob: public BaseJob + class MediaThumbnailJob: public GetContentThumbnailJob { public: - MediaThumbnailJob(QUrl url, QSize requestedSize, - ThumbnailType thumbnailType = ThumbnailType::Scale); + MediaThumbnailJob(QUrl url, QSize requestedSize); QImage thumbnail() const; QImage scaledThumbnail(QSize toSize) const; |