Commit fb8a050b authored by Don Gagne's avatar Don Gagne

SetupView converted to Qml only

parent 63e37c4a
......@@ -546,9 +546,6 @@ INCLUDEPATH += \
src/VehicleSetup \
src/AutoPilotPlugins/PX4 \
FORMS += \
src/VehicleSetup/SetupView.ui \
HEADERS+= \
src/AutoPilotPlugins/AutoPilotPlugin.h \
src/AutoPilotPlugins/AutoPilotPluginManager.h \
......
......@@ -43,6 +43,7 @@
<file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file>
<file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.qml</file>
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
<file alias="SetupViewButtonsConnected.qml">src/VehicleSetup/SetupViewButtonsConnected.qml</file>
<file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file>
......
......@@ -25,7 +25,6 @@
/// @author Don Gagne <don@thegagnes.com>
#include "AutoPilotPlugin.h"
#include "SetupView.h"
#include "QGCApplication.h"
#include "QGCMessageBox.h"
#include "MainWindow.h"
......@@ -40,6 +39,8 @@ AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) :
Q_ASSERT(_uas);
connect(_uas, &UASInterface::disconnected, this, &AutoPilotPlugin::_uasDisconnected);
connect(_uas, &UASInterface::armingChanged, this, &AutoPilotPlugin::armedChanged);
connect(this, &AutoPilotPlugin::pluginReadyChanged, this, &AutoPilotPlugin::_pluginReadyChanged);
}
......@@ -66,12 +67,6 @@ void AutoPilotPlugin::_pluginReadyChanged(bool pluginReady)
Q_ASSERT(mainWindow);
mainWindow->getMainToolBar()->onSetupView();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
QWidget* setupViewWidget = mainWindow->getCurrentViewWidget();
Q_ASSERT(setupViewWidget);
SetupView* setupView = qobject_cast<SetupView*>(setupViewWidget);
Q_ASSERT(setupView);
setupView->summaryButtonClicked();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
}
}
}
......@@ -172,3 +167,8 @@ void AutoPilotPlugin::readParametersFromStream(QTextStream &stream)
{
_getParameterLoader()->readParametersFromStream(stream);
}
bool AutoPilotPlugin::armed(void)
{
return _uas->isArmed();
}
......@@ -61,6 +61,8 @@ public:
/// false: One or more vehicle components require setup
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged)
Q_PROPERTY(bool armed READ armed NOTIFY armedChanged)
/// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(void);
......@@ -111,6 +113,7 @@ public:
// Property accessors
bool pluginReady(void) { return _pluginReady; }
bool setupComplete(void);
bool armed(void);
UASInterface* uas(void) { return _uas; }
......@@ -118,6 +121,7 @@ signals:
void pluginReadyChanged(bool pluginReady);
void setupCompleteChanged(bool setupComplete);
void parameterListProgress(float value);
void armedChanged(bool armed);
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
......
......@@ -171,16 +171,9 @@ QStringList AirframeComponent::paramFilterList(void) const
return list;
}
QWidget* AirframeComponent::setupWidget(void) const
QUrl AirframeComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml");
}
QUrl AirframeComponent::summaryQmlSource(void) const
......
......@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
......
......@@ -104,16 +104,9 @@ QStringList FlightModesComponent::paramFilterList(void) const
return list;
}
QWidget* FlightModesComponent::setupWidget(void) const
QUrl FlightModesComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/FlightModesComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/FlightModesComponent.qml");
}
QUrl FlightModesComponent::summaryQmlSource(void) const
......
......@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
......
......@@ -86,13 +86,9 @@ QStringList PowerComponent::paramFilterList(void) const
return list;
}
QWidget* PowerComponent::setupWidget(void) const
QUrl PowerComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/PowerComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/PowerComponent.qml");
}
QUrl PowerComponent::summaryQmlSource(void) const
......
......@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup (void) const;
virtual bool setupComplete (void) const;
virtual QString setupStateDescription (void) const;
virtual QWidget* setupWidget (void) const;
virtual QUrl setupSource (void) const;
virtual QStringList paramFilterList (void) const;
virtual QUrl summaryQmlSource (void) const;
virtual QString prerequisiteSetup (void) const;
......
......@@ -138,13 +138,9 @@ QStringList RadioComponent::paramFilterList(void) const
return list;
}
QWidget* RadioComponent::setupWidget(void) const
QUrl RadioComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/RadioComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/RadioComponent.qml");
}
QUrl RadioComponent::summaryQmlSource(void) const
......
......@@ -48,7 +48,7 @@ public:
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
......
......@@ -84,16 +84,9 @@ QStringList SafetyComponent::paramFilterList(void) const
return list;
}
QWidget* SafetyComponent::setupWidget(void) const
QUrl SafetyComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml");
}
QUrl SafetyComponent::summaryQmlSource(void) const
......
......@@ -48,7 +48,7 @@ public:
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
......
......@@ -105,15 +105,9 @@ QStringList SensorsComponent::paramFilterList(void) const
return list;
}
QWidget* SensorsComponent::setupWidget(void) const
QUrl SensorsComponent::setupSource(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml"));
return holder;
return QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml");
}
QUrl SensorsComponent::summaryQmlSource(void) const
......
......@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
......
......@@ -27,7 +27,6 @@
#include "FactSystem.h"
#include "UASManager.h"
#include "QGCApplication.h"
#include "VehicleComponent.h"
#include "FactPanelController.h"
#include <QtQml>
......@@ -42,7 +41,6 @@ FactSystem::FactSystem(QObject* parent) :
qmlRegisterType<Fact>(_factSystemQmlUri, 1, 0, "Fact");
qmlRegisterType<FactPanelController>(_factSystemQmlUri, 1, 0, "FactPanelController");
qmlRegisterUncreatableType<VehicleComponent>(_factSystemQmlUri, 1, 0, "VehicleComponent", "Can only reference, cannot create");
}
FactSystem::~FactSystem()
......
......@@ -67,6 +67,11 @@
#include "SensorsComponentController.h"
#include "PowerComponentController.h"
#include "RadioComponentController.h"
#ifndef __android__
#include "FirmwareUpgradeController.h"
#endif
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
#include "ScreenTools.h"
#include "MavManager.h"
......@@ -318,6 +323,9 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<QGCPalette>("QGroundControl.Palette", 1, 0, "QGCPalette");
qmlRegisterUncreatableType<AutoPilotPlugin>("QGroundControl.AutoPilotPlugin", 1, 0, "AutoPilotPlugin", "Can only reference, cannot create");
qmlRegisterUncreatableType<VehicleComponent>("QGroundControl.AutoPilotPlugin", 1, 0, "VehicleComponent", "Can only reference, cannot create");
qmlRegisterType<ViewWidgetController>("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<CustomCommandWidgetController>("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
......@@ -326,7 +334,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<SensorsComponentController>("QGroundControl.Controllers", 1, 0, "SensorsComponentController");
qmlRegisterType<PowerComponentController>("QGroundControl.Controllers", 1, 0, "PowerComponentController");
qmlRegisterType<RadioComponentController>("QGroundControl.Controllers", 1, 0, "RadioComponentController");
#ifndef __android__
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
#endif
//-- Create QML Singleton Interfaces
qmlRegisterSingletonType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
......@@ -372,7 +383,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
splashScreen->finish(mainWindow);
mainWindow->splashScreenFinished();
// Now that main window is upcheck for lost log files
// Now that main window is up check for lost log files
connect(this, &QGCApplication::checkForLostLogFiles, MAVLinkProtocol::instance(), &MAVLinkProtocol::checkForLostLogFiles);
emit checkForLostLogFiles();
......
......@@ -53,7 +53,12 @@ void QGCQmlWidgetHolder::setContextPropertyObject(const QString& name, QObject*
_ui.qmlWidget->rootContext()->setContextProperty(name, object);
}
QQmlContext* QGCQmlWidgetHolder::getRootContext()
QQmlContext* QGCQmlWidgetHolder::getRootContext(void)
{
return _ui.qmlWidget->rootContext();
}
QQuickItem* QGCQmlWidgetHolder::getRootObject(void)
{
return _ui.qmlWidget->rootObject();
}
......@@ -50,8 +50,11 @@ public:
void setAutoPilot(AutoPilotPlugin* autoPilot);
/// Get Root Context
QQmlContext* getRootContext();
QQmlContext* getRootContext(void);
/// Get Root Object
QQuickItem* getRootObject(void);
/// Sets the QML into the control. Will display errors message box if error occurs loading source.
/// @return true: source loaded, false: source not loaded, errors occured
bool setSource(const QUrl& qmlUrl);
......
......@@ -43,26 +43,20 @@
#include <QDebug>
SetupView::SetupView(QWidget* parent) :
QWidget(parent),
QGCQmlWidgetHolder(parent),
_uasCurrent(NULL),
_initComplete(false),
_autoPilotPlugin(NULL),
_currentSetupWidget(NULL),
_ui(new Ui::SetupView)
_initComplete(false)
{
_ui->setupUi(this);
bool fSucceeded = connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(_setActiveUAS(UASInterface*)));
Q_UNUSED(fSucceeded);
Q_ASSERT(fSucceeded);
#ifndef __android__
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
#ifdef __android__
_showFirmware = false;
#else
_showFirmware = true;
#endif
_ui->buttonHolder->rootContext()->setContextProperty("controller", this);
_ui->buttonHolder->setAutoPilot(NULL);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml"));
connect(UASManager::instance(), &UASManager::activeUASSet, this, &SetupView::_setActiveUAS);
getRootContext()->setContextProperty("controller", this);
setSource(QUrl::fromUserInput("qrc:/qml/SetupView.qml"));
_setActiveUAS(UASManager::instance()->getActiveUAS());
}
......@@ -75,8 +69,7 @@ SetupView::~SetupView()
void SetupView::_setActiveUAS(UASInterface* uas)
{
if (_uasCurrent) {
Q_ASSERT(_autoPilotPlugin);
disconnect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
disconnect(_autopilot.data(), &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
}
_pluginReadyChanged(false);
......@@ -84,98 +77,69 @@ void SetupView::_setActiveUAS(UASInterface* uas)
_uasCurrent = uas;
if (_uasCurrent) {
_autoPilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uasCurrent).data();
_pluginReadyChanged(_autoPilotPlugin->pluginReady());
connect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
_autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uasCurrent);
if (_autopilot.data()->pluginReady()) {
_pluginReadyChanged(_autopilot.data()->pluginReady());
}
connect(_autopilot.data(), &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
}
}
void SetupView::_pluginReadyChanged(bool pluginReady)
{
if (pluginReady) {
_ui->buttonHolder->setAutoPilot(_autoPilotPlugin);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsConnected.qml"));
summaryButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("summaryButton");
Q_ASSERT(button);
button->setProperty("checked", true);
_readyAutopilot = _autopilot.data();
emit autopilotChanged(_readyAutopilot);
} else {
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml"));
_ui->buttonHolder->setAutoPilot(NULL);
firmwareButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("firmwareButton");
Q_ASSERT(button);
button->setProperty("checked", true);
_readyAutopilot = NULL;
emit autopilotChanged(NULL);
_autopilot.clear();
}
}
void SetupView::_changeSetupWidget(QWidget* newWidget)
{
if (_currentSetupWidget) {
delete _currentSetupWidget;
}
_currentSetupWidget = newWidget;
_ui->horizontalLayout->addWidget(newWidget);
}
void SetupView::firmwareButtonClicked(void)
#ifdef UNITTEST_BUILD
void SetupView::showFirmware(void)
{
#ifndef __android__
//FIXME: Hack out for android for now
if (_uasCurrent && _uasCurrent->isArmed()) {
QGCMessageBox::warning("Setup", "Firmware Update cannot be performed while vehicle is armed.");
return;
}
QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder;
Q_CHECK_PTR(setup);
setup->setSource(QUrl::fromUserInput("qrc:/qml/FirmwareUpgrade.qml"));
_changeSetupWidget(setup);
QVariant returnedValue;
bool success = QMetaObject::invokeMethod(getRootObject(),
"showFirmwarePanel",
Q_RETURN_ARG(QVariant, returnedValue));
Q_ASSERT(success);
#endif
}
void SetupView::parametersButtonClicked(void)
void SetupView::showParameters(void)
{
QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder;
Q_CHECK_PTR(setup);
Q_ASSERT(_autoPilotPlugin);
setup->setAutoPilot(_autoPilotPlugin);
setup->setSource(QUrl::fromUserInput("qrc:/qml/SetupParameterEditor.qml"));
_changeSetupWidget(setup);
QVariant returnedValue;
bool success = QMetaObject::invokeMethod(getRootObject(),
"showParametersPanel",
Q_RETURN_ARG(QVariant, returnedValue));
Q_ASSERT(success);
}
void SetupView::summaryButtonClicked(void)
void SetupView::showSummary(void)
{
Q_ASSERT(_autoPilotPlugin);
QGCQmlWidgetHolder* summary = new QGCQmlWidgetHolder;
Q_CHECK_PTR(summary);
summary->setAutoPilot(_autoPilotPlugin);
summary->setSource(QUrl::fromUserInput("qrc:/qml/VehicleSummary.qml"));
_changeSetupWidget(summary);
QVariant returnedValue;
bool success = QMetaObject::invokeMethod(getRootObject(),
"showSummaryPanel",
Q_RETURN_ARG(QVariant, returnedValue));
Q_ASSERT(success);
}
void SetupView::setupButtonClicked(const QVariant& component)
void SetupView::showVehicleComponentSetup(const QUrl& url)
{
if (_uasCurrent->isArmed()) {
QGCMessageBox::warning("Setup", "Setup cannot be performed while vehicle is armed.");
return;
}
VehicleComponent* vehicle = qobject_cast<VehicleComponent*>(component.value<QObject*>());
Q_ASSERT(vehicle);
QString setupPrereq = vehicle->prerequisiteSetup();
if (!setupPrereq.isEmpty()) {
QGCMessageBox::warning("Setup", QString("%1 setup must be completed prior to %2 setup.").arg(setupPrereq).arg(vehicle->name()));
return;
}
_changeSetupWidget(vehicle->setupWidget());
QVariant returnedValue;
QVariant varSource = url;
bool success = QMetaObject::invokeMethod(getRootObject(),
"showVehicleComponentPanel",
Q_RETURN_ARG(QVariant, returnedValue),
Q_ARG(QVariant, varSource));
Q_ASSERT(success);
}
#endif
AutoPilotPlugin* SetupView::autopilot(void)
{
return _readyAutopilot;
}
\ No newline at end of file
......@@ -27,6 +27,7 @@
#include "UASInterface.h"
#include "VehicleComponent.h"
#include "AutoPilotPlugin.h"
#include "QGCQmlWidgetHolder.h"
#include <QWidget>
......@@ -34,11 +35,7 @@
/// @brief This class is used to display the UI for the VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
namespace Ui {
class SetupView;
}
class SetupView : public QWidget
class SetupView : public QGCQmlWidgetHolder
{
Q_OBJECT
......@@ -46,24 +43,31 @@ public:
explicit SetupView(QWidget* parent = 0);
~SetupView();
Q_INVOKABLE void firmwareButtonClicked(void);
Q_INVOKABLE void parametersButtonClicked(void);
Q_INVOKABLE void summaryButtonClicked(void);
Q_INVOKABLE void setupButtonClicked(const QVariant& component);
Q_PROPERTY(AutoPilotPlugin* autopilot READ autopilot NOTIFY autopilotChanged)
Q_PROPERTY (bool showFirmware MEMBER _showFirmware CONSTANT)
#ifdef UNITTEST_BUILD
void showFirmware(void);
void showParameters(void);
void showSummary(void);
void showVehicleComponentSetup(const QUrl& url);
#endif
AutoPilotPlugin* autopilot(void);
signals:
void autopilotChanged(AutoPilotPlugin* autopilot);
private slots:
void _setActiveUAS(UASInterface* uas);
void _pluginReadyChanged(bool pluginReady);
private:
void _changeSetupWidget(QWidget* newWidget);
UASInterface* _uasCurrent; ///< Currently active UAS
bool _initComplete; ///< true: parameters are ready and ui has been setup
AutoPilotPlugin* _autoPilotPlugin;
QWidget* _currentSetupWidget;
Ui::SetupView* _ui;
UASInterface* _uasCurrent;
bool _initComplete; ///< true: parameters are ready and ui has been setup
QSharedPointer<AutoPilotPlugin> _autopilot; // Shared pointer to prevent shutdown ordering problems
AutoPilotPlugin* _readyAutopilot; // NULL if autopilot is not yet read
bool _showFirmware;
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @brief Setup View
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.3
import QtQuick.Controls 1.2
import QGroundControl.AutoPilotPlugin 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
Rectangle {
id: topLevel
color: palette.window
QGCPalette { id: palette; colorGroupEnabled: true }
ExclusiveGroup { id: setupButtonGroup }
QGCLabel { id: _textMeasure; text: "X"; visible: false }
readonly property real defaultTextHeight: _textMeasure.contentHeight
readonly property real defaultTextWidth: _textMeasure.contentWidth
readonly property real buttonWidth: defaultTextWidth * 15
property string messagePanelText: "missing message panel text"
readonly property string armedVehicleText: "This operation cannot be performed while vehicle is armed."
function showSummaryPanel()
{
if (controller.autopilot) {
panelLoader.source = "VehicleSummary.qml";
} else {
panelLoader.sourceComponent = disconnectedVehicleSummaryComponent
}
}
function showFirmwarePanel()
{
if (controller.showFirmware) {
if (controller.autopilot && controller.autopilot.armed) {
messagePanelText = armedVehicleText
panelLoader.sourceComponent = messagePanelComponent
} else {
panelLoader.source = "FirmwareUpgrade.qml";
}
}
}
function showParametersPanel()
{
panelLoader.source = "SetupParameterEditor.qml";
}
function showVehicleComponentPanel(setupSource)
{
if (controller.autopilot.armed) {
messagePanelText = armedVehicleText
panelLoader.sourceComponent = messagePanelComponent
} else {
panelLoader.source = setupSource
}
}
Connections {
target: controller
onAutopilotChanged: {
summaryButton.checked = true
showSummaryPanel()
}
}
Component.onCompleted: showSummaryPanel()
Component {
id: disconnectedVehicleSummaryComponent
Rectangle {
color: palette.windowShade
QGCLabel {
anchors.margins: defaultTextWidth * 2
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.pointSize: ScreenTools.mediumFontPointSize
text: "Welcome to QGroundControl. " +
"QGroundControl supports any <font color=\"orange\"><a href=\"http://www.qgroundcontrol.org/mavlink/start\">mavlink</a></font> enabled vehicle. " +
"If you are using the <font color=\"orange\"><a href=\"https://pixhawk.org/choice\">PX4 Flight Stack</a></font>, you also get full support for setting up and calibrating your vehicle. "+
"Otherwise you will only get support for flying a vehicle which has been setup and calibrated using other means. " +
"Use the Connect button above to connect to your vehicle."
onLinkActivated: Qt.openUrlExternally(link)
}
}
}
Component {
id: messagePanelComponent
Item {
QGCLabel {
anchors.fill: parent
wrapMode: Text.WordWrap
text: messagePanelText
}
}
}
Column {
id: buttonColumn
width: buttonWidth
SubMenuButton {
id: summaryButton
width: buttonWidth
imageResource: "VehicleSummaryIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
text: "SUMMARY"
onClicked: showSummaryPanel()
}
SubMenuButton {
id: firmwareButton
width: buttonWidth
imageResource: "FirmwareUpgradeIcon.png"
setupIndicator: false
exclusiveGroup: setupButtonGroup
visible: controller.showFirmware
text: "FIRMWARE"
onClicked: showFirmwarePanel()
}
Repeater {
model: controller.autopilot ? controller.autopilot.vehicleComponents : 0
SubMenuButton {
width: buttonWidth
imageResource: modelData.iconResource
setupComplete: modelData.setupComplete
exclusiveGroup: setupButtonGroup
text: modelData.name.toUpperCase()
onClicked: showVehicleComponentPanel(modelData.setupSource)
}
}
SubMenuButton {
width: buttonWidth
setupIndicator: false
exclusiveGroup: setupButtonGroup
visible: controller.autopilot
text: "PARAMETERS"
onClicked: showParametersPanel()
}
} // Column
Loader {
id: panelLoader
anchors.leftMargin: defaultTextWidth
anchors.rightMargin: defaultTextWidth
anchors.left: buttonColumn.right
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
property var autopilot: controller.autopilot
}
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SetupView</class>
<widget class="QWidget" name="SetupView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>946</width>
<height>821</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGCQuickWidget" name="buttonHolder">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>16777215</height>
</size>
</property>
<property name="resizeMode">
<enum>QGCQuickWidget::SizeRootObjectToView</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QGCQuickWidget</class>
<extends>QQuickWidget</extends>
<header>QGCQuickWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -92,16 +92,21 @@ void SetupViewTest::_clickThrough_test(void)
Q_ASSERT(setupView);
// Click through fixed buttons
setupView->firmwareButtonClicked();
qDebug() << "Showing firmware";
setupView->showFirmware();
QTest::qWait(1000);
setupView->parametersButtonClicked();
qDebug() << "Showing parameters";
setupView->showParameters();
QTest::qWait(1000);
setupView->summaryButtonClicked();
qDebug() << "Showing summary";
setupView->showSummary();
QTest::qWait(1000);
const QVariantList& components = autopilot->vehicleComponents();
foreach(QVariant varComponent, components) {
setupView->setupButtonClicked(varComponent);
VehicleComponent* component = qobject_cast<VehicleComponent*>(qvariant_cast<QObject *>(varComponent));
qDebug() << "Showing" << component->name();
setupView->showVehicleComponentSetup(component->setupSource());
}
// On MainWindow close we should get a message box telling the user to disconnect first. Disconnect will then pop
......
......@@ -48,7 +48,7 @@ class VehicleComponent : public QObject
Q_PROPERTY(bool setupComplete READ setupComplete STORED false NOTIFY setupCompleteChanged)
Q_PROPERTY(QString setupStateDescription READ setupStateDescription STORED false)
Q_PROPERTY(QString iconResource READ iconResource CONSTANT)
Q_PROPERTY(QWidget* setupWidget READ setupWidget STORED false)
Q_PROPERTY(QUrl setupSource READ setupSource CONSTANT)
Q_PROPERTY(QUrl summaryQmlSource READ summaryQmlSource CONSTANT);
Q_PROPERTY(QString prerequisiteSetup READ prerequisiteSetup)
......@@ -62,7 +62,7 @@ public:
virtual bool requiresSetup(void) const = 0;
virtual bool setupComplete(void) const = 0;
virtual QString setupStateDescription(void) const = 0;
virtual QWidget* setupWidget(void) const = 0;
virtual QUrl setupSource(void) const = 0;
virtual QStringList paramFilterList(void) const = 0;
virtual QUrl summaryQmlSource(void) const = 0;
virtual QString prerequisiteSetup(void) const = 0;
......
......@@ -58,11 +58,13 @@ Rectangle {
QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
color: autopilot.setupComplete ? qgcPal.text : "red"
font.pointSize: autopilot.setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20)
text: autopilot.setupComplete ?
"Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." :
"WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left."
color: setupComplete ? qgcPal.text : "red"
font.pointSize: setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20)
text: setupComplete ?
"Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." :
"WARNING: Your vehicle requires setup prior to flight. Please resolve the items marked in red using the menu on the left."
property bool setupComplete: autopilot && autopilot.setupComplete
}
Item {
......@@ -76,7 +78,7 @@ Rectangle {
spacing: 10
Repeater {
model: autopilot.vehicleComponents
model: autopilot ? autopilot.vehicleComponents : 0
// Outer summary item rectangle
Rectangle {
......
......@@ -444,8 +444,6 @@ signals:
void dropRateChanged(int systemId, float receiveDrop);
/** @brief Robot mode has changed */
void modeChanged(int sysId, QString status, QString description);
/** @brief Robot armed state has changed */
void armingChanged(int sysId, QString armingState);
/** @brief A command has been issued **/
void commandSent(int command);
/** @brief The robot is connecting **/
......
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