Newer
Older
/****************************************************************************
*
* (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.
*
****************************************************************************/
#include "FactSystem.h"
#include "FirmwarePluginManager.h"
Beat Küng
committed
#ifndef __mobile__
Beat Küng
committed
#include "GPSManager.h"
#include "HomePositionManager.h"
#include "JoystickManager.h"
#include "LinkManager.h"
#include "MAVLinkProtocol.h"
#include "MissionCommandTree.h"
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
#if defined(QGC_CUSTOM_BUILD)
#include CUSTOMHEADER
#endif
QGCToolbox::QGCToolbox(QGCApplication* app)
: _audioOutput(NULL)
, _factSystem(NULL)
, _firmwarePluginManager(NULL)
, _missionCommandTree(NULL)
, _corePlugin(NULL)
//-- Scan and load plugins
_scanAndLoadPlugins(app);
_audioOutput = new GAudioOutput(app);
_factSystem = new FactSystem(app);
_firmwarePluginManager = new FirmwarePluginManager(app);
_flightMapSettings = new FlightMapSettings(app);
Beat Küng
committed
#ifndef __mobile__
Beat Küng
committed
_gpsManager = new GPSManager(app);
_homePositionManager = new HomePositionManager(app);
_imageProvider = new QGCImageProvider(app);
_joystickManager = new JoystickManager(app);
_linkManager = new LinkManager(app);
_mavlinkProtocol = new MAVLinkProtocol(app);
_missionCommandTree = new MissionCommandTree(app);
_multiVehicleManager = new MultiVehicleManager(app);
_mapEngineManager = new QGCMapEngineManager(app);
_uasMessageHandler = new UASMessageHandler(app);
_qgcPositionManager = new QGCPositionManager(app);
void QGCToolbox::setChildToolboxes(void)
{
_corePlugin->setToolbox(this);
_audioOutput->setToolbox(this);
_factSystem->setToolbox(this);
_firmwarePluginManager->setToolbox(this);
Beat Küng
committed
#ifndef __mobile__
Beat Küng
committed
_gpsManager->setToolbox(this);
_homePositionManager->setToolbox(this);
_imageProvider->setToolbox(this);
_joystickManager->setToolbox(this);
_linkManager->setToolbox(this);
_mavlinkProtocol->setToolbox(this);
_missionCommandTree->setToolbox(this);
}
QGCToolbox::~QGCToolbox()
{
delete _audioOutput;
delete _factSystem;
delete _firmwarePluginManager;
delete _flightMapSettings;
delete _homePositionManager;
delete _joystickManager;
delete _linkManager;
delete _mavlinkProtocol;
delete _missionCommandTree;
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
delete _corePlugin;
}
void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
{
#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)
_corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app);
if(_corePlugin) {
return;
}
#endif
//-- No plugins found, use default instance
_corePlugin = new QGCCorePlugin(app);