aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-05 11:17:13 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-09 11:54:45 +0900
commita671d1aeff6bc9c01aa4204e0c05da894c72b603 (patch)
tree9e239608ffea3e59cc971358483d0c80063e3ae9
parent4c1d52601be66caafa913171b5d5ed47ee4eb67d (diff)
downloadlibquotient-a671d1aeff6bc9c01aa4204e0c05da894c72b603.tar.gz
libquotient-a671d1aeff6bc9c01aa4204e0c05da894c72b603.zip
MediaThumbnailJob: Rewire to GetContentThumbnailJob; decommission ThumbnailType
"crop" thumbnail type didn't seem to be ever used. Once GTAD is able to generate enums, the respective code will show up in GetContentThumbnailJob and this parameter can be reintroduced in MediaThumbnailJob. As of now, just rely on the default "scale" value.
-rw-r--r--jobs/mediathumbnailjob.cpp20
-rw-r--r--jobs/mediathumbnailjob.h9
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;