aboutsummaryrefslogtreecommitdiff
path: root/jobs/mediathumbnailjob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'jobs/mediathumbnailjob.cpp')
-rw-r--r--jobs/mediathumbnailjob.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp
index c0d67a63..ec82f57b 100644
--- a/jobs/mediathumbnailjob.cpp
+++ b/jobs/mediathumbnailjob.cpp
@@ -17,23 +17,19 @@
*/
#include "mediathumbnailjob.h"
-#include "util.h"
-
-#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(const QString& serverName,
+ const QString& mediaId, QSize requestedSize)
+ : GetContentThumbnailJob(serverName, mediaId,
+ requestedSize.width(), requestedSize.height())
+{ }
+
+MediaThumbnailJob::MediaThumbnailJob(const QUrl& mxcUri, QSize requestedSize)
+ : GetContentThumbnailJob(mxcUri.authority(),
+ mxcUri.path().mid(1), // sans leading '/'
+ requestedSize.width(), requestedSize.height())
{ }
QImage MediaThumbnailJob::thumbnail() const
@@ -47,9 +43,10 @@ QImage MediaThumbnailJob::scaledThumbnail(QSize toSize) const
Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
-BaseJob::Status MediaThumbnailJob::parseReply(QByteArray data)
+BaseJob::Status MediaThumbnailJob::parseReply(QNetworkReply* reply)
{
- if( !_thumbnail.loadFromData(data) )
+ GetContentThumbnailJob::parseReply(reply);
+ if( !_thumbnail.loadFromData(content()->readAll()) )
{
qCDebug(JOBS) << "MediaThumbnailJob: could not read image data";
}