[vlc-commits] qml: use binding to calculate minimum width of ButtonsLayout
Fatih Uzunoglu
git at videolan.org
Mon Mar 29 12:47:54 UTC 2021
vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Fri Mar 19 00:00:00 2021 +0300| [046eab9c5784f3429d3c816af52f23c8400f1d2c] | committer: Pierre Lamot
qml: use binding to calculate minimum width of ButtonsLayout
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)
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=046eab9c5784f3429d3c816af52f23c8400f1d2c
---
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() {
More information about the vlc-commits
mailing list