Rewrite image provider.

Fixes #42.
This commit is contained in:
Black Hat
2018-09-07 13:50:06 +08:00
parent ffe10e9514
commit 8fb16d0700
6 changed files with 21 additions and 52 deletions

View File

@@ -6,9 +6,11 @@
#include <QtQuick/QQuickImageProvider>
#include "connection.h"
#include "imageproviderconnection.h"
class ImageProvider : public QQuickImageProvider {
class ImageProvider : public QObject, public QQuickImageProvider {
Q_OBJECT
Q_PROPERTY(QMatrixClient::Connection* connection READ connection WRITE
setConnection NOTIFY connectionChanged)
public:
explicit ImageProvider(QObject* parent = nullptr);
@@ -17,11 +19,20 @@ class ImageProvider : public QQuickImageProvider {
void initializeEngine(QQmlEngine* engine, const char* uri);
ImageProviderConnection* getConnection() { return m_connection; }
QMatrixClient::Connection* connection() { return m_connection; }
void setConnection(QMatrixClient::Connection* newConnection) {
if (m_connection != newConnection) {
m_connection = newConnection;
emit connectionChanged();
}
}
signals:
void connectionChanged();
private:
QReadWriteLock m_lock;
ImageProviderConnection* m_connection;
QMatrixClient::Connection* m_connection;
};
#endif // IMAGEPROVIDER_H