summary refs log tree commit diff
path: root/src/MxcImageProvider.h
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-03-18 15:46:04 +0100
committerGitHub <noreply@github.com>2021-03-18 15:46:04 +0100
commitf6de66576cc80e7767f2084d4b3efaf08aaad56d (patch)
tree6e26705fda350a3c2a4e014f4b5ac61f40fb2dad /src/MxcImageProvider.h
parentMerge pull request #527 from anjanik012/ignore_event (diff)
parentMake CI happy (diff)
downloadnheko-f6de66576cc80e7767f2084d4b3efaf08aaad56d.tar.xz
Merge pull request #475 from LorenDB/htmlFormattedNotifs
Better notifications
Diffstat (limited to 'src/MxcImageProvider.h')
-rw-r--r--src/MxcImageProvider.h31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/MxcImageProvider.h b/src/MxcImageProvider.h

index f7580bca..7b960836 100644 --- a/src/MxcImageProvider.h +++ b/src/MxcImageProvider.h
@@ -10,21 +10,18 @@ #include <QImage> #include <QThreadPool> -#include <mtx/common.hpp> +#include <functional> -#include <boost/optional.hpp> +#include <mtx/common.hpp> class MxcImageResponse : public QQuickImageResponse , public QRunnable { public: - MxcImageResponse(const QString &id, - const QSize &requestedSize, - boost::optional<mtx::crypto::EncryptedFile> encryptionInfo) + MxcImageResponse(const QString &id, const QSize &requestedSize) : m_id(id) , m_requestedSize(requestedSize) - , m_encryptionInfo(encryptionInfo) { setAutoDelete(false); } @@ -40,7 +37,6 @@ public: QString m_id, m_error; QSize m_requestedSize; QImage m_image; - boost::optional<mtx::crypto::EncryptedFile> m_encryptionInfo; }; class MxcImageProvider @@ -50,24 +46,13 @@ class MxcImageProvider Q_OBJECT public slots: QQuickImageResponse *requestImageResponse(const QString &id, - const QSize &requestedSize) override - { - boost::optional<mtx::crypto::EncryptedFile> info; - auto temp = infos.find("mxc://" + id); - if (temp != infos.end()) - info = *temp; + const QSize &requestedSize) override; - MxcImageResponse *response = new MxcImageResponse(id, requestedSize, info); - pool.start(response); - return response; - } - - void addEncryptionInfo(mtx::crypto::EncryptedFile info) - { - infos.insert(QString::fromStdString(info.url), info); - } + static void addEncryptionInfo(mtx::crypto::EncryptedFile info); + static void download(const QString &id, + const QSize &requestedSize, + std::function<void(QString, QSize, QImage, QString)> then); private: QThreadPool pool; - QHash<QString, mtx::crypto::EncryptedFile> infos; };