From 079d2fed4615aaa32fe0cb8ec02786936525eaf5 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 26 Sep 2015 19:56:04 -0700 Subject: [PATCH] Add top level QGroundControl object Use import QGroundControl 1.0 to get to it --- QGCApplication.pro | 2 + src/QGCApplication.cc | 29 +++++++----- src/QmlControls/QGroundControlQmlGlobal.cc | 39 ++++++++++++++++ src/QmlControls/QGroundControlQmlGlobal.h | 52 ++++++++++++++++++++++ 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 src/QmlControls/QGroundControlQmlGlobal.cc create mode 100644 src/QmlControls/QGroundControlQmlGlobal.h diff --git a/QGCApplication.pro b/QGCApplication.pro index 394d6baca..cd9af36b4 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -264,6 +264,7 @@ HEADERS += \ src/QmlControls/MavlinkQmlSingleton.h \ src/QmlControls/ParameterEditorController.h \ src/QmlControls/ScreenToolsController.h \ + src/QmlControls/QGroundControlQmlGlobal.h \ src/QmlControls/QmlObjectListModel.h \ src/SerialPortIds.h \ src/uas/FileManager.h \ @@ -394,6 +395,7 @@ SOURCES += \ src/QGCTemporaryFile.cc \ src/QmlControls/ParameterEditorController.cc \ src/QmlControls/ScreenToolsController.cc \ + src/QmlControls/QGroundControlQmlGlobal.cc \ src/QmlControls/QmlObjectListModel.cc \ src/uas/FileManager.cc \ src/uas/UAS.cc \ diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index e1ceee7e0..c795fe028 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -81,6 +81,8 @@ #include "JoystickManager.h" #include "QmlObjectListModel.h" #include "MissionManager.h" +#include "QGroundControlQmlGlobal.h" +#include "HomePositionManager.h" #ifndef __ios__ #include "SerialLink.h" @@ -125,6 +127,11 @@ static QObject* mavlinkQmlSingletonFactory(QQmlEngine*, QJSEngine*) return new MavlinkQmlSingleton; } +static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine*, QJSEngine*) +{ + return new QGroundControlQmlGlobal; +} + #if defined(QGC_GST_STREAMING) #ifdef Q_OS_MAC #ifndef __ios__ @@ -298,14 +305,15 @@ void QGCApplication::_initCommon(void) qmlRegisterType("QGroundControl.Palette", 1, 0, "QGCPalette"); - qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "AutoPilotPlugin", "Can only reference, cannot create"); - qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "VehicleComponent", "Can only reference, cannot create"); - qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "Vehicle", "Can only reference, cannot create"); - qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionItem", "Can only reference, cannot create"); - qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionManager", "Can only reference, cannot create"); - qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only"); - qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only"); - qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "AutoPilotPlugin", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "VehicleComponent", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "Vehicle", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionItem", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionManager", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only"); + qmlRegisterUncreatableType ("QGroundControl", 1, 0, "HomePositionManager", "Reference only"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); @@ -323,8 +331,9 @@ void QGCApplication::_initCommon(void) #endif // Register Qml Singletons - qmlRegisterSingletonType ("QGroundControl.ScreenToolsController", 1, 0, "ScreenToolsController", screenToolsControllerSingletonFactory); - qmlRegisterSingletonType ("QGroundControl.Mavlink", 1, 0, "Mavlink", mavlinkQmlSingletonFactory); + qmlRegisterSingletonType ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory); + qmlRegisterSingletonType ("QGroundControl.ScreenToolsController", 1, 0, "ScreenToolsController", screenToolsControllerSingletonFactory); + qmlRegisterSingletonType ("QGroundControl.Mavlink", 1, 0, "Mavlink", mavlinkQmlSingletonFactory); // Show user an upgrade message if the settings version has been bumped up bool settingsUpgraded = false; diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc new file mode 100644 index 000000000..1261e059b --- /dev/null +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -0,0 +1,39 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + 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 . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#include "QGroundControlQmlGlobal.h" + +QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject* parent) + : QObject(parent) + , _homePositionManager(HomePositionManager::instance()) +{ + +} + +QGroundControlQmlGlobal::~QGroundControlQmlGlobal() +{ + +} diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h new file mode 100644 index 000000000..72fcfff8d --- /dev/null +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -0,0 +1,52 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + 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 . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#ifndef QGroundControlQmlGlobal_H +#define QGroundControlQmlGlobal_H + +#include + +#include "HomePositionManager.h" + +class QGroundControlQmlGlobal : public QObject +{ + Q_OBJECT + +public: + QGroundControlQmlGlobal(QObject* parent = NULL); + ~QGroundControlQmlGlobal(); + + Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager CONSTANT) + + // Property accesors + + HomePositionManager* homePositionManager(void) { return _homePositionManager; } + +private: + HomePositionManager* _homePositionManager; +}; + +#endif -- 2.22.0