Support Qt 5.11 and fix image provider.
This commit is contained in:
@@ -10,13 +10,22 @@
|
||||
|
||||
using QMatrixClient::MediaThumbnailJob;
|
||||
|
||||
ImageProvider::ImageProvider(QObject *parent)
|
||||
ImageProviderConnection::ImageProviderConnection(QObject* parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
|
||||
ImageProviderConnection::~ImageProviderConnection() {
|
||||
|
||||
}
|
||||
|
||||
ImageProvider::ImageProvider(QObject* parent)
|
||||
: QQuickImageProvider(QQmlImageProviderBase::Image,
|
||||
QQmlImageProviderBase::ForceAsynchronousImageLoading)
|
||||
{
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||
qRegisterMetaType<MediaThumbnailJob*>();
|
||||
#endif
|
||||
m_connection = new ImageProviderConnection();
|
||||
}
|
||||
|
||||
QImage ImageProvider::requestImage(const QString& id,
|
||||
@@ -34,9 +43,10 @@ QImage ImageProvider::requestImage(const QString& id,
|
||||
|
||||
MediaThumbnailJob* job = nullptr;
|
||||
QReadLocker locker(&m_lock);
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QMetaObject::invokeMethod(m_connection,
|
||||
[=] { return m_connection->getThumbnail(mxcUri, requestedSize); },
|
||||
[=] { return m_connection->getConnection()->getThumbnail(mxcUri, requestedSize); },
|
||||
Qt::BlockingQueuedConnection, &job);
|
||||
#else
|
||||
QMetaObject::invokeMethod(m_connection, "getThumbnail",
|
||||
@@ -64,9 +74,3 @@ QImage ImageProvider::requestImage(const QString& id,
|
||||
return result;
|
||||
}
|
||||
|
||||
void ImageProvider::setConnection(QMatrixClient::Connection* connection)
|
||||
{
|
||||
QWriteLocker locker(&m_lock);
|
||||
|
||||
m_connection = connection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user