Commit 92bf4bd5 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #4259 from dogmaphobic/pluginSupport

Plugin support
parents c54482ac 33297c60
include($$PWD/libs/qtandroidserialport/src/qtandroidserialport.pri)
message("Adding Serial Java Classes")
QT += androidextras
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
OTHER_FILES += \
$$PWD/android/AndroidManifest.xml \
$$PWD/android/res/xml/device_filter.xml \
$$PWD/android/src/com/hoho/android/usbserial/driver/CdcAcmSerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/CommonUsbSerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/Cp2102SerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/FtdiSerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/ProlificSerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/UsbId.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/UsbSerialDriver.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/UsbSerialProber.java \
$$PWD/android/src/com/hoho/android/usbserial/driver/UsbSerialRuntimeException.java \
$$PWD/android/src/org/qgroundcontrol/qgchelper/UsbDeviceJNI.java \
$$PWD/android/src/org/qgroundcontrol/qgchelper/UsbIoManager.java
DISTFILES += \
$$PWD/android/gradle/wrapper/gradle-wrapper.jar \
$$PWD/android/gradlew \
$$PWD/android/res/values/libs.xml \
$$PWD/android/build.gradle \
$$PWD/android/gradle/wrapper/gradle-wrapper.properties \
$$PWD/android/gradlew.bat
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
/**
* @brief QGC Main Application Interface (used for Dynamic Loaded plugins)
* @author Gus Grubba <mavlink@grubba.com>
*/
#pragma once
class IQGCApplication
{
public:
IQGCApplication() {}
virtual ~IQGCApplication() {}
//-- Not yet implemented
};
#pragma once
#include <QObject>
/// @file
/// @brief Core Plugin Interface for QGroundControl
/// @author Gus Grubba <mavlink@grubba.com>
// Work In Progress
class QGCApplication;
class IQGCApplication;
class IQGCOptions;
class IQGCQMLSource;
class IQGCCorePlugin
{
public:
IQGCCorePlugin(QObject*) {}
virtual ~IQGCCorePlugin() {}
#if defined (QGC_DYNAMIC_PLUGIN)
virtual bool init (IQGCApplication* pApp) = 0;
#else
virtual bool init (QGCApplication* pApp) = 0;
#endif
virtual IQGCOptions* uiOptions () { return NULL; }
virtual IQGCQMLSource* settingsQML () { return NULL; }
};
#if defined (QGC_DYNAMIC_PLUGIN)
Q_DECLARE_INTERFACE(IQGCCorePlugin, "org.qgroundcontrol.qgccoreplugin")
#endif
#pragma once
/// @file
/// @brief Core Plugin Interface for QGroundControl
/// @author Gus Grubba <mavlink@grubba.com>
class IQGCOptions
{
public:
IQGCOptions() {}
virtual ~IQGCOptions() {}
//! Should QGC colapse its settings menu into one single menu (Settings and Vehicle Setup)?
/*!
@return true if QGC should consolidate both menus into one.
*/
virtual bool colapseSettings () { return false; }
//! Should QGC use Maps as its default main view?
/*!
@return true if QGC should use Maps by default or false to show Video by default.
*/
virtual bool mainViewIsMap () { return true; }
//! Should QGC use virtual Joysticks?
/*!
@return false to disable Virtual Joysticks.
*/
virtual bool enableVirtualJoystick () { return true; }
//! Should QGC allow setting auto-connect options?
/*!
@return false to disable auto-connect options.
*/
virtual bool enableAutoConnectOptions () { return true; }
//! Should QGC allow setting video source options?
/*!
@return false to disable video source options.
*/
virtual bool enableVideoSourceOptions () { return true; }
//! Does your plugin defines its on video source?
/*!
@return true to define your own video source.
*/
virtual bool definesVideo () { return false; }
//! UDP port to use for (RTP) video source.
/*!
@return UDP Port to use. Return 0 to disable UDP RTP.
*/
virtual uint16_t videoUDPPort () { return 0; }
//! RTSP URL to use for video source.
/*!
@return RTSP url to use. Return "" to disable RTSP.
*/
virtual QString videoRSTPUrl () { return QString(); }
};
#pragma once
#include <QString>
/// @file
/// @brief Core Plugin Interface for QGroundControl
/// @author Gus Grubba <mavlink@grubba.com>
class IQGCQMLSource
{
public:
IQGCQMLSource() {}
virtual ~IQGCQMLSource() {}
virtual QString pageUrl () { return QString(); }
virtual QString pageTitle () { return QString(); }
virtual QString pageIconUrl () { return QString(); }
};
<RCC>
<qresource prefix="/unittest">
<file alias="APMArduCopterMockLink.params">src/comm/APMArduCopterMockLink.params</file>
<file alias="APMArduPlaneMockLink.params">src/comm/APMArduPlaneMockLink.params</file>
<file alias="APMArduSubMockLink.params">src/comm/APMArduSubMockLink.params</file>
</qresource>
<qresource prefix="/qml">
<file alias="APMAirframeComponent.qml">src/AutoPilotPlugins/APM/APMAirframeComponent.qml</file>
<file alias="APMAirframeComponentSummary.qml">src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml</file>
<file alias="APMCameraComponent.qml">src/AutoPilotPlugins/APM/APMCameraComponent.qml</file>
<file alias="APMCameraComponentSummary.qml">src/AutoPilotPlugins/APM/APMCameraComponentSummary.qml</file>
<file alias="APMFlightModesComponent.qml">src/AutoPilotPlugins/APM/APMFlightModesComponent.qml</file>
<file alias="APMFlightModesComponentSummary.qml">src/AutoPilotPlugins/APM/APMFlightModesComponentSummary.qml</file>
<file alias="APMLightsComponent.qml">src/AutoPilotPlugins/APM/APMLightsComponent.qml</file>
<file alias="APMLightsComponentSummary.qml">src/AutoPilotPlugins/APM/APMLightsComponentSummary.qml</file>
<file alias="APMNotSupported.qml">src/AutoPilotPlugins/APM/APMNotSupported.qml</file>
<file alias="APMPowerComponent.qml">src/AutoPilotPlugins/APM/APMPowerComponent.qml</file>
<file alias="APMPowerComponentSummary.qml">src/AutoPilotPlugins/APM/APMPowerComponentSummary.qml</file>
<file alias="APMRadioComponentSummary.qml">src/AutoPilotPlugins/APM/APMRadioComponentSummary.qml</file>
<file alias="APMSafetyComponentCopter.qml">src/AutoPilotPlugins/APM/APMSafetyComponentCopter.qml</file>
<file alias="APMSafetyComponentPlane.qml">src/AutoPilotPlugins/APM/APMSafetyComponentPlane.qml</file>
<file alias="APMSafetyComponentRover.qml">src/AutoPilotPlugins/APM/APMSafetyComponentRover.qml</file>
<file alias="APMSafetyComponentSub.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSub.qml</file>
<file alias="APMSafetyComponentSummaryCopter.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummaryCopter.qml</file>
<file alias="APMSafetyComponentSummaryPlane.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummaryPlane.qml</file>
<file alias="APMSafetyComponentSummaryRover.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummaryRover.qml</file>
<file alias="APMSafetyComponentSummarySub.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummarySub.qml</file>
<file alias="APMSensorsComponent.qml">src/AutoPilotPlugins/APM/APMSensorsComponent.qml</file>
<file alias="APMSensorsComponentSummary.qml">src/AutoPilotPlugins/APM/APMSensorsComponentSummary.qml</file>
<file alias="APMTuningComponentCopter.qml">src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APM/MavCmdInfoCommon.json">src/FirmwarePlugin/APM/MavCmdInfoCommon.json</file>
<file alias="APM/MavCmdInfoFixedWing.json">src/FirmwarePlugin/APM/MavCmdInfoFixedWing.json</file>
<file alias="APM/MavCmdInfoMultiRotor.json">src/FirmwarePlugin/APM/MavCmdInfoMultiRotor.json</file>
<file alias="APM/MavCmdInfoRover.json">src/FirmwarePlugin/APM/MavCmdInfoRover.json</file>
<file alias="APM/MavCmdInfoSub.json">src/FirmwarePlugin/APM/MavCmdInfoSub.json</file>
<file alias="APM/MavCmdInfoVTOL.json">src/FirmwarePlugin/APM/MavCmdInfoVTOL.json</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/unittest">
<file alias="PX4MockLink.params">src/comm/PX4MockLink.params</file>
</qresource>
<qresource prefix="/qml">
<file alias="PX4AdvancedFlightModes.qml">src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml</file>
<file alias="PX4FlightModes.qml">src/AutoPilotPlugins/PX4/PX4FlightModes.qml</file>
<file alias="PX4FlowSensor.qml">src/VehicleSetup/PX4FlowSensor.qml</file>
<file alias="PX4RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/PX4RadioComponentSummary.qml</file>
<file alias="PX4SimpleFlightModes.qml">src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml</file>
<file alias="PX4TuningComponentCopter.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml</file>
<file alias="PX4TuningComponentPlane.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml</file>
<file alias="PX4TuningComponentVTOL.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="PX4/MavCmdInfoCommon.json">src/FirmwarePlugin/PX4/MavCmdInfoCommon.json</file>
<file alias="PX4/MavCmdInfoFixedWing.json">src/FirmwarePlugin/PX4/MavCmdInfoFixedWing.json</file>
<file alias="PX4/MavCmdInfoMultiRotor.json">src/FirmwarePlugin/PX4/MavCmdInfoMultiRotor.json</file>
<file alias="PX4/MavCmdInfoRover.json">src/FirmwarePlugin/PX4/MavCmdInfoRover.json</file>
<file alias="PX4/MavCmdInfoSub.json">src/FirmwarePlugin/PX4/MavCmdInfoSub.json</file>
<file alias="PX4/MavCmdInfoVTOL.json">src/FirmwarePlugin/PX4/MavCmdInfoVTOL.json</file>
</qresource>
</RCC>
This diff is collapsed.
This diff is collapsed.
......@@ -11,8 +11,8 @@ QGCCheckBox {
property variant checkedValue: 1
property variant uncheckedValue: 0
partiallyCheckedEnabled: fact.value != checkedValue && fact.value != uncheckedValue
checkedState: fact.value == checkedValue ? Qt.Checked : (fact.value == uncheckedValue ? Qt.Unchecked : Qt.PartiallyChecked)
partiallyCheckedEnabled: fact ? fact.value !== checkedValue && fact.value !== uncheckedValue : false
checkedState: fact ? fact.value === checkedValue ? Qt.Checked : (fact.value === uncheckedValue ? Qt.Unchecked : Qt.PartiallyChecked) : false
text: qsTr("Label")
......
......@@ -83,6 +83,10 @@
#include "QGCMapPolygon.h"
#include "ParameterManager.h"
#if defined(QGC_CUSTOM_BUILD)
#include CUSTOMHEADER
#endif
#ifndef __ios__
#include "SerialLink.h"
#endif
......@@ -184,10 +188,15 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
, _toolbox(NULL)
, _bluetoothAvailable(false)
, _lastKnownHomePosition(37.803784, -122.462276, 0.0)
, _pQGCOptions(NULL)
, _pCorePlugin(NULL)
{
Q_ASSERT(_app == NULL);
_app = this;
//-- Scan and load plugins
_scanAndLoadPlugins();
// This prevents usage of QQuickWidget to fail since it doesn't support native widget siblings
#ifndef __android__
setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
......@@ -349,6 +358,9 @@ QGCApplication::~QGCApplication()
#endif
shutdownVideoStreaming();
delete _toolbox;
if(_pCorePlugin) {
delete _pCorePlugin;
}
}
void QGCApplication::_initCommon(void)
......@@ -445,6 +457,13 @@ bool QGCApplication::_initForNormalAppBoot(void)
settings.sync();
//-- Initialize Core Plugin (if any)
if(_pCorePlugin) {
if(!_pCorePlugin->init(this)) {
return false;
}
}
return true;
}
......@@ -564,7 +583,7 @@ void QGCApplication::setStyle(bool styleIsDark)
emit styleChanged(_styleIsDark);
}
void QGCApplication::_loadCurrentStyle(void)
void QGCApplication::_loadCurrentStyle()
{
#ifndef __mobile__
bool success = true;
......@@ -626,7 +645,7 @@ void QGCApplication::_missingParamsDisplay(void)
showMessage(QString("Parameters missing from firmware: %1. You may be running an older version of firmware QGC does not work correctly with or your firmware has a bug in it.").arg(params));
}
QObject* QGCApplication::_rootQmlObject(void)
QObject* QGCApplication::_rootQmlObject()
{
#ifdef __mobile__
return _qmlAppEngine->rootObjects()[0];
......@@ -689,3 +708,41 @@ void QGCApplication::setLastKnownHomePosition(QGeoCoordinate& lastKnownHomePosit
settings.setValue(_lastKnownHomePositionAltKey, lastKnownHomePosition.altitude());
_lastKnownHomePosition = lastKnownHomePosition;
}
IQGCOptions* QGCApplication::qgcOptions()
{
return _pQGCOptions;
}
void QGCApplication::_scanAndLoadPlugins()
{
#if defined (QGC_DYNAMIC_PLUGIN)
//-- Look for plugins (Dynamic)
QString filter = "*.core.so";
QString path = QCoreApplication::applicationDirPath();
QDirIterator it(path, QStringList() << filter, QDir::Files);
while(it.hasNext()) {
QString pluginFile = it.next();
QPluginLoader loader(pluginFile);
QObject *plugin = loader.instance();
if(plugin) {
_pCorePlugin = qobject_cast<IQGCCorePlugin*>(plugin);
if(_pCorePlugin) {
_pQGCOptions = _pCorePlugin->uiOptions();
return;
}
} else {
qWarning() << "Plugin" << pluginFile << " not loaded:" << loader.errorString();
}
}
#elif defined (QGC_CUSTOM_BUILD)
//-- Create custom plugin (Static)
_pCorePlugin = (IQGCCorePlugin*) new CUSTOMCLASS(this);
if(_pCorePlugin) {
_pQGCOptions = _pCorePlugin->uiOptions();
return;
}
#endif
//-- No plugins found, use default options
_pQGCOptions = new IQGCOptions;
}
......@@ -35,6 +35,12 @@
#include "UASMessageHandler.h"
#include "FactSystem.h"
//-- Plugin Architecture
#include "IQGCApplication.h"
#include "IQGCCorePlugin.h"
#include "IQGCOptions.h"
#include "IQGCQMLSource.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
#endif
......@@ -117,6 +123,11 @@ public:
QGeoCoordinate lastKnownHomePosition(void) { return _lastKnownHomePosition; }
void setLastKnownHomePosition(QGeoCoordinate& lastKnownHomePosition);
/// Options (can be overwriten by a core plugin)
IQGCOptions* qgcOptions();
/// Custom core plugin (NULL if none)
IQGCCorePlugin* customCorePlugin() { return _pCorePlugin; }
public slots:
/// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
......@@ -166,8 +177,9 @@ private slots:
void _missingParamsDisplay(void);
private:
void _loadCurrentStyle(void);
QObject* _rootQmlObject(void);
void _loadCurrentStyle ();
QObject* _rootQmlObject ();
void _scanAndLoadPlugins ();
#ifdef __mobile__
QQmlApplicationEngine* _qmlAppEngine;
......@@ -205,6 +217,10 @@ private:
/// Unit Test have access to creating and destroying singletons
friend class UnitTest;
//-- Plugin Architecture
IQGCOptions* _pQGCOptions;
IQGCCorePlugin* _pCorePlugin;
};
/// @brief Returns the QGCApplication object singleton.
......
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