[vlc-devel] [PATCH 2/2] qml: use binding to calculate minimum width of ButtonsLayout
Fatih Uzunoglu
fuzun54 at outlook.com
Thu Mar 18 21:00:00 UTC 2021
This patch fixes the issue of wrongly positioned controls that happened in two or more conditions:
1) Interface scale factor is changed
2) ButtonsLayout model is changed (ToolbarEditor is used to change the player controlbar configuration)
---
modules/gui/qt/player/qml/ButtonsLayout.qml | 28 ++++++++++++---------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/modules/gui/qt/player/qml/ButtonsLayout.qml b/modules/gui/qt/player/qml/ButtonsLayout.qml
index a7b5f0fd9b..c6e5f8408f 100644
--- a/modules/gui/qt/player/qml/ButtonsLayout.qml
+++ b/modules/gui/qt/player/qml/ButtonsLayout.qml
@@ -30,8 +30,22 @@ Widgets.NavigableFocusScope {
property alias model: buttonsRepeater.model
- property real _minimumWidth: 0 // minimumWidth without spacing (minimumWidth of all controls inside)
- property real minimumWidth: _minimumWidth + ((buttonsRepeater.count - 1) * buttonrow.spacing) // minimumWidth with spacing
+ readonly property real minimumWidth: {
+ var minimumWidth = 0
+
+ for (var i = 0; i < buttonsRepeater.count; ++i) {
+ var item = buttonsRepeater.itemAt(i).item
+
+ if (item.minimumWidth !== undefined)
+ minimumWidth += item.minimumWidth
+ else
+ minimumWidth += item.width
+ }
+
+ minimumWidth += ((buttonsRepeater.count - 1) * buttonrow.spacing)
+
+ return minimumWidth
+ }
property real extraWidth: undefined
property int expandableCount: 0 // widget count that can expand when extra width is available
@@ -64,11 +78,6 @@ Widgets.NavigableFocusScope {
if (item.item.extraWidth !== undefined)
buttonsLayout.expandableCount--
-
- if (item.item.minimumWidth !== undefined)
- buttonsLayout._minimumWidth -= item.item.minimumWidth
- else
- buttonsLayout._minimumWidth -= item.item.width
}
delegate: Loader {
@@ -110,11 +119,6 @@ Widgets.NavigableFocusScope {
if (buttonloader.item.navigationLeft !== undefined)
buttonloader.item.navigationLeft = buttonsLayout.navigationLeft
- if (buttonloader.item.minimumWidth !== undefined)
- buttonsLayout._minimumWidth += buttonloader.item.minimumWidth
- else
- buttonsLayout._minimumWidth += buttonloader.item.width
-
if (buttonloader.item.extraWidth !== undefined && buttonsLayout.extraWidth !== undefined) {
buttonsLayout.expandableCount++
buttonloader.item.extraWidth = Qt.binding( function() {
--
2.27.0
More information about the vlc-devel
mailing list