[vlc-commits] qt: report video size when a video is reattached to the QML video surface

Pierre Lamot git at videolan.org
Thu Aug 20 10:21:00 CEST 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Jul  3 09:53:47 2020 +0200| [19d0f41d92e7426a7d85e5c4d4795cd096ceac4a] | committer: Pierre Lamot

qt: report video size when a video is reattached to the QML video surface

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19d0f41d92e7426a7d85e5c4d4795cd096ceac4a
---

 modules/gui/qt/maininterface/videosurface.cpp | 8 ++++++++
 modules/gui/qt/maininterface/videosurface.hpp | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/maininterface/videosurface.cpp b/modules/gui/qt/maininterface/videosurface.cpp
index 47c888ebf9..b69e4a3b52 100644
--- a/modules/gui/qt/maininterface/videosurface.cpp
+++ b/modules/gui/qt/maininterface/videosurface.cpp
@@ -270,11 +270,19 @@ QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintN
         connect(this, &VideoSurface::keyPressed, m_provider, &VideoSurfaceProvider::onKeyPressed);
         connect(this, &VideoSurface::surfaceSizeChanged, m_provider, &VideoSurfaceProvider::onSurfaceSizeChanged);
 
+        connect(m_provider, &VideoSurfaceProvider::hasVideoChanged, this, &VideoSurface::onProviderVideoChanged);
+
         onSurfaceSizeChanged();
     }
     return node;
 }
 
+void VideoSurface::onProviderVideoChanged(bool hasVideo)
+{
+    if (hasVideo)
+        emit surfaceSizeChanged(size() * this->window()->effectiveDevicePixelRatio());
+}
+
 void VideoSurface::onSurfaceSizeChanged()
 {
     if (isEnabled())
diff --git a/modules/gui/qt/maininterface/videosurface.hpp b/modules/gui/qt/maininterface/videosurface.hpp
index 8ac5e612c4..5ff2cd4814 100644
--- a/modules/gui/qt/maininterface/videosurface.hpp
+++ b/modules/gui/qt/maininterface/videosurface.hpp
@@ -106,9 +106,11 @@ signals:
     void keyPressed(int key, Qt::KeyboardModifiers modifier);
     void mouseWheeled(const QPointF& pos, int delta, Qt::MouseButtons buttons,  Qt::KeyboardModifiers modifiers, Qt::Orientation orient);
 
-private:
+protected slots:
+    void onProviderVideoChanged(bool);
     void onSurfaceSizeChanged();
 
+private:
     QmlMainContext* m_mainCtx = nullptr;
 
     bool m_sourceSizeChanged = false;



More information about the vlc-commits mailing list