diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-28 11:26:59 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-28 11:26:59 +0900 |
commit | a3b9fe1ddd2d3b0a0cbb07ffc42317b30a1a3899 (patch) | |
tree | 206628e68b5f19db48b6bcc03cbaa00ae151fc29 /jobs | |
parent | 1dce783c4ac9ca37343648114885d332bdfe7fa1 (diff) | |
download | libquotient-a3b9fe1ddd2d3b0a0cbb07ffc42317b30a1a3899.tar.gz libquotient-a3b9fe1ddd2d3b0a0cbb07ffc42317b30a1a3899.zip |
Switch from QPixmap to QImage; add convenience avatar() overloads to Room and User
The switch is necessary because MediaThumbnailJob is supposed to return something that can be worked on in non-GUI threads (as is the case of QML image providers), and QPixmap is not supposed for usage out of the main thread.
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/mediathumbnailjob.cpp | 11 | ||||
-rw-r--r-- | jobs/mediathumbnailjob.h | 6 |
2 files changed, 9 insertions, 8 deletions
diff --git a/jobs/mediathumbnailjob.cpp b/jobs/mediathumbnailjob.cpp index 5945493a..c0d67a63 100644 --- a/jobs/mediathumbnailjob.cpp +++ b/jobs/mediathumbnailjob.cpp @@ -36,19 +36,20 @@ MediaThumbnailJob::MediaThumbnailJob(QUrl url, QSize requestedSize, })) { } -QPixmap MediaThumbnailJob::thumbnail() const +QImage MediaThumbnailJob::thumbnail() const { - return pixmap; + return _thumbnail; } -QPixmap MediaThumbnailJob::scaledThumbnail(QSize toSize) const +QImage MediaThumbnailJob::scaledThumbnail(QSize toSize) const { - return pixmap.scaled(toSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + return _thumbnail.scaled(toSize, + Qt::KeepAspectRatio, Qt::SmoothTransformation); } BaseJob::Status MediaThumbnailJob::parseReply(QByteArray data) { - if( !pixmap.loadFromData(data) ) + if( !_thumbnail.loadFromData(data) ) { qCDebug(JOBS) << "MediaThumbnailJob: could not read image data"; } diff --git a/jobs/mediathumbnailjob.h b/jobs/mediathumbnailjob.h index 292e7f14..f8f36fe9 100644 --- a/jobs/mediathumbnailjob.h +++ b/jobs/mediathumbnailjob.h @@ -32,13 +32,13 @@ namespace QMatrixClient MediaThumbnailJob(QUrl url, QSize requestedSize, ThumbnailType thumbnailType = ThumbnailType::Scale); - QPixmap thumbnail() const; - QPixmap scaledThumbnail(QSize toSize) const; + QImage thumbnail() const; + QImage scaledThumbnail(QSize toSize) const; protected: Status parseReply(QByteArray data) override; private: - QPixmap pixmap; + QImage _thumbnail; }; } // namespace QMatrixClient |