Commit fb8a050b authored by Don Gagne's avatar Don Gagne

SetupView converted to Qml only

parent 63e37c4a
...@@ -546,9 +546,6 @@ INCLUDEPATH += \ ...@@ -546,9 +546,6 @@ INCLUDEPATH += \
src/VehicleSetup \ src/VehicleSetup \
src/AutoPilotPlugins/PX4 \ src/AutoPilotPlugins/PX4 \
FORMS += \
src/VehicleSetup/SetupView.ui \
HEADERS+= \ HEADERS+= \
src/AutoPilotPlugins/AutoPilotPlugin.h \ src/AutoPilotPlugins/AutoPilotPlugin.h \
src/AutoPilotPlugins/AutoPilotPluginManager.h \ src/AutoPilotPlugins/AutoPilotPluginManager.h \
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file> <file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file>
<file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.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="SetupViewButtonsConnected.qml">src/VehicleSetup/SetupViewButtonsConnected.qml</file>
<file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file> <file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file>
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "SetupView.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "MainWindow.h" #include "MainWindow.h"
...@@ -40,6 +39,8 @@ AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) : ...@@ -40,6 +39,8 @@ AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) :
Q_ASSERT(_uas); Q_ASSERT(_uas);
connect(_uas, &UASInterface::disconnected, this, &AutoPilotPlugin::_uasDisconnected); connect(_uas, &UASInterface::disconnected, this, &AutoPilotPlugin::_uasDisconnected);
connect(_uas, &UASInterface::armingChanged, this, &AutoPilotPlugin::armedChanged);
connect(this, &AutoPilotPlugin::pluginReadyChanged, this, &AutoPilotPlugin::_pluginReadyChanged); connect(this, &AutoPilotPlugin::pluginReadyChanged, this, &AutoPilotPlugin::_pluginReadyChanged);
} }
...@@ -66,12 +67,6 @@ void AutoPilotPlugin::_pluginReadyChanged(bool pluginReady) ...@@ -66,12 +67,6 @@ void AutoPilotPlugin::_pluginReadyChanged(bool pluginReady)
Q_ASSERT(mainWindow); Q_ASSERT(mainWindow);
mainWindow->getMainToolBar()->onSetupView(); mainWindow->getMainToolBar()->onSetupView();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); 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) ...@@ -172,3 +167,8 @@ void AutoPilotPlugin::readParametersFromStream(QTextStream &stream)
{ {
_getParameterLoader()->readParametersFromStream(stream); _getParameterLoader()->readParametersFromStream(stream);
} }
bool AutoPilotPlugin::armed(void)
{
return _uas->isArmed();
}
...@@ -61,6 +61,8 @@ public: ...@@ -61,6 +61,8 @@ public:
/// false: One or more vehicle components require setup /// false: One or more vehicle components require setup
Q_PROPERTY(bool setupComplete READ setupComplete NOTIFY setupCompleteChanged) 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 /// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(void); Q_INVOKABLE void refreshAllParameters(void);
...@@ -111,6 +113,7 @@ public: ...@@ -111,6 +113,7 @@ public:
// Property accessors // Property accessors
bool pluginReady(void) { return _pluginReady; } bool pluginReady(void) { return _pluginReady; }
bool setupComplete(void); bool setupComplete(void);
bool armed(void);
UASInterface* uas(void) { return _uas; } UASInterface* uas(void) { return _uas; }
...@@ -118,6 +121,7 @@ signals: ...@@ -118,6 +121,7 @@ signals:
void pluginReadyChanged(bool pluginReady); void pluginReadyChanged(bool pluginReady);
void setupCompleteChanged(bool setupComplete); void setupCompleteChanged(bool setupComplete);
void parameterListProgress(float value); void parameterListProgress(float value);
void armedChanged(bool armed);
protected: protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin /// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
......
...@@ -171,16 +171,9 @@ QStringList AirframeComponent::paramFilterList(void) const ...@@ -171,16 +171,9 @@ QStringList AirframeComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* AirframeComponent::setupWidget(void) const QUrl AirframeComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml"));
return holder;
} }
QUrl AirframeComponent::summaryQmlSource(void) const QUrl AirframeComponent::summaryQmlSource(void) const
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const; virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const; virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const; virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const; virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const; virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const; virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
......
...@@ -104,16 +104,9 @@ QStringList FlightModesComponent::paramFilterList(void) const ...@@ -104,16 +104,9 @@ QStringList FlightModesComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* FlightModesComponent::setupWidget(void) const QUrl FlightModesComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/FlightModesComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/FlightModesComponent.qml"));
return holder;
} }
QUrl FlightModesComponent::summaryQmlSource(void) const QUrl FlightModesComponent::summaryQmlSource(void) const
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const; virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const; virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const; virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const; virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const; virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const; virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
......
...@@ -86,13 +86,9 @@ QStringList PowerComponent::paramFilterList(void) const ...@@ -86,13 +86,9 @@ QStringList PowerComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* PowerComponent::setupWidget(void) const QUrl PowerComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/PowerComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/PowerComponent.qml"));
return holder;
} }
QUrl PowerComponent::summaryQmlSource(void) const QUrl PowerComponent::summaryQmlSource(void) const
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup (void) const; virtual bool requiresSetup (void) const;
virtual bool setupComplete (void) const; virtual bool setupComplete (void) const;
virtual QString setupStateDescription (void) const; virtual QString setupStateDescription (void) const;
virtual QWidget* setupWidget (void) const; virtual QUrl setupSource (void) const;
virtual QStringList paramFilterList (void) const; virtual QStringList paramFilterList (void) const;
virtual QUrl summaryQmlSource (void) const; virtual QUrl summaryQmlSource (void) const;
virtual QString prerequisiteSetup (void) const; virtual QString prerequisiteSetup (void) const;
......
...@@ -138,13 +138,9 @@ QStringList RadioComponent::paramFilterList(void) const ...@@ -138,13 +138,9 @@ QStringList RadioComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* RadioComponent::setupWidget(void) const QUrl RadioComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/RadioComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/RadioComponent.qml"));
return holder;
} }
QUrl RadioComponent::summaryQmlSource(void) const QUrl RadioComponent::summaryQmlSource(void) const
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
virtual bool requiresSetup(void) const; virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const; virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const; virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const; virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const; virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const; virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
......
...@@ -84,16 +84,9 @@ QStringList SafetyComponent::paramFilterList(void) const ...@@ -84,16 +84,9 @@ QStringList SafetyComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* SafetyComponent::setupWidget(void) const QUrl SafetyComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml"));
return holder;
} }
QUrl SafetyComponent::summaryQmlSource(void) const QUrl SafetyComponent::summaryQmlSource(void) const
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
virtual bool requiresSetup(void) const; virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const; virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const; virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const; virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const; virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const; virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
......
...@@ -105,15 +105,9 @@ QStringList SensorsComponent::paramFilterList(void) const ...@@ -105,15 +105,9 @@ QStringList SensorsComponent::paramFilterList(void) const
return list; return list;
} }
QWidget* SensorsComponent::setupWidget(void) const QUrl SensorsComponent::setupSource(void) const
{ {
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); return QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml");
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml"));
return holder;
} }
QUrl SensorsComponent::summaryQmlSource(void) const QUrl SensorsComponent::summaryQmlSource(void) const
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual bool requiresSetup(void) const; virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const; virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const; virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const; virtual QUrl setupSource(void) const;
virtual QStringList paramFilterList(void) const; virtual QStringList paramFilterList(void) const;
virtual QUrl summaryQmlSource(void) const; virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const; virtual QString prerequisiteSetup(void) const;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "FactSystem.h" #include "FactSystem.h"
#include "UASManager.h" #include "UASManager.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include "VehicleComponent.h"
#include "FactPanelController.h" #include "FactPanelController.h"
#include <QtQml> #include <QtQml>
...@@ -42,7 +41,6 @@ FactSystem::FactSystem(QObject* parent) : ...@@ -42,7 +41,6 @@ FactSystem::FactSystem(QObject* parent) :
qmlRegisterType<Fact>(_factSystemQmlUri, 1, 0, "Fact"); qmlRegisterType<Fact>(_factSystemQmlUri, 1, 0, "Fact");
qmlRegisterType<FactPanelController>(_factSystemQmlUri, 1, 0, "FactPanelController"); qmlRegisterType<FactPanelController>(_factSystemQmlUri, 1, 0, "FactPanelController");
qmlRegisterUncreatableType<VehicleComponent>(_factSystemQmlUri, 1, 0, "VehicleComponent", "Can only reference, cannot create");
} }
FactSystem::~FactSystem() FactSystem::~FactSystem()
......
...@@ -67,6 +67,11 @@ ...@@ -67,6 +67,11 @@
#include "SensorsComponentController.h" #include "SensorsComponentController.h"
#include "PowerComponentController.h" #include "PowerComponentController.h"
#include "RadioComponentController.h" #include "RadioComponentController.h"
#ifndef __android__
#include "FirmwareUpgradeController.h"
#endif
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
#include "ScreenTools.h" #include "ScreenTools.h"
#include "MavManager.h" #include "MavManager.h"
...@@ -318,6 +323,9 @@ void QGCApplication::_initCommon(void) ...@@ -318,6 +323,9 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<QGCPalette>("QGroundControl.Palette", 1, 0, "QGCPalette"); 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<ViewWidgetController>("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<CustomCommandWidgetController>("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController"); qmlRegisterType<CustomCommandWidgetController>("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
...@@ -326,7 +334,10 @@ void QGCApplication::_initCommon(void) ...@@ -326,7 +334,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<SensorsComponentController>("QGroundControl.Controllers", 1, 0, "SensorsComponentController"); qmlRegisterType<SensorsComponentController>("QGroundControl.Controllers", 1, 0, "SensorsComponentController");
qmlRegisterType<PowerComponentController>("QGroundControl.Controllers", 1, 0, "PowerComponentController"); qmlRegisterType<PowerComponentController>("QGroundControl.Controllers", 1, 0, "PowerComponentController");
qmlRegisterType<RadioComponentController>("QGroundControl.Controllers", 1, 0, "RadioComponentController"); qmlRegisterType<RadioComponentController>("QGroundControl.Controllers", 1, 0, "RadioComponentController");
#ifndef __android__
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
#endif
//-- Create QML Singleton Interfaces //-- Create QML Singleton Interfaces
qmlRegisterSingletonType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory); qmlRegisterSingletonType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory); qmlRegisterSingletonType<MavManager>("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory);
...@@ -372,7 +383,7 @@ bool QGCApplication::_initForNormalAppBoot(void) ...@@ -372,7 +383,7 @@ bool QGCApplication::_initForNormalAppBoot(void)
splashScreen->finish(mainWindow); splashScreen->finish(mainWindow);
mainWindow->splashScreenFinished(); 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); connect(this, &QGCApplication::checkForLostLogFiles, MAVLinkProtocol::instance(), &MAVLinkProtocol::checkForLostLogFiles);
emit checkForLostLogFiles(); emit checkForLostLogFiles();
......
...@@ -53,7 +53,12 @@ void QGCQmlWidgetHolder::setContextPropertyObject(const QString& name, QObject* ...@@ -53,7 +53,12 @@ void QGCQmlWidgetHolder::setContextPropertyObject(const QString& name, QObject*
_ui.qmlWidget->rootContext()->setContextProperty(name, object); _ui.qmlWidget->rootContext()->setContextProperty(name, object);
} }
QQmlContext* QGCQmlWidgetHolder::getRootContext() QQmlContext* QGCQmlWidgetHolder::getRootContext(void)
{ {
return _ui.qmlWidget->rootContext(); return _ui.qmlWidget->rootContext();
} }
QQuickItem* QGCQmlWidgetHolder::getRootObject(void)
{
return _ui.qmlWidget->rootObject();
}
...@@ -50,8 +50,11 @@ public: ...@@ -50,8 +50,11 @@ public:
void setAutoPilot(AutoPilotPlugin* autoPilot); void setAutoPilot(AutoPilotPlugin* autoPilot);
/// Get Root Context /// 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. /// 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 /// @return true: source loaded, false: source not loaded, errors occured
bool setSource(const QUrl& qmlUrl); bool setSource(const QUrl& qmlUrl);
......
...@@ -43,26 +43,20 @@ ...@@ -43,26 +43,20 @@
#include <QDebug> #include <QDebug>
SetupView::SetupView(QWidget* parent) : SetupView::SetupView(QWidget* parent) :
QWidget(parent), QGCQmlWidgetHolder(parent),
_uasCurrent(NULL), _uasCurrent(NULL),
_initComplete(false), _initComplete(false)
_autoPilotPlugin(NULL),
_currentSetupWidget(NULL),
_ui(new Ui::SetupView)
{ {
_ui->setupUi(this); #ifdef __android__
_showFirmware = false;
bool fSucceeded = connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(_setActiveUAS(UASInterface*))); #else
Q_UNUSED(fSucceeded); _showFirmware = true;
Q_ASSERT(fSucceeded);
#ifndef __android__
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
#endif #endif
_ui->buttonHolder->rootContext()->setContextProperty("controller", this); connect(UASManager::instance(), &UASManager::activeUASSet, this, &SetupView::_setActiveUAS);
_ui->buttonHolder->setAutoPilot(NULL);
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml")); getRootContext()->setContextProperty("controller", this);
setSource(QUrl::fromUserInput("qrc:/qml/SetupView.qml"));
_setActiveUAS(UASManager::instance()->getActiveUAS()); _setActiveUAS(UASManager::instance()->getActiveUAS());
} }
...@@ -75,8 +69,7 @@ SetupView::~SetupView() ...@@ -75,8 +69,7 @@ SetupView::~SetupView()
void SetupView::_setActiveUAS(UASInterface* uas) void SetupView::_setActiveUAS(UASInterface* uas)
{ {
if (_uasCurrent) { if (_uasCurrent) {
Q_ASSERT(_autoPilotPlugin); disconnect(_autopilot.data(), &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
disconnect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
} }
_pluginReadyChanged(false); _pluginReadyChanged(false);
...@@ -84,98 +77,69 @@ void SetupView::_setActiveUAS(UASInterface* uas) ...@@ -84,98 +77,69 @@ void SetupView::_setActiveUAS(UASInterface* uas)
_uasCurrent = uas; _uasCurrent = uas;
if (_uasCurrent) { if (_uasCurrent) {
_autoPilotPlugin = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uasCurrent).data(); _autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uasCurrent);
_pluginReadyChanged(_autoPilotPlugin->pluginReady()); if (_autopilot.data()->pluginReady()) {
connect(_autoPilotPlugin, &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged); _pluginReadyChanged(_autopilot.data()->pluginReady());
}
connect(_autopilot.data(), &AutoPilotPlugin::pluginReadyChanged, this, &SetupView::_pluginReadyChanged);
} }
} }
void SetupView::_pluginReadyChanged(bool pluginReady) void SetupView::_pluginReadyChanged(bool pluginReady)
{ {
if (pluginReady) { if (pluginReady) {
_ui->buttonHolder->setAutoPilot(_autoPilotPlugin); _readyAutopilot = _autopilot.data();
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsConnected.qml")); emit autopilotChanged(_readyAutopilot);
summaryButtonClicked();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("summaryButton");
Q_ASSERT(button);
button->setProperty("checked", true);
} else { } else {
_ui->buttonHolder->setSource(QUrl::fromUserInput("qrc:/qml/SetupViewButtonsDisconnected.qml")); _readyAutopilot = NULL;
_ui->buttonHolder->setAutoPilot(NULL); emit autopilotChanged(NULL);
firmwareButtonClicked(); _autopilot.clear();
QObject* button = _ui->buttonHolder->rootObject()->findChild<QObject*>("firmwareButton");
Q_ASSERT(button);
button->setProperty("checked", true);
} }
} }
void SetupView::_changeSetupWidget(QWidget* newWidget) #ifdef UNITTEST_BUILD
{ void SetupView::showFirmware(void)
if (_currentSetupWidget) {
delete _currentSetupWidget;
}
_currentSetupWidget = newWidget;
_ui->horizontalLayout->addWidget(newWidget);
}
void SetupView::firmwareButtonClicked(void)
{ {
#ifndef __android__ #ifndef __android__
//FIXME: Hack out for android for now QVariant returnedValue;
if (_uasCurrent && _uasCurrent->isArmed()) { bool success = QMetaObject::invokeMethod(getRootObject(),
QGCMessageBox::warning("Setup", "Firmware Update cannot be performed while vehicle is armed."); "showFirmwarePanel",
return; Q_RETURN_ARG(QVariant, returnedValue));
} Q_ASSERT(success);
QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder;
Q_CHECK_PTR(setup);
setup->setSource(QUrl::fromUserInput("qrc:/qml/FirmwareUpgrade.qml"));
_changeSetupWidget(setup);
#endif #endif
} }
void SetupView::parametersButtonClicked(void) void SetupView::showParameters(void)
{ {
QGCQmlWidgetHolder* setup = new QGCQmlWidgetHolder; QVariant returnedValue;
Q_CHECK_PTR(setup); bool success = QMetaObject::invokeMethod(getRootObject(),
"showParametersPanel",
Q_ASSERT(_autoPilotPlugin); Q_RETURN_ARG(QVariant, returnedValue));
setup->setAutoPilot(_autoPilotPlugin); Q_ASSERT(success);
setup->setSource(QUrl::fromUserInput("qrc:/qml/SetupParameterEditor.qml"));
_changeSetupWidget(setup);
} }
void SetupView::summaryButtonClicked(void) void SetupView::showSummary(void)
{ {
Q_ASSERT(_autoPilotPlugin); QVariant returnedValue;
bool success = QMetaObject::invokeMethod(getRootObject(),
QGCQmlWidgetHolder* summary = new QGCQmlWidgetHolder; "showSummaryPanel",
Q_CHECK_PTR(summary); Q_RETURN_ARG(QVariant, returnedValue));
Q_ASSERT(success);
summary->setAutoPilot(_autoPilotPlugin);
summary->setSource(QUrl::fromUserInput("qrc:/qml/VehicleSummary.qml"));
_changeSetupWidget(summary);
} }
void SetupView::setupButtonClicked(const QVariant& component) void SetupView::showVehicleComponentSetup(const QUrl& url)
{ {
if (_uasCurrent->isArmed()) { QVariant returnedValue;
QGCMessageBox::warning("Setup", "Setup cannot be performed while vehicle is armed."); QVariant varSource = url;
return; bool success = QMetaObject::invokeMethod(getRootObject(),
} "showVehicleComponentPanel",
Q_RETURN_ARG(QVariant, returnedValue),
VehicleComponent* vehicle = qobject_cast<VehicleComponent*>(component.value<QObject*>()); Q_ARG(QVariant, varSource));
Q_ASSERT(vehicle); Q_ASSERT(success);
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());
} }
#endif
AutoPilotPlugin* SetupView::autopilot(void)
{
return _readyAutopilot;
}
\ No newline at end of file
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "UASInterface.h" #include "UASInterface.h"
#include "VehicleComponent.h" #include "VehicleComponent.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "QGCQmlWidgetHolder.h"
#include <QWidget> #include <QWidget>
...@@ -34,11 +35,7 @@ ...@@ -34,11 +35,7 @@
/// @brief This class is used to display the UI for the VehicleComponent objects. /// @brief This class is used to display the UI for the VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
namespace Ui { class SetupView : public QGCQmlWidgetHolder
class SetupView;
}
class SetupView : public QWidget
{ {
Q_OBJECT Q_OBJECT
...@@ -46,24 +43,31 @@ public: ...@@ -46,24 +43,31 @@ public:
explicit SetupView(QWidget* parent = 0); explicit SetupView(QWidget* parent = 0);
~SetupView(); ~SetupView();
Q_INVOKABLE void firmwareButtonClicked(void); Q_PROPERTY(AutoPilotPlugin* autopilot READ autopilot NOTIFY autopilotChanged)
Q_INVOKABLE void parametersButtonClicked(void); Q_PROPERTY (bool showFirmware MEMBER _showFirmware CONSTANT)
Q_INVOKABLE void summaryButtonClicked(void);
Q_INVOKABLE void setupButtonClicked(const QVariant& component); #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: private slots:
void _setActiveUAS(UASInterface* uas); void _setActiveUAS(UASInterface* uas);
void _pluginReadyChanged(bool pluginReady); void _pluginReadyChanged(bool pluginReady);
private: private:
void _changeSetupWidget(QWidget* newWidget); UASInterface* _uasCurrent;
bool _initComplete; ///< true: parameters are ready and ui has been setup
UASInterface* _uasCurrent; ///< Currently active UAS QSharedPointer<AutoPilotPlugin> _autopilot; // Shared pointer to prevent shutdown ordering problems
bool _initComplete; ///< true: parameters are ready and ui has been setup AutoPilotPlugin* _readyAutopilot; // NULL if autopilot is not yet read
AutoPilotPlugin* _autoPilotPlugin; bool _showFirmware;
QWidget* _currentSetupWidget;
Ui::SetupView* _ui;
}; };
#endif #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) ...@@ -92,16 +92,21 @@ void SetupViewTest::_clickThrough_test(void)
Q_ASSERT(setupView); Q_ASSERT(setupView);
// Click through fixed buttons // Click through fixed buttons
setupView->firmwareButtonClicked(); qDebug() << "Showing firmware";
setupView->showFirmware();
QTest::qWait(1000); QTest::qWait(1000);
setupView->parametersButtonClicked(); qDebug() << "Showing parameters";
setupView->showParameters();
QTest::qWait(1000); QTest::qWait(1000);
setupView->summaryButtonClicked(); qDebug() << "Showing summary";
setupView->showSummary();
QTest::qWait(1000); QTest::qWait(1000);
const QVariantList& components = autopilot->vehicleComponents(); const QVariantList& components = autopilot->vehicleComponents();
foreach(QVariant varComponent, components) { 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 // 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 ...@@ -48,7 +48,7 @@ class VehicleComponent : public QObject
Q_PROPERTY(bool setupComplete READ setupComplete STORED false NOTIFY setupCompleteChanged) Q_PROPERTY(bool setupComplete READ setupComplete STORED false NOTIFY setupCompleteChanged)
Q_PROPERTY(QString setupStateDescription READ setupStateDescription STORED false) Q_PROPERTY(QString setupStateDescription READ setupStateDescription STORED false)
Q_PROPERTY(QString iconResource READ iconResource CONSTANT) 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(QUrl summaryQmlSource READ summaryQmlSource CONSTANT);
Q_PROPERTY(QString prerequisiteSetup READ prerequisiteSetup) Q_PROPERTY(QString prerequisiteSetup READ prerequisiteSetup)
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
virtual bool requiresSetup(void) const = 0; virtual bool requiresSetup(void) const = 0;
virtual bool setupComplete(void) const = 0; virtual bool setupComplete(void) const = 0;
virtual QString setupStateDescription(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 QStringList paramFilterList(void) const = 0;
virtual QUrl summaryQmlSource(void) const = 0; virtual QUrl summaryQmlSource(void) const = 0;
virtual QString prerequisiteSetup(void) const = 0; virtual QString prerequisiteSetup(void) const = 0;
......
...@@ -58,11 +58,13 @@ Rectangle { ...@@ -58,11 +58,13 @@ Rectangle {
QGCLabel { QGCLabel {
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
color: autopilot.setupComplete ? qgcPal.text : "red" color: setupComplete ? qgcPal.text : "red"
font.pointSize: autopilot.setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20) font.pointSize: setupComplete ? ScreenTools.defaultFontPointSize : ScreenTools.fontPointFactor * (20)
text: autopilot.setupComplete ? text: setupComplete ?
"Below you will find a summary of the settings for your vehicle. To the left are the setup menus for each component." : "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." "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 { Item {
...@@ -76,7 +78,7 @@ Rectangle { ...@@ -76,7 +78,7 @@ Rectangle {
spacing: 10 spacing: 10
Repeater { Repeater {
model: autopilot.vehicleComponents model: autopilot ? autopilot.vehicleComponents : 0
// Outer summary item rectangle // Outer summary item rectangle
Rectangle { Rectangle {
......
...@@ -444,8 +444,6 @@ signals: ...@@ -444,8 +444,6 @@ signals:
void dropRateChanged(int systemId, float receiveDrop); void dropRateChanged(int systemId, float receiveDrop);
/** @brief Robot mode has changed */ /** @brief Robot mode has changed */
void modeChanged(int sysId, QString status, QString description); 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 **/ /** @brief A command has been issued **/
void commandSent(int command); void commandSent(int command);
/** @brief The robot is connecting **/ /** @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