summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-01-02 21:46:29 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-01-02 21:46:29 +0100
commit66520eae195ad252021ebb5c6bfe2a1efc5f8adf (patch)
treeb747d2ca17a3fc4a7bc116cd309d52861e2b3c0b /src/ui
parentFix fade out of ripple (diff)
downloadnheko-66520eae195ad252021ebb5c6bfe2a1efc5f8adf.tar.xz
Port image overlay to qml
Allows you to zoom and pan now.

relates to #647
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/MxcAnimatedImage.cpp21
-rw-r--r--src/ui/MxcAnimatedImage.h1
2 files changed, 19 insertions, 3 deletions
diff --git a/src/ui/MxcAnimatedImage.cpp b/src/ui/MxcAnimatedImage.cpp

index 36e028e3..83787fff 100644 --- a/src/ui/MxcAnimatedImage.cpp +++ b/src/ui/MxcAnimatedImage.cpp
@@ -20,10 +20,12 @@ void MxcAnimatedImage::startDownload() { + nhlog::ui()->debug("START DOWNLOAD!!!"); if (!room_) return; if (eventId_.isEmpty()) return; + nhlog::ui()->debug("START DOWNLOAD2!!!"); auto event = room_->eventById(eventId_); if (!event) { @@ -92,7 +94,9 @@ MxcAnimatedImage::startDownload() "Playing movie with size: {}, {}", buffer.bytesAvailable(), buffer.isOpen()); movie.setFormat(mimeType); movie.setDevice(&buffer); - movie.setScaledSize(this->size().toSize()); + + if (height() != 0 && width() != 0) + movie.setScaledSize(this->size().toSize()); if (buffer.bytesAvailable() < 4LL * 1024 * 1024 * 1024) // cache images smaller than 4MB in RAM movie.setCacheMode(QMovie::CacheAll); @@ -145,6 +149,17 @@ MxcAnimatedImage::startDownload() }); } +void +MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + QQuickItem::geometryChanged(newGeometry, oldGeometry); + + if (newGeometry.size() != oldGeometry.size()) { + if (height() != 0 && width() != 0) + movie.setScaledSize(newGeometry.size().toSize()); + } +} + QSGNode * MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *) { @@ -171,8 +186,8 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD return nullptr; } - n->setRect(QRect(0, 0, width(), height())); - n->setFiltering(QSGTexture::Nearest); + n->setRect(0, 0, width(), height()); + n->setFiltering(QSGTexture::Linear); n->setMipmapFiltering(QSGTexture::None); return n; diff --git a/src/ui/MxcAnimatedImage.h b/src/ui/MxcAnimatedImage.h
index 1afe6a19..8891e57e 100644 --- a/src/ui/MxcAnimatedImage.h +++ b/src/ui/MxcAnimatedImage.h
@@ -60,6 +60,7 @@ public: } } + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData) override;