Commit c1fee45f authored by Don Gagne's avatar Don Gagne

Handle dynamic sizing of setup buttons

parent 1e105f0c
...@@ -13,8 +13,8 @@ Button { ...@@ -13,8 +13,8 @@ Button {
text: "Button" ///< Pass in your own button text text: "Button" ///< Pass in your own button text
checkable: true checkable: true
height: ScreenTools.defaultFontPixelHeight * 2.5 implicitHeight: ScreenTools.defaultFontPixelHeight * 2.5
style: ButtonStyle { style: ButtonStyle {
id: buttonStyle id: buttonStyle
...@@ -30,6 +30,8 @@ Button { ...@@ -30,6 +30,8 @@ Button {
id: innerRect id: innerRect
color: showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade color: showHighlight ? qgcPal.buttonHighlight : qgcPal.windowShade
implicitWidth: titleBar.x + titleBar.contentWidth + ScreenTools.defaultFontPixelWidth
QGCColoredImage { QGCColoredImage {
id: image id: image
anchors.leftMargin: ScreenTools.defaultFontPixelWidth anchors.leftMargin: ScreenTools.defaultFontPixelWidth
......
...@@ -213,24 +213,42 @@ Rectangle { ...@@ -213,24 +213,42 @@ Rectangle {
Flickable { Flickable {
id: buttonScroll id: buttonScroll
width: mainWindow.menuButtonWidth width: buttonColumn.width
anchors.topMargin: _defaultTextHeight / 2 anchors.topMargin: _defaultTextHeight / 2
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
clip: true clip: true
contentHeight: buttonColumn.height contentHeight: buttonColumn.height
contentWidth: parent.width contentWidth: buttonColumn.width
boundsBehavior: Flickable.StopAtBounds boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
Column { Column {
id: buttonColumn id: buttonColumn
width: mainWindow.menuButtonWidth width: _maxButtonWidth
spacing: _defaultTextHeight / 2 spacing: _defaultTextHeight / 2
property real _maxButtonWidth: 0
Component.onCompleted: reflowWidths()
Connections {
target: componentRepeater
onModelChanged: buttonColumn.reflowWidths()
}
function reflowWidths() {
for (var i=0; i<children.length; i++) {
_maxButtonWidth = Math.max(_maxButtonWidth, children[i].width)
}
for (var i=0; i<children.length; i++) {
children[i].width = _maxButtonWidth
}
}
SubMenuButton { SubMenuButton {
id: summaryButton id: summaryButton
width: mainWindow.menuButtonWidth
imageResource: "/qmlimages/VehicleSummaryIcon.png" imageResource: "/qmlimages/VehicleSummaryIcon.png"
setupIndicator: false setupIndicator: false
checked: true checked: true
...@@ -242,7 +260,6 @@ Rectangle { ...@@ -242,7 +260,6 @@ Rectangle {
SubMenuButton { SubMenuButton {
id: firmwareButton id: firmwareButton
width: mainWindow.menuButtonWidth
imageResource: "/qmlimages/FirmwareUpgradeIcon.png" imageResource: "/qmlimages/FirmwareUpgradeIcon.png"
setupIndicator: false setupIndicator: false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
...@@ -254,7 +271,6 @@ Rectangle { ...@@ -254,7 +271,6 @@ Rectangle {
SubMenuButton { SubMenuButton {
id: px4FlowButton id: px4FlowButton
width: mainWindow.menuButtonWidth
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.genericFirmware : false visible: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.genericFirmware : false
setupIndicator: false setupIndicator: false
...@@ -264,7 +280,6 @@ Rectangle { ...@@ -264,7 +280,6 @@ Rectangle {
SubMenuButton { SubMenuButton {
id: joystickButton id: joystickButton
width: mainWindow.menuButtonWidth
setupIndicator: true setupIndicator: true
setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false setupComplete: joystickManager.activeJoystick ? joystickManager.activeJoystick.calibrated : false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
...@@ -275,10 +290,10 @@ Rectangle { ...@@ -275,10 +290,10 @@ Rectangle {
} }
Repeater { Repeater {
model: _fullParameterVehicleAvailable ? multiVehicleManager.activeVehicle.autopilot.vehicleComponents : 0 id: componentRepeater
model: _fullParameterVehicleAvailable ? multiVehicleManager.activeVehicle.autopilot.vehicleComponents : 0
SubMenuButton { SubMenuButton {
width: mainWindow.menuButtonWidth
imageResource: modelData.iconResource imageResource: modelData.iconResource
setupIndicator: modelData.requiresSetup setupIndicator: modelData.requiresSetup
setupComplete: modelData.setupComplete setupComplete: modelData.setupComplete
...@@ -290,7 +305,6 @@ Rectangle { ...@@ -290,7 +305,6 @@ Rectangle {
} }
SubMenuButton { SubMenuButton {
width: mainWindow.menuButtonWidth
setupIndicator: false setupIndicator: false
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: multiVehicleManager.parameterReadyVehicleAvailable visible: multiVehicleManager.parameterReadyVehicleAvailable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment