From c1fee45f77e0dfb4df1ad954f97b60e7259a42db Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 17 Dec 2015 16:39:42 -0800 Subject: [PATCH] Handle dynamic sizing of setup buttons --- src/QmlControls/SubMenuButton.qml | 6 ++++-- src/VehicleSetup/SetupView.qml | 34 ++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/QmlControls/SubMenuButton.qml b/src/QmlControls/SubMenuButton.qml index 05533114d..4d4538b13 100644 --- a/src/QmlControls/SubMenuButton.qml +++ b/src/QmlControls/SubMenuButton.qml @@ -13,8 +13,8 @@ Button { text: "Button" ///< Pass in your own button text - checkable: true - height: ScreenTools.defaultFontPixelHeight * 2.5 + checkable: true + implicitHeight: ScreenTools.defaultFontPixelHeight * 2.5 style: ButtonStyle { id: buttonStyle @@ -30,6 +30,8 @@ Button { id: innerRect color: showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade + implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth + QGCColoredImage { id: image anchors.leftMargin: ScreenTools.defaultFontPixelWidth diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 1a7824660..27e8c33a1 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -213,24 +213,42 @@ Rectangle { Flickable { id: buttonScroll - width: mainWindow.menuButtonWidth + width: buttonColumn.width anchors.topMargin: _defaultTextHeight / 2 anchors.top: parent.top anchors.bottom: parent.bottom clip: true contentHeight: buttonColumn.height - contentWidth: parent.width + contentWidth: buttonColumn.width boundsBehavior: Flickable.StopAtBounds flickableDirection: Flickable.VerticalFlick Column { id: buttonColumn - width: mainWindow.menuButtonWidth + width: _maxButtonWidth spacing: _defaultTextHeight / 2 + property real _maxButtonWidth: 0 + + Component.onCompleted: reflowWidths() + + Connections { + target: componentRepeater + + onModelChanged: buttonColumn.reflowWidths() + } + + function reflowWidths() { + for (var i=0; i