Commit c9f56212 authored by Don Gagne's avatar Don Gagne

Use ViewWithDialog, support custom config

parent 52d149b7
......@@ -24,6 +24,7 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
......@@ -31,10 +32,51 @@ import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
FactPanel {
ViewWithDialog {
viewComponent: view
Component {
id: view
FactPanel {
id: panel
anchors.fill: parent
signal showDialog(Component component, string title, int charWidth, int buttons)
signal hideDialog
function doWorkAfterComponentCompleted() {
if (controller.showCustomConfigPanel) {
panel.showDialog(customConfigDialog, "Custom Airframe Config", 50, StandardButton.Reset)
}
}
AirframeComponentController {
id: controller
factPanel: panel
}
AirframeComponentController { id: controller; factPanel: panel }
Component {
id: customConfigDialog
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()
}
}
}
Rectangle {
anchors.fill: parent
......@@ -43,36 +85,52 @@ FactPanel {
color: qgcPal.window
Column {
anchors.fill: parent
QGCLabel {
text: "AIRFRAME CONFIG"
id: header
width: parent.width
font.pointSize: 20
text: "AIRFRAME CONFIG"
}
Item { height: 20; width: 10 } // spacer
Row {
width: parent.width
Item {
id: headingSpacer
anchors.top: header.bottom
height: 20
width: 20
}
QGCLabel {
width: parent.width - applyButton.width
anchors.top: headingSpacer.bottom
width: parent.width - applyButton.width - 5
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 {
id: applyButton
anchors.top: headingSpacer.bottom
anchors.right: parent.right
text: "Apply and Restart"
onClicked: { controller.changeAutostart() }
}
Item {
id: lastSpacer
anchors.top: applyButton.bottom
height: 20
width: 10
}
Item { height: 20; width: 10 } // spacer
ScrollView {
id: scroll
anchors.top: lastSpacer.bottom
anchors.bottom: parent.bottom
width: parent.width
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
Flow {
width: parent.width
width: scroll.width
spacing: 10
ExclusiveGroup {
......@@ -154,9 +212,10 @@ FactPanel {
}
}
}
}
}
}
}
} // 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;
AirframeComponentController::AirframeComponentController(void) :
_uas(NULL),
_currentVehicleIndex(0),
_autostartId(0)
_autostartId(0),
_showCustomConfigPanel(false)
{
_uas = UASManager::instance()->getActiveUAS();
Q_ASSERT(_uas);
......@@ -82,10 +83,9 @@ AirframeComponentController::AirframeComponentController(void) :
_airframeTypes.append(QVariant::fromValue(airframeType));
}
if (_autostartId != 0) {
// FIXME: Should be a user error
Q_UNUSED(autostartFound);
Q_ASSERT(autostartFound);
if (_autostartId != 0 && !autostartFound) {
_showCustomConfigPanel = true;
emit showCustomConfigPanelChanged(true);
}
}
......
......@@ -44,6 +44,8 @@ public:
AirframeComponentController(void);
~AirframeComponentController();
Q_PROPERTY(bool showCustomConfigPanel MEMBER _showCustomConfigPanel NOTIFY showCustomConfigPanelChanged)
Q_PROPERTY(QVariantList airframeTypes MEMBER _airframeTypes CONSTANT)
Q_PROPERTY(QString currentAirframeType MEMBER _currentAirframeType CONSTANT)
......@@ -59,6 +61,7 @@ public:
signals:
void autostartIdChanged(int newAutostartId);
void showCustomConfigPanelChanged(bool show);
private:
static bool _typesRegistered;
......@@ -69,6 +72,7 @@ private:
QString _currentVehicleName;
int _currentVehicleIndex;
int _autostartId;
bool _showCustomConfigPanel;
};
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