[vlc-devel] [PATCH 12/22] qml: don't layout the expandGridView before it has a proper size
Pierre Lamot
pierre at videolabs.io
Fri Feb 14 11:23:47 CET 2020
this avoids using 0 width/height in our calculus
Initialization will make the initial current index visible.
---
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()
--
2.17.1
More information about the vlc-devel
mailing list