Add QImageReader::imageFormatsForMimeType replacement function

This commit is contained in:
Jonas Kvinge
2020-05-12 19:48:37 +02:00
parent 7e22e0e552
commit c5c7a07c12
4 changed files with 30 additions and 4 deletions

View File

@@ -37,6 +37,7 @@
#include "core/song.h"
#include "core/timeconstants.h"
#include "core/application.h"
#include "core/utilities.h"
#include "covermanager/albumcoverloader.h"
#include "tidalservice.h"
#include "tidalurlhandler.h"
@@ -1166,15 +1167,21 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album
AlbumCoverFinishCheck();
return;
}
QByteArray format = QImageReader::imageFormatsForMimeType(mimetype.toUtf8()).first();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
QList<QByteArray> format_list = QImageReader::imageFormatsForMimeType(mimetype.toUtf8());
#else
QList<QByteArray> format_list = Utilities::ImageFormatsForMimeType(mimetype.toUtf8());
#endif
QByteArray data = reply->readAll();
if (data.isEmpty()) {
if (format_list.isEmpty() || data.isEmpty()) {
Error(QString("Received empty image data for %1").arg(url.toString()));
if (album_covers_requests_sent_.contains(album_id)) album_covers_requests_sent_.remove(album_id);
AlbumCoverFinishCheck();
return;
}
QByteArray format = format_list.first();
QImage image;
if (image.loadFromData(data, format)) {