[vlc-commits] qml: don't layout the expandGridView before it has a proper size

Pierre Lamot git at videolan.org
Fri Feb 14 12:00:01 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Thu Jan 30 10:05:26 2020 +0100| [87706ebbdca372b2ec4394d9e37997406c9f0d8b] | committer: Jean-Baptiste Kempf

qml: don't layout the expandGridView before it has a proper size

  this avoids using 0 width/height in our calculus

  Initialization will make the initial current index visible.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt/widgets/qml/ExpandGridView.qml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/modules/gui/qt/widgets/qml/ExpandGridView.qml b/modules/gui/qt/widgets/qml/ExpandGridView.qml
index c4976a723e..c5dd742d08 100644
--- a/modules/gui/qt/widgets/qml/ExpandGridView.qml
+++ b/modules/gui/qt/widgets/qml/ExpandGridView.qml
@@ -40,6 +40,8 @@ NavigableFocusScope {
     property alias contentX: flickable.contentX
     property bool isAnimating: animateRetractItem.running || animateExpandItem.running
 
+    property bool _isInitialised: false
+
     /// the id of the item to be expanded
     property int _expandIndex: -1
     property int _newExpandIndex: -1
@@ -154,6 +156,17 @@ NavigableFocusScope {
         }
     }
 
+    function _initialize() {
+        if (root._isInitialised)
+            return;
+
+        if (flickable.width === 0 || flickable.height === 0)
+            return;
+        if (currentIndex !== 0)
+            positionViewAtIndex(currentIndex, ItemView.Contain)
+        root._isInitialised = true;
+    }
+
     //Gridview visible above the expanded item
     Flickable {
         id: flickable
@@ -271,6 +284,11 @@ NavigableFocusScope {
         }
 
         function layout(forceRelayout) {
+            if (flickable.width === 0 || flickable.height === 0)
+                return
+            else if (!root._isInitialised)
+                root._initialize()
+
             var i
             var expandItemGridId = getExpandItemGridId()
 



More information about the vlc-commits mailing list