aboutsummaryrefslogtreecommitdiff
path: root/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'jobs')
-rw-r--r--jobs/mediathumbnailjob.cpp17
-rw-r--r--jobs/mediathumbnailjob.h5
2 files changed, 7 insertions, 15 deletions
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp
index 9bb731b9..9579f6b2 100644
--- a/jobs/mediathumbnailjob.cpp
+++ b/jobs/mediathumbnailjob.cpp
@@ -23,12 +23,6 @@
using namespace QMatrixClient;
-class MediaThumbnailJob::Private
-{
- public:
- QPixmap thumbnail;
-};
-
MediaThumbnailJob::MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize requestedSize,
ThumbnailType thumbnailType)
: BaseJob(data, HttpVerb::Get, "MediaThumbnailJob",
@@ -39,22 +33,21 @@ MediaThumbnailJob::MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize
, { "method",
thumbnailType == ThumbnailType::Scale ? "scale" : "crop" }
}))
- , d(new Private)
{ }
-MediaThumbnailJob::~MediaThumbnailJob()
+QPixmap MediaThumbnailJob::thumbnail()
{
- delete d;
+ return pixmap;
}
-QPixmap MediaThumbnailJob::thumbnail()
+QPixmap MediaThumbnailJob::scaledThumbnail(QSize toSize)
{
- return d->thumbnail;
+ return pixmap.scaled(toSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
BaseJob::Status MediaThumbnailJob::parseReply(QByteArray data)
{
- if( !d->thumbnail.loadFromData(data) )
+ if( !pixmap.loadFromData(data) )
{
qCDebug(JOBS) << "MediaThumbnailJob: could not read image data";
}
diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h
index 307d0a99..186da829 100644
--- a/jobs/mediathumbnailjob.h
+++ b/jobs/mediathumbnailjob.h
@@ -31,15 +31,14 @@ namespace QMatrixClient
public:
MediaThumbnailJob(const ConnectionData* data, QUrl url, QSize requestedSize,
ThumbnailType thumbnailType=ThumbnailType::Scale);
- virtual ~MediaThumbnailJob();
QPixmap thumbnail();
+ QPixmap scaledThumbnail(QSize toSize);
protected:
Status parseReply(QByteArray data) override;
private:
- class Private;
- Private* d;
+ QPixmap pixmap;
};
}