[vlc-devel] [PATCH v2 08/16] qt: report video size when a video is reattached to the QML video surface

Pierre Lamot pierre at videolabs.io
Fri Aug 14 18:43:42 CEST 2020


---
 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;
-- 
2.25.1



More information about the vlc-devel mailing list