2018-03-02 08:56:36 +00:00
|
|
|
#ifndef IMAGEPROVIDER_H
|
|
|
|
#define IMAGEPROVIDER_H
|
|
|
|
|
2018-07-07 09:38:20 +00:00
|
|
|
#include <QObject>
|
2018-07-09 02:45:26 +00:00
|
|
|
#include <QtCore/QReadWriteLock>
|
|
|
|
#include <QtQuick/QQuickImageProvider>
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-07-08 05:25:46 +00:00
|
|
|
#include "connection.h"
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-09-07 05:50:06 +00:00
|
|
|
class ImageProvider : public QObject, public QQuickImageProvider {
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QMatrixClient::Connection* connection READ connection WRITE
|
|
|
|
setConnection NOTIFY connectionChanged)
|
2018-07-09 02:45:26 +00:00
|
|
|
public:
|
|
|
|
explicit ImageProvider(QObject* parent = nullptr);
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
QImage requestImage(const QString& id, QSize* pSize,
|
|
|
|
const QSize& requestedSize) override;
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
void initializeEngine(QQmlEngine* engine, const char* uri);
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-09-07 05:50:06 +00:00
|
|
|
QMatrixClient::Connection* connection() { return m_connection; }
|
|
|
|
void setConnection(QMatrixClient::Connection* newConnection) {
|
|
|
|
if (m_connection != newConnection) {
|
|
|
|
m_connection = newConnection;
|
|
|
|
emit connectionChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void connectionChanged();
|
2018-07-07 09:38:20 +00:00
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
private:
|
|
|
|
QReadWriteLock m_lock;
|
2018-11-07 08:29:24 +00:00
|
|
|
QMatrixClient::Connection* m_connection = nullptr;
|
2018-03-02 08:56:36 +00:00
|
|
|
};
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
#endif // IMAGEPROVIDER_H
|