Commit 3a8b8099 authored by DonLakeFlyer's avatar DonLakeFlyer

Use ColumnLayout so manual reflow not needed

parent c980c331
...@@ -7,13 +7,9 @@ ...@@ -7,13 +7,9 @@
* *
****************************************************************************/ ****************************************************************************/
/// @file
/// @brief Setup View
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.AutoPilotPlugin 1.0 import QGroundControl.AutoPilotPlugin 1.0
...@@ -217,36 +213,10 @@ Rectangle { ...@@ -217,36 +213,10 @@ Rectangle {
flickableDirection: Flickable.VerticalFlick flickableDirection: Flickable.VerticalFlick
clip: true clip: true
Column { ColumnLayout {
id: buttonColumn id: buttonColumn
width: _maxButtonWidth
spacing: _defaultTextHeight / 2 spacing: _defaultTextHeight / 2
property real _maxButtonWidth: 0
Component.onCompleted: reflowWidths()
Connections {
target: componentRepeater
onModelChanged: buttonColumn.reflowWidths()
}
// I don't know why this does not work
Connections {
target: QGroundControl.settingsManager.appSettings.appFontPointSize
onValueChanged: buttonColumn.reflowWidths()
}
function reflowWidths() {
buttonColumn._maxButtonWidth = 0
for (var i = 0; i < children.length; i++) {
buttonColumn._maxButtonWidth = Math.max(buttonColumn._maxButtonWidth, children[i].width)
}
for (var j = 0; j < children.length; j++) {
children[j].width = buttonColumn._maxButtonWidth
}
}
QGCLabel { QGCLabel {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -257,7 +227,7 @@ Rectangle { ...@@ -257,7 +227,7 @@ Rectangle {
} }
Repeater { Repeater {
model: QGroundControl.corePlugin.settings model: QGroundControl.corePlugin.settingsPages
visible: QGroundControl.corePlugin.options.combineSettingsAndSetup visible: QGroundControl.corePlugin.options.combineSettingsAndSetup
SubMenuButton { SubMenuButton {
imageResource: modelData.icon imageResource: modelData.icon
...@@ -266,6 +236,7 @@ Rectangle { ...@@ -266,6 +236,7 @@ Rectangle {
text: modelData.title text: modelData.title
visible: QGroundControl.corePlugin.options.combineSettingsAndSetup visible: QGroundControl.corePlugin.options.combineSettingsAndSetup
onClicked: panelLoader.setSource(modelData.url) onClicked: panelLoader.setSource(modelData.url)
Layout.fillWidth: true
} }
} }
...@@ -276,6 +247,7 @@ Rectangle { ...@@ -276,6 +247,7 @@ Rectangle {
checked: true checked: true
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: "Summary" text: "Summary"
Layout.fillWidth: true
onClicked: showSummaryPanel() onClicked: showSummaryPanel()
} }
...@@ -287,6 +259,7 @@ Rectangle { ...@@ -287,6 +259,7 @@ Rectangle {
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: !ScreenTools.isMobile visible: !ScreenTools.isMobile
text: "Firmware" text: "Firmware"
Layout.fillWidth: true
onClicked: showFirmwarePanel() onClicked: showFirmwarePanel()
} }
...@@ -297,6 +270,8 @@ Rectangle { ...@@ -297,6 +270,8 @@ Rectangle {
visible: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.genericFirmware : false visible: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle.genericFirmware : false
setupIndicator: false setupIndicator: false
text: "PX4Flow" text: "PX4Flow"
Layout.fillWidth: true
onClicked: showPX4FlowPanel() onClicked: showPX4FlowPanel()
} }
...@@ -307,6 +282,7 @@ Rectangle { ...@@ -307,6 +282,7 @@ Rectangle {
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length != 0 visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length != 0
text: "Joystick" text: "Joystick"
Layout.fillWidth: true
onClicked: showJoystickPanel() onClicked: showJoystickPanel()
} }
...@@ -322,6 +298,7 @@ Rectangle { ...@@ -322,6 +298,7 @@ Rectangle {
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: modelData.name text: modelData.name
visible: modelData.setupSource.toString() != "" visible: modelData.setupSource.toString() != ""
Layout.fillWidth: true
onClicked: showVehicleComponentPanel(modelData) onClicked: showVehicleComponentPanel(modelData)
} }
...@@ -332,6 +309,7 @@ Rectangle { ...@@ -332,6 +309,7 @@ Rectangle {
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
visible: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable visible: QGroundControl.multiVehicleManager.parameterReadyVehicleAvailable
text: "Parameters" text: "Parameters"
Layout.fillWidth: true
onClicked: showParametersPanel() onClicked: showParametersPanel()
} }
......
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtPositioning 5.3 import QtQuick.Layouts 1.2
import QGroundControl 1.0 import QGroundControl 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.FlightDisplay 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
Rectangle { Rectangle {
...@@ -28,7 +27,6 @@ Rectangle { ...@@ -28,7 +27,6 @@ Rectangle {
readonly property real _horizontalMargin: _defaultTextWidth / 2 readonly property real _horizontalMargin: _defaultTextWidth / 2
readonly property real _verticalMargin: _defaultTextHeight / 2 readonly property real _verticalMargin: _defaultTextHeight / 2
readonly property real _buttonHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3 : ScreenTools.defaultFontPixelHeight * 2 readonly property real _buttonHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3 : ScreenTools.defaultFontPixelHeight * 2
readonly property real _buttonWidth: ScreenTools.defaultFontPixelWidth * 10
property bool _first: true property bool _first: true
...@@ -36,7 +34,7 @@ Rectangle { ...@@ -36,7 +34,7 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
//-- Default Settings //-- Default Settings
__rightPanel.source = QGroundControl.corePlugin.settings[QGroundControl.corePlugin.defaultSettings].url __rightPanel.source = QGroundControl.corePlugin.settingsPages[QGroundControl.corePlugin.defaultSettings].url
} }
QGCFlickable { QGCFlickable {
...@@ -53,25 +51,12 @@ Rectangle { ...@@ -53,25 +51,12 @@ Rectangle {
ExclusiveGroup { id: panelActionGroup } ExclusiveGroup { id: panelActionGroup }
Column { ColumnLayout {
id: buttonColumn id: buttonColumn
width: _maxButtonWidth
spacing: _verticalMargin spacing: _verticalMargin
property real _maxButtonWidth: 0 property real _maxButtonWidth: 0
Component.onCompleted: reflowWidths()
function reflowWidths() {
buttonColumn._maxButtonWidth = 0
for (var i = 0; i < children.length; i++) {
buttonColumn._maxButtonWidth = Math.max(buttonColumn._maxButtonWidth, children[i].width)
}
for (var j = 0; j < children.length; j++) {
children[j].width = buttonColumn._maxButtonWidth
}
}
QGCLabel { QGCLabel {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
...@@ -82,17 +67,20 @@ Rectangle { ...@@ -82,17 +67,20 @@ Rectangle {
} }
Repeater { Repeater {
model: QGroundControl.corePlugin.settings model: QGroundControl.corePlugin.settingsPages
QGCButton { QGCButton {
height: _buttonHeight height: _buttonHeight
text: modelData.title text: modelData.title
exclusiveGroup: panelActionGroup exclusiveGroup: panelActionGroup
Layout.fillWidth: true
onClicked: { onClicked: {
if(__rightPanel.source !== modelData.url) { if(__rightPanel.source !== modelData.url) {
__rightPanel.source = modelData.url __rightPanel.source = modelData.url
} }
checked = true checked = true
} }
Component.onCompleted: { Component.onCompleted: {
if(_first) { if(_first) {
_first = false _first = false
......
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