2018-03-02 08:56:36 +00:00
|
|
|
#ifndef IMAGEPROVIDER_H
|
|
|
|
#define IMAGEPROVIDER_H
|
|
|
|
|
|
|
|
#include <QtQuick/QQuickImageProvider>
|
|
|
|
#include <QtCore/QReadWriteLock>
|
2018-07-07 09:38:20 +00:00
|
|
|
#include <QObject>
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
#include "libqmatrixclient/connection.h"
|
|
|
|
|
|
|
|
class ImageProviderConnection: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QMatrixClient::Connection* connection READ getConnection WRITE setConnection NOTIFY connectionChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ImageProviderConnection(QObject* parent = nullptr);
|
|
|
|
~ImageProviderConnection();
|
|
|
|
|
|
|
|
QMatrixClient::Connection* getConnection() { return m_connection; }
|
|
|
|
Q_INVOKABLE void setConnection(QMatrixClient::Connection* connection) {
|
|
|
|
qDebug() << "Connection changed.";
|
|
|
|
emit connectionChanged();
|
|
|
|
m_connection = connection;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
QMatrixClient::Connection* m_connection;
|
|
|
|
signals:
|
|
|
|
void connectionChanged();
|
|
|
|
};
|
2018-03-02 08:56:36 +00:00
|
|
|
|
|
|
|
class ImageProvider: public QQuickImageProvider
|
|
|
|
{
|
|
|
|
public:
|
2018-07-07 09:38:20 +00:00
|
|
|
explicit ImageProvider(QObject* parent = nullptr);
|
2018-03-02 08:56:36 +00:00
|
|
|
|
|
|
|
QImage requestImage(const QString& id, QSize* pSize,
|
|
|
|
const QSize& requestedSize) override;
|
|
|
|
|
|
|
|
void initializeEngine(QQmlEngine *engine, const char *uri);
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
ImageProviderConnection* getConnection() { return m_connection; }
|
|
|
|
|
2018-03-02 08:56:36 +00:00
|
|
|
private:
|
|
|
|
QReadWriteLock m_lock;
|
2018-07-07 09:38:20 +00:00
|
|
|
ImageProviderConnection* m_connection;
|
2018-03-02 08:56:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IMAGEPROVIDER_H
|