Commit c9f56212 authored by Don Gagne's avatar Don Gagne

Use ViewWithDialog, support custom config

parent 52d149b7
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2 import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QGroundControl.FactSystem 1.0 import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0 import QGroundControl.FactControls 1.0
...@@ -31,132 +32,190 @@ import QGroundControl.Palette 1.0 ...@@ -31,132 +32,190 @@ import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0 import QGroundControl.Controllers 1.0
FactPanel { ViewWithDialog {
id: panel viewComponent: view
AirframeComponentController { id: controller; factPanel: panel } Component {
id: view
Rectangle { FactPanel {
anchors.fill: parent id: panel
anchors.fill: parent
QGCPalette { id: qgcPal; colorGroupEnabled: true } signal showDialog(Component component, string title, int charWidth, int buttons)
signal hideDialog
color: qgcPal.window function doWorkAfterComponentCompleted() {
if (controller.showCustomConfigPanel) {
panel.showDialog(customConfigDialog, "Custom Airframe Config", 50, StandardButton.Reset)
}
}
Column { AirframeComponentController {
anchors.fill: parent id: controller
factPanel: panel
}
QGCLabel { Component {
text: "AIRFRAME CONFIG" id: customConfigDialog
font.pointSize: 20
QGCLabel {
id: customConfigPanel
anchors.fill: parent
wrapMode: Text.WordWrap
text: "Your vehicle is using a custom airframe configuration. " +
"This configuration can only be modified through the Parameter Editor.\n\n" +
"If you want to Reset your airframe configuration and select a standard configuration, click 'Reset' above."
signal hideDialog
Fact { id: sys_autostart; name: "SYS_AUTOSTART" }
function accept() {
sys_autostart.value = 0
customConfigPanel.hideDialog()
}
}
} }
Item { height: 20; width: 10 } // spacer Rectangle {
anchors.fill: parent
QGCPalette { id: qgcPal; colorGroupEnabled: true }
color: qgcPal.window
QGCLabel {
id: header
width: parent.width
font.pointSize: 20
text: "AIRFRAME CONFIG"
}
Row { Item {
width: parent.width id: headingSpacer
anchors.top: header.bottom
height: 20
width: 20
}
QGCLabel { QGCLabel {
width: parent.width - applyButton.width anchors.top: headingSpacer.bottom
text: "Select you airframe type and specific vehicle bellow. Click 'Apply and Restart' when ready and your vehicle will be disconnected, rebooted to the new settings and re-connected." width: parent.width - applyButton.width - 5
wrapMode: Text.WordWrap text: "Select you airframe type and specific vehicle bellow. Click 'Apply and Restart' when ready and your vehicle will be disconnected, rebooted to the new settings and re-connected."
wrapMode: Text.WordWrap
} }
QGCButton { QGCButton {
id: applyButton id: applyButton
text: "Apply and Restart" anchors.top: headingSpacer.bottom
anchors.right: parent.right
text: "Apply and Restart"
onClicked: { controller.changeAutostart() } onClicked: { controller.changeAutostart() }
} }
}
Item { height: 20; width: 10 } // spacer Item {
id: lastSpacer
anchors.top: applyButton.bottom
height: 20
width: 10
}
Flow { ScrollView {
width: parent.width id: scroll
spacing: 10 anchors.top: lastSpacer.bottom
anchors.bottom: parent.bottom
width: parent.width
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
ExclusiveGroup { Flow {
id: airframeTypeExclusive width: scroll.width
} spacing: 10
Repeater { ExclusiveGroup {
model: controller.airframeTypes id: airframeTypeExclusive
}
// Outer summary item rectangle Repeater {
Rectangle { model: controller.airframeTypes
readonly property real titleHeight: 30
readonly property real innerMargin: 10
width: 250 // Outer summary item rectangle
height: 200 Rectangle {
color: qgcPal.windowShade readonly property real titleHeight: 30
readonly property real innerMargin: 10
Rectangle { width: 250
id: title height: 200
width: parent.width color: qgcPal.windowShade
height: parent.titleHeight
color: qgcPal.windowShadeDark
Text { Rectangle {
anchors.fill: parent id: title
width: parent.width
height: parent.titleHeight
color: qgcPal.windowShadeDark
color: qgcPal.buttonText Text {
font.pixelSize: 12 anchors.fill: parent
text: modelData.name
verticalAlignment: TextEdit.AlignVCenter color: qgcPal.buttonText
horizontalAlignment: TextEdit.AlignHCenter font.pixelSize: 12
} text: modelData.name
}
Image { verticalAlignment: TextEdit.AlignVCenter
id: image horizontalAlignment: TextEdit.AlignHCenter
x: innerMargin }
width: parent.width - (innerMargin * 2) }
height: parent.height - title.height - combo.height - (innerMargin * 3)
anchors.topMargin: innerMargin
anchors.top: title.bottom
source: modelData.imageResource Image {
fillMode: Image.PreserveAspectFit id: image
smooth: true x: innerMargin
width: parent.width - (innerMargin * 2)
height: parent.height - title.height - combo.height - (innerMargin * 3)
anchors.topMargin: innerMargin
anchors.top: title.bottom
} source: modelData.imageResource
fillMode: Image.PreserveAspectFit
smooth: true
QGCCheckBox { }
id: airframeCheckBox
anchors.bottom: image.bottom
anchors.right: image.right
checked: modelData.name == controller.currentAirframeType
exclusiveGroup: airframeTypeExclusive
onCheckedChanged: { QGCCheckBox {
if (checked && combo.currentIndex != -1) { id: airframeCheckBox
controller.autostartId = modelData.airframes[combo.currentIndex].autostartId anchors.bottom: image.bottom
anchors.right: image.right
checked: modelData.name == controller.currentAirframeType
exclusiveGroup: airframeTypeExclusive
onCheckedChanged: {
if (checked && combo.currentIndex != -1) {
controller.autostartId = modelData.airframes[combo.currentIndex].autostartId
}
}
} }
}
}
QGCComboBox { QGCComboBox {
id: combo id: combo
objectName: modelData.airframeType + "ComboBox" objectName: modelData.airframeType + "ComboBox"
x: innerMargin x: innerMargin
anchors.topMargin: innerMargin anchors.topMargin: innerMargin
anchors.top: image.bottom anchors.top: image.bottom
width: parent.width - (innerMargin * 2) width: parent.width - (innerMargin * 2)
model: modelData.airframes model: modelData.airframes
currentIndex: (modelData.name == controller.currentAirframeType) ? controller.currentVehicleIndex : 0 currentIndex: (modelData.name == controller.currentAirframeType) ? controller.currentVehicleIndex : 0
onCurrentIndexChanged: { onCurrentIndexChanged: {
if (airframeCheckBox.checked) { if (airframeCheckBox.checked) {
controller.autostartId = modelData.airframes[currentIndex].autostartId controller.autostartId = modelData.airframes[currentIndex].autostartId
}
}
} }
} }
} } // Repeater - summary boxes
} } // Flow - summary boxes
} } // Scroll View - summary boxes
} } // Rectangle - background
} // FactPanel
} } // Component - View
}
} }
\ No newline at end of file
...@@ -40,7 +40,8 @@ bool AirframeComponentController::_typesRegistered = false; ...@@ -40,7 +40,8 @@ bool AirframeComponentController::_typesRegistered = false;
AirframeComponentController::AirframeComponentController(void) : AirframeComponentController::AirframeComponentController(void) :
_uas(NULL), _uas(NULL),
_currentVehicleIndex(0), _currentVehicleIndex(0),
_autostartId(0) _autostartId(0),
_showCustomConfigPanel(false)
{ {
_uas = UASManager::instance()->getActiveUAS(); _uas = UASManager::instance()->getActiveUAS();
Q_ASSERT(_uas); Q_ASSERT(_uas);
...@@ -82,10 +83,9 @@ AirframeComponentController::AirframeComponentController(void) : ...@@ -82,10 +83,9 @@ AirframeComponentController::AirframeComponentController(void) :
_airframeTypes.append(QVariant::fromValue(airframeType)); _airframeTypes.append(QVariant::fromValue(airframeType));
} }
if (_autostartId != 0) { if (_autostartId != 0 && !autostartFound) {
// FIXME: Should be a user error _showCustomConfigPanel = true;
Q_UNUSED(autostartFound); emit showCustomConfigPanelChanged(true);
Q_ASSERT(autostartFound);
} }
} }
......
...@@ -44,6 +44,8 @@ public: ...@@ -44,6 +44,8 @@ public:
AirframeComponentController(void); AirframeComponentController(void);
~AirframeComponentController(); ~AirframeComponentController();
Q_PROPERTY(bool showCustomConfigPanel MEMBER _showCustomConfigPanel NOTIFY showCustomConfigPanelChanged)
Q_PROPERTY(QVariantList airframeTypes MEMBER _airframeTypes CONSTANT) Q_PROPERTY(QVariantList airframeTypes MEMBER _airframeTypes CONSTANT)
Q_PROPERTY(QString currentAirframeType MEMBER _currentAirframeType CONSTANT) Q_PROPERTY(QString currentAirframeType MEMBER _currentAirframeType CONSTANT)
...@@ -59,6 +61,7 @@ public: ...@@ -59,6 +61,7 @@ public:
signals: signals:
void autostartIdChanged(int newAutostartId); void autostartIdChanged(int newAutostartId);
void showCustomConfigPanelChanged(bool show);
private: private:
static bool _typesRegistered; static bool _typesRegistered;
...@@ -69,6 +72,7 @@ private: ...@@ -69,6 +72,7 @@ private:
QString _currentVehicleName; QString _currentVehicleName;
int _currentVehicleIndex; int _currentVehicleIndex;
int _autostartId; int _autostartId;
bool _showCustomConfigPanel;
}; };
class Airframe : public QObject class Airframe : public QObject
......
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