diff --git a/QGCCommon.pri b/QGCCommon.pri index 4a807431865a650d97f5225da9cd0e7e726a0d1f..2fb1d80163d7cd4f493a828fe8f92b261c4b657f 100644 --- a/QGCCommon.pri +++ b/QGCCommon.pri @@ -38,7 +38,6 @@ linux { equals(ANDROID_TARGET_ARCH, x86) { CONFIG += Androidx86Build DEFINES += __androidx86__ - DEFINES += QGC_DISABLE_UVC message("Android x86 build") } else { message("Android Arm build") @@ -77,9 +76,10 @@ linux { error("Unsupported Qt version, 5.5.x or greater is required for iOS") } message("iOS build") - CONFIG += iOSBuild MobileBuild app_bundle + CONFIG += iOSBuild MobileBuild app_bundle NoSerialBuild DEFINES += __ios__ DEFINES += QGC_NO_GOOGLE_MAPS + DEFINES += NO_SERIAL_LINK QMAKE_IOS_DEPLOYMENT_TARGET = 8.0 QMAKE_IOS_TARGETED_DEVICE_FAMILY = 1,2 # Universal QMAKE_LFLAGS += -Wl,-no_pie diff --git a/api/IQGCCorePlugin.h b/api/IQGCCorePlugin.h deleted file mode 100644 index 6bd0fa859b56169baad0d7e91b9e577e088c9ef9..0000000000000000000000000000000000000000 --- a/api/IQGCCorePlugin.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include - -/// @file -/// @brief Core Plugin Interface for QGroundControl -/// @author Gus Grubba - -// 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 diff --git a/api/IQGCOptions.h b/api/IQGCOptions.h deleted file mode 100644 index f28544617625076e3943708ef3ca50698484a43c..0000000000000000000000000000000000000000 --- a/api/IQGCOptions.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -/// @file -/// @brief Core Plugin Interface for QGroundControl -/// @author Gus Grubba - -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(); } -}; diff --git a/api/IQGCQMLSource.h b/api/IQGCQMLSource.h deleted file mode 100644 index 5e59c21692909db4140c672c34633bdb7d6e2fd6..0000000000000000000000000000000000000000 --- a/api/IQGCQMLSource.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -/// @file -/// @brief Core Plugin Interface for QGroundControl -/// @author Gus Grubba - -class IQGCQMLSource -{ -public: - IQGCQMLSource() {} - virtual ~IQGCQMLSource() {} - virtual QString pageUrl () { return QString(); } - virtual QString pageTitle () { return QString(); } - virtual QString pageIconUrl () { return QString(); } -}; diff --git a/qgcresources.qrc b/qgcresources.qrc index b8ce22efeeeb1d70bfa5e7ee60dc3ec9563cbd55..51a35405d4d1de17c046df4b62d9a3c21feaa2f2 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -181,6 +181,7 @@ resources/TrashDelete.svg resources/XDelete.svg resources/XDeleteBlack.svg + resources/waves.svg resources/icons/qgroundcontrol.ico diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 3652d75294611c1ab6fdfde76b9bc95f4a4c4906..f056999455f97c838b27fc3ac1900d0fb6e4b980 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -34,6 +34,34 @@ exists(user_config.pri):infile(user_config.pri, CONFIG) { message($$sprintf("Using user-supplied additional config: '%1' specified in user_config.pri", $$fromfile(user_config.pri, CONFIG))) } +# +# Custom Build +# +# QGC will create a "CUSTOMCLASS" object (exposed by your custom build +# and derived from QGCCorePlugin). +# This is the start of allowing custom Plugins, which will eventually use a +# more defined runtime plugin architecture and not require a QGC project +# file you would have to keep in sync with the upstream repo. +# + +# This allows you to ignore the custom build even if the custom build +# is present. It's useful to run "regular" builds to make sure you didn't +# break anything. + +contains (CONFIG, QGC_DISABLE_CUSTOM_BUILD) { + message("Disable custom build override") +} else { + exists($$PWD/custom/custom.pri) { + message("Found custom build") + CONFIG += CustomBuild + DEFINES += QGC_CUSTOM_BUILD + # custom.pri must define: + # CUSTOMCLASS = YourIQGCCorePluginDerivation + # CUSTOMHEADER = \"\\\"YourIQGCCorePluginDerivation.h\\\"\" + include($$PWD/custom/custom.pri) + } +} + # # Plugin configuration # @@ -69,34 +97,6 @@ contains (CONFIG, QGC_DISABLE_PX4_PLUGIN_FACTORY) { CONFIG += PX4FirmwarePluginFactory } -# -# Custom Build -# -# QGC will create a "CUSTOMCLASS" object (exposed by your custom build -# and derived from IQGCCorePlugin) and call its IQGCCorePlugin::init() method. -# This is the start of allowing custom Plugins, which will eventually use a -# more defined runtime plugin architecture and not require a QGC project -# file you would have to keep in sync with the upstream repo. -# - -# This allows you to ignore the custom build even if the custom build -# is present. It's useful to run "regular" builds to make sure you didn't -# break anything. - -contains (CONFIG, QGC_DISABLE_CUSTOM_BUILD) { - message("Disable custom build override") -} else { - exists($$PWD/custom/custom.pri) { - message("Found custom build") - CONFIG += CustomBuild - DEFINES += QGC_CUSTOM_BUILD - # custom.pri must define: - # CUSTOMCLASS = YourIQGCCorePluginDerivation - # CUSTOMHEADER = \"\\\"YourIQGCCorePluginDerivation.h\\\"\" - include($$PWD/custom/custom.pri) - } -} - # Bluetooth contains (DEFINES, QGC_DISABLE_BLUETOOTH) { message("Skipping support for Bluetooth (manual override from command line)") @@ -273,9 +273,9 @@ DEPENDPATH += \ INCLUDEPATH += . INCLUDEPATH += \ - api \ include/ui \ src \ + src/api \ src/AnalyzeView \ src/AutoPilotPlugins \ src/FlightDisplay \ @@ -336,10 +336,14 @@ FORMS += \ # HEADERS += \ - api/IQGCApplication.h \ - api/IQGCCorePlugin.h \ - api/IQGCOptions.h \ - api/IQGCQMLSource.h \ + src/api/QGCCorePlugin.h \ + src/api/QGCOptions.h \ + src/api/QGCSettings.h \ + +SOURCES += \ + src/api/QGCCorePlugin.cc \ + src/api/QGCOptions.cc \ + src/api/QGCSettings.cc \ # # Unit Test specific configuration goes here (requires full debug build with all plugins) @@ -503,7 +507,7 @@ contains(DEFINES, QGC_ENABLE_BLUETOOTH) { src/comm/BluetoothLink.h \ } -!iOSBuild { +!NoSerialBuild { HEADERS += \ src/comm/QGCSerialPortInfo.h \ src/comm/SerialLink.h \ @@ -651,7 +655,7 @@ SOURCES += \ src/comm/MockLinkMissionItemHandler.cc \ } -!iOSBuild { +!NoSerialBuild { SOURCES += \ src/comm/QGCSerialPortInfo.cc \ src/comm/SerialLink.cc \ diff --git a/resources/waves.svg b/resources/waves.svg new file mode 100644 index 0000000000000000000000000000000000000000..fbca7c7819fd882452ada1c52c56db7ddb0f2afa --- /dev/null +++ b/resources/waves.svg @@ -0,0 +1,21 @@ + + + + + + + + diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index c370749550ab2bd8dfd0d2550ac51424ebfcd732..094a3fa25e16acf1fc6aeb647d52116e2bad8fa1 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -140,10 +140,10 @@ Item { } QGCLabel { - id: flyLabel - text: qsTr("Fly") - color: mapPal.text - visible: !ScreenTools.isShortScreen + id: flyLabel + text: qsTr("Fly") + color: mapPal.text + visible: !ScreenTools.isShortScreen && _mainIsMap anchors.topMargin: _toolButtonTopMargin anchors.horizontalCenter: toolColumn.horizontalCenter anchors.top: parent.top diff --git a/src/FlightDisplay/VideoManager.cc b/src/FlightDisplay/VideoManager.cc index 02c325fabffee80638ec6f20bef41ae3002bf4e9..a68e880aa97d5ecb774e63f08197ba3b8a9634ab 100644 --- a/src/FlightDisplay/VideoManager.cc +++ b/src/FlightDisplay/VideoManager.cc @@ -20,12 +20,15 @@ #include "ScreenToolsController.h" #include "VideoManager.h" +#include "QGCToolbox.h" +#include "QGCCorePlugin.h" +#include "QGCOptions.h" static const char* kVideoSourceKey = "VideoSource"; static const char* kVideoUDPPortKey = "VideoUDPPort"; static const char* kVideoRTSPUrlKey = "VideoRTSPUrl"; -static const char* kUDPStream = "UDP Video Stream"; #if defined(QGC_GST_STREAMING) +static const char* kUDPStream = "UDP Video Stream"; static const char* kRTSPStream = "RTSP Video Stream"; #endif static const char* kNoVideo = "No Video Available"; @@ -41,17 +44,6 @@ VideoManager::VideoManager(QGCApplication* app) , _udpPort(5600) //-- Defalut Port 5600 == Solo UDP Port , _init(false) { - //-- Get saved settings - QSettings settings; - setVideoSource(settings.value(kVideoSourceKey, kUDPStream).toString()); - setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt()); - setRtspURL(settings.value(kVideoRTSPUrlKey, "rtsp://192.168.42.1:554/live").toString()); //-- Example RTSP URL - _init = true; -#if defined(QGC_GST_STREAMING) - _updateVideo(); - connect(&_frameTimer, &QTimer::timeout, this, &VideoManager::_updateTimer); - _frameTimer.start(1000); -#endif } //----------------------------------------------------------------------------- @@ -67,6 +59,34 @@ VideoManager::setToolbox(QGCToolbox *toolbox) QGCTool::setToolbox(toolbox); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.VideoManager", 1, 0, "VideoManager", "Reference only"); + //-- Get saved settings +#if defined(QGC_GST_STREAMING) + QSettings settings; +#if defined(NO_UDP_VIDEO) + setVideoSource(settings.value(kVideoSourceKey, kRTSPStream).toString()); +#else + setVideoSource(settings.value(kVideoSourceKey, kUDPStream).toString()); +#endif + //-- Check if core plugin defines its own video requirements + if(qgcApp()->toolbox()->corePlugin()->options()->definesVideo()) { + if(qgcApp()->toolbox()->corePlugin()->options()->videoUDPPort()) { + setUdpPort(qgcApp()->toolbox()->corePlugin()->options()->videoUDPPort()); + setVideoSource(kUDPStream); + } else { + setVideoSource(kRTSPStream); + setRtspURL(qgcApp()->toolbox()->corePlugin()->options()->videoRSTPUrl()); + } + } else { + setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt()); + setRtspURL(settings.value(kVideoRTSPUrlKey, "rtsp://192.168.42.1:554/live").toString()); //-- Example RTSP URL + } +#endif + _init = true; +#if defined(QGC_GST_STREAMING) + _updateVideo(); + connect(&_frameTimer, &QTimer::timeout, this, &VideoManager::_updateTimer); + _frameTimer.start(1000); +#endif } //----------------------------------------------------------------------------- diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 278c0a06c6247c2a283abfde4653b4befad0909b..578634b6d38f14565a374ba344bb7510e1c88d1d 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -83,11 +83,7 @@ #include "QGCMapPolygon.h" #include "ParameterManager.h" -#if defined(QGC_CUSTOM_BUILD) -#include CUSTOMHEADER -#endif - -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif @@ -188,15 +184,10 @@ 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); @@ -358,9 +349,6 @@ QGCApplication::~QGCApplication() #endif shutdownVideoStreaming(); delete _toolbox; - if(_pCorePlugin) { - delete _pCorePlugin; - } } void QGCApplication::_initCommon(void) @@ -456,14 +444,6 @@ bool QGCApplication::_initForNormalAppBoot(void) } settings.sync(); - - //-- Initialize Core Plugin (if any) - if(_pCorePlugin) { - if(!_pCorePlugin->init(this)) { - return false; - } - } - return true; } @@ -708,41 +688,3 @@ 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(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; -} diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 6a9dbf96644455ca7a4b3b1f820ff537e437df6b..002c88e39d1ab9fc889258d1c7d300d70afb9a8a 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -35,12 +35,6 @@ #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 @@ -123,11 +117,6 @@ 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); @@ -179,7 +168,6 @@ private slots: private: void _loadCurrentStyle (); QObject* _rootQmlObject (); - void _scanAndLoadPlugins (); #ifdef __mobile__ QQmlApplicationEngine* _qmlAppEngine; @@ -218,9 +206,6 @@ 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. diff --git a/src/QGCToolbox.cc b/src/QGCToolbox.cc index 3e625d66a1bfa0e2a0ceb4198ca16dad615a7b4e..28e1afbe22901b4cee6ad0f3fd43bb7fc62e5c89 100644 --- a/src/QGCToolbox.cc +++ b/src/QGCToolbox.cc @@ -28,6 +28,12 @@ #include "PositionManager.h" #include "VideoManager.h" #include "MAVLinkLogManager.h" +#include "QGCCorePlugin.h" +#include "QGCOptions.h" + +#if defined(QGC_CUSTOM_BUILD) +#include CUSTOMHEADER +#endif QGCToolbox::QGCToolbox(QGCApplication* app) : _audioOutput(NULL) @@ -50,7 +56,10 @@ QGCToolbox::QGCToolbox(QGCApplication* app) , _qgcPositionManager(NULL) , _videoManager(NULL) , _mavlinkLogManager(NULL) + , _corePlugin(NULL) { + //-- Scan and load plugins + _scanAndLoadPlugins(app); _audioOutput = new GAudioOutput(app); _factSystem = new FactSystem(app); _firmwarePluginManager = new FirmwarePluginManager(app); @@ -75,6 +84,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app) void QGCToolbox::setChildToolboxes(void) { + _corePlugin->setToolbox(this); _audioOutput->setToolbox(this); _factSystem->setToolbox(this); _firmwarePluginManager->setToolbox(this); @@ -115,6 +125,20 @@ QGCToolbox::~QGCToolbox() delete _uasMessageHandler; delete _followMe; delete _qgcPositionManager; + delete _corePlugin; +} + +void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app) +{ +#if 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); } QGCTool::QGCTool(QGCApplication* app) @@ -122,7 +146,6 @@ QGCTool::QGCTool(QGCApplication* app) , _app(app) , _toolbox(NULL) { - } void QGCTool::setToolbox(QGCToolbox* toolbox) diff --git a/src/QGCToolbox.h b/src/QGCToolbox.h index 8948fda3a0b92423eef2ecd811caeee1d4f9c3f0..607ab0a665df0ada4ceffd6068dc0c3c30e4c8ae 100644 --- a/src/QGCToolbox.h +++ b/src/QGCToolbox.h @@ -32,6 +32,7 @@ class UASMessageHandler; class QGCPositionManager; class VideoManager; class MAVLinkLogManager; +class QGCCorePlugin; /// This is used to manage all of our top level services/tools class QGCToolbox { @@ -56,6 +57,7 @@ public: QGCPositionManager* qgcPositionManager(void) { return _qgcPositionManager; } VideoManager* videoManager(void) { return _videoManager; } MAVLinkLogManager* mavlinkLogManager(void) { return _mavlinkLogManager; } + QGCCorePlugin* corePlugin(void) { return _corePlugin; } #ifndef __mobile__ GPSManager* gpsManager(void) { return _gpsManager; } @@ -63,6 +65,8 @@ public: private: void setChildToolboxes(void); + void _scanAndLoadPlugins(QGCApplication *app); + GAudioOutput* _audioOutput; FactSystem* _factSystem; @@ -84,6 +88,7 @@ private: QGCPositionManager* _qgcPositionManager; VideoManager* _videoManager; MAVLinkLogManager* _mavlinkLogManager; + QGCCorePlugin* _corePlugin; friend class QGCApplication; }; diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index c249191bdba2e3cbd4f844c03bf979b098c21964..2a8168db32061e1c2cccb1a2d6733f0a5a02fc93 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -45,6 +45,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app) , _missionCommandTree(NULL) , _videoManager(NULL) , _mavlinkLogManager(NULL) + , _corePlugin(NULL) , _virtualTabletJoystick(false) , _baseFontPointSize(0.0) { @@ -73,6 +74,7 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox) _missionCommandTree = toolbox->missionCommandTree(); _videoManager = toolbox->videoManager(); _mavlinkLogManager = toolbox->mavlinkLogManager(); + _corePlugin = toolbox->corePlugin(); } void QGroundControlQmlGlobal::saveGlobalSetting (const QString& key, const QString& value) diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index 8f3ef8777cde8cabe41c893efd0b53e95f63f934..b0b01d09217cd9830ef7a3e7bc8965a5f8dabeae 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -73,13 +73,13 @@ public: Q_PROPERTY(MissionCommandTree* missionCommandTree READ missionCommandTree CONSTANT) Q_PROPERTY(VideoManager* videoManager READ videoManager CONSTANT) Q_PROPERTY(MAVLinkLogManager* mavlinkLogManager READ mavlinkLogManager CONSTANT) + Q_PROPERTY(QGCCorePlugin* corePlugin READ corePlugin CONSTANT) Q_PROPERTY(qreal zOrderTopMost READ zOrderTopMost CONSTANT) ///< z order for top most items, toolbar, main window sub view Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss Q_PROPERTY(qreal zOrderMapItems READ zOrderMapItems CONSTANT) ///< z order value for map items, for example: mission item indicators // Various QGC settings exposed to Qml - Q_PROPERTY(bool isAdvancedMode READ isAdvancedMode CONSTANT) ///< Global "Advance Mode" preference. Certain UI elements and features are different based on this. Q_PROPERTY(bool isDarkStyle READ isDarkStyle WRITE setIsDarkStyle NOTIFY isDarkStyleChanged) // TODO: Should be in ScreenTools? Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged) Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged) @@ -87,6 +87,7 @@ public: Q_PROPERTY(bool virtualTabletJoystick READ virtualTabletJoystick WRITE setVirtualTabletJoystick NOTIFY virtualTabletJoystickChanged) Q_PROPERTY(qreal baseFontPointSize READ baseFontPointSize WRITE setBaseFontPointSize NOTIFY baseFontPointSizeChanged) + //------------------------------------------------------------------------- // MavLink Protocol Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) Q_PROPERTY(int mavlinkSystemID READ mavlinkSystemID WRITE setMavlinkSystemID NOTIFY mavlinkSystemIDChanged) @@ -170,6 +171,7 @@ public: MissionCommandTree* missionCommandTree () { return _missionCommandTree; } VideoManager* videoManager () { return _videoManager; } MAVLinkLogManager* mavlinkLogManager () { return _mavlinkLogManager; } + QGCCorePlugin* corePlugin () { return _corePlugin; } qreal zOrderTopMost () { return 1000; } qreal zOrderWidgets () { return 100; } @@ -196,9 +198,6 @@ public: static Fact* speedUnits (void); static Fact* batteryPercentRemainingAnnounce(void); - //-- TODO: Make this into an actual preference. - bool isAdvancedMode () { return false; } - void setIsDarkStyle (bool dark); void setIsAudioMuted (bool muted); void setIsSaveLogPrompt (bool prompt); @@ -244,6 +243,7 @@ private: MissionCommandTree* _missionCommandTree; VideoManager* _videoManager; MAVLinkLogManager* _mavlinkLogManager; + QGCCorePlugin* _corePlugin; bool _virtualTabletJoystick; qreal _baseFontPointSize; diff --git a/src/Vehicle/MultiVehicleManager.cc b/src/Vehicle/MultiVehicleManager.cc index 9bac096f60e35eb40f3e16bec550fa3211a9ff81..5baa4fab65451ac1d53554284e4c3fac91b5218e 100644 --- a/src/Vehicle/MultiVehicleManager.cc +++ b/src/Vehicle/MultiVehicleManager.cc @@ -16,7 +16,7 @@ #include "QGroundControlQmlGlobal.h" #include "ParameterManager.h" -#ifdef __mobile__ +#if defined (__ios__) || defined(__android__) #include "MobileScreenMgr.h" #endif @@ -116,7 +116,7 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle // Mark link as active link->setActive(true); -#ifdef __mobile__ +#if defined (__ios__) || defined(__android__) if(_vehicles.count() == 1) { //-- Once a vehicle is connected, keep screen from going off qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::keepScreenOn"; @@ -157,7 +157,7 @@ void MultiVehicleManager::_deleteVehiclePhase1(Vehicle* vehicle) emit parameterReadyVehicleAvailableChanged(false); emit vehicleRemoved(vehicle); -#ifdef __mobile__ +#if defined (__ios__) || defined(__android__) if(_vehicles.count() == 0) { //-- Once no vehicles are connected, we no longer need to keep screen from going off qCDebug(MultiVehicleManagerLog) << "QAndroidJniObject::restoreScreenOn"; diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 4537f0f3576aa73f8f221c942661bb261884009c..90ad8003d1d3906695de74706ae35f64b99e8c46 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -933,7 +933,7 @@ void Vehicle::_sendMessageOnLink(LinkInterface* link, mavlink_message_t message) /// @return Direct usb connection link to board if one, NULL if none LinkInterface* Vehicle::priorityLink(void) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK foreach (LinkInterface* link, _links) { if (link->isConnected()) { SerialLink* pSerialLink = qobject_cast(link); diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index 77b6781790a3b921bb61f14d0854d47fd82cd830..54e0e0ffca0e88399ec81fda03280c05453be6d7 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -256,6 +256,19 @@ Rectangle { visible: !ScreenTools.isShortScreen } + Repeater { + model: QGroundControl.corePlugin.settings + visible: QGroundControl.corePlugin.options.combineSettingsAndSetup + SubMenuButton { + imageResource: modelData.icon + setupIndicator: false + exclusiveGroup: setupButtonGroup + text: modelData.title + visible: QGroundControl.corePlugin.options.combineSettingsAndSetup + onClicked: panelLoader.setSource(modelData.url) + } + } + SubMenuButton { id: summaryButton imageResource: "/qmlimages/VehicleSummaryIcon.png" diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc new file mode 100644 index 0000000000000000000000000000000000000000..a530547ddc96be0dcb7cb3a4f4b322f47e778452 --- /dev/null +++ b/src/api/QGCCorePlugin.cc @@ -0,0 +1,136 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "QGCCorePlugin.h" +#include "QGCOptions.h" +#include "QGCSettings.h" + +#include +#include + +/// @file +/// @brief Core Plugin Interface for QGroundControl - Default Implementation +/// @author Gus Grubba + +class QGCCorePlugin_p +{ +public: + QGCCorePlugin_p() + : pGeneral(NULL) + , pCommLinks(NULL) + , pOfflineMaps(NULL) + , pMAVLink(NULL) + , pConsole(NULL) +#if defined(QT_DEBUG) + , pMockLink(NULL) + , pDebug(NULL) +#endif + , defaultOptions(NULL) + { + } + ~QGCCorePlugin_p() + { + if(pGeneral) + delete pGeneral; + if(pCommLinks) + delete pCommLinks; + if(pOfflineMaps) + delete pOfflineMaps; + if(pMAVLink) + delete pMAVLink; + if(pConsole) + delete pConsole; +#if defined(QT_DEBUG) + if(pMockLink) + delete pMockLink; + if(pDebug) + delete pDebug; +#endif + if(defaultOptions) + delete defaultOptions; + } + QGCSettings* pGeneral; + QGCSettings* pCommLinks; + QGCSettings* pOfflineMaps; + QGCSettings* pMAVLink; + QGCSettings* pConsole; +#if defined(QT_DEBUG) + QGCSettings* pMockLink; + QGCSettings* pDebug; +#endif + QVariantList settingsList; + QGCOptions* defaultOptions; +}; + +QGCCorePlugin::~QGCCorePlugin() +{ + if(_p) { + delete _p; + } +} + +QGCCorePlugin::QGCCorePlugin(QGCApplication *app) + : QGCTool(app) +{ + _p = new QGCCorePlugin_p; +} + +void QGCCorePlugin::setToolbox(QGCToolbox *toolbox) +{ + QGCTool::setToolbox(toolbox); + QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); + qmlRegisterUncreatableType("QGroundControl.QGCCorePlugin", 1, 0, "QGCCorePlugin", "Reference only"); + qmlRegisterUncreatableType("QGroundControl.QGCOptions", 1, 0, "QGCOptions", "Reference only"); +} + +QVariantList &QGCCorePlugin::settings() +{ + //-- If this hasn't been overridden, create default set of settings + if(!_p->pGeneral) { + //-- Default Settings + _p->pGeneral = new QGCSettings(tr("General"), + QUrl::fromUserInput("qrc:/qml/GeneralSettings.qml"), + QUrl::fromUserInput("qrc:/res/gear-white.svg")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pGeneral)); + _p->pCommLinks = new QGCSettings(tr("Comm Links"), + QUrl::fromUserInput("qrc:/qml/LinkSettings.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pCommLinks)); + _p->pOfflineMaps = new QGCSettings(tr("Offline Maps"), + QUrl::fromUserInput("qrc:/qml/OfflineMap.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pOfflineMaps)); + _p->pMAVLink = new QGCSettings(tr("MAVLink"), + QUrl::fromUserInput("qrc:/qml/MavlinkSettings.qml"), + QUrl::fromUserInput("qrc:/res/waves.svg")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pMAVLink)); + _p->pConsole = new QGCSettings(tr("Console"), + QUrl::fromUserInput("qrc:/qml/QGroundControl/Controls/AppMessages.qml")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pConsole)); + #if defined(QT_DEBUG) + //-- These are always present on Debug builds + _p->pMockLink = new QGCSettings(tr("Mock Link"), + QUrl::fromUserInput("qrc:/qml/MockLink.qml")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pMockLink)); + _p->pDebug = new QGCSettings(tr("Debug"), + QUrl::fromUserInput("qrc:/qml/DebugWindow.qml")); + _p->settingsList.append(QVariant::fromValue((QGCSettings*)_p->pDebug)); + #endif + } + return _p->settingsList; +} + +QGCOptions* QGCCorePlugin::options() +{ + if(!_p->defaultOptions) { + _p->defaultOptions = new QGCOptions(); + } + return _p->defaultOptions; +} + diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..9d1a1afa03ff965cf157fad294b5638bb57ef943 --- /dev/null +++ b/src/api/QGCCorePlugin.h @@ -0,0 +1,54 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include "QGCToolbox.h" + +#include +#include + +/// @file +/// @brief Core Plugin Interface for QGroundControl +/// @author Gus Grubba + +// Work In Progress + +class QGCApplication; +class QGCOptions; +class QGCSettings; +class QGCCorePlugin_p; + +class QGCCorePlugin : public QGCTool +{ + Q_OBJECT +public: + QGCCorePlugin(QGCApplication* app); + ~QGCCorePlugin(); + + Q_PROPERTY(QVariantList settings READ settings CONSTANT) + Q_PROPERTY(QGCOptions* options READ options CONSTANT) + + //! The list of settings under the Settings Menu + /*! + @return A list of QGCSettings + */ + virtual QVariantList& settings (); + + //! Global options + /*! + @return An instance of QGCOptions + */ + virtual QGCOptions* options (); + + // Override from QGCTool + void setToolbox (QGCToolbox *toolbox); +private: + QGCCorePlugin_p* _p; +}; diff --git a/api/IQGCApplication.h b/src/api/QGCOptions.cc similarity index 58% rename from api/IQGCApplication.h rename to src/api/QGCOptions.cc index 79edce901b314bddbe5f4faed1032182eb9b8688..3b598fe3dfc19aa3e25ca86407540249674a8913 100644 --- a/api/IQGCApplication.h +++ b/src/api/QGCOptions.cc @@ -7,18 +7,13 @@ * ****************************************************************************/ +#include "QGCOptions.h" -/** - * @brief QGC Main Application Interface (used for Dynamic Loaded plugins) - * @author Gus Grubba - */ +/// @file +/// @brief Core Plugin Interface for QGroundControl - Application Options +/// @author Gus Grubba -#pragma once - -class IQGCApplication +QGCOptions::QGCOptions(QObject* parent) + : QObject(parent) { -public: - IQGCApplication() {} - virtual ~IQGCApplication() {} - //-- Not yet implemented -}; +} diff --git a/src/api/QGCOptions.h b/src/api/QGCOptions.h new file mode 100644 index 0000000000000000000000000000000000000000..e1e9135120a2e831cf0165a497ca2e1262f955bd --- /dev/null +++ b/src/api/QGCOptions.h @@ -0,0 +1,68 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include +#include + +/// @file +/// @brief Core Plugin Interface for QGroundControl - Application Options +/// @author Gus Grubba + +class QGCOptions : public QObject +{ + Q_OBJECT +public: + QGCOptions(QObject* parent = NULL); + + Q_PROPERTY(bool combineSettingsAndSetup READ combineSettingsAndSetup CONSTANT) + Q_PROPERTY(bool enableVirtualJoystick READ enableVirtualJoystick CONSTANT) + Q_PROPERTY(bool enableAutoConnectOptions READ enableAutoConnectOptions CONSTANT) + Q_PROPERTY(bool enableVideoSourceOptions READ enableVideoSourceOptions CONSTANT) + Q_PROPERTY(bool definesVideo READ definesVideo CONSTANT) + Q_PROPERTY(uint16_t videoUDPPort READ videoUDPPort CONSTANT) + Q_PROPERTY(QString videoRSTPUrl READ videoRSTPUrl CONSTANT) + + //! Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)? + /*! + @return true if QGC should consolidate both menus into one. + */ + virtual bool combineSettingsAndSetup () { return false; } + //! 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(); } +}; diff --git a/src/api/QGCSettings.cc b/src/api/QGCSettings.cc new file mode 100644 index 0000000000000000000000000000000000000000..6fbe9dbe336b6bda84e2913a817ff6356382ba0c --- /dev/null +++ b/src/api/QGCSettings.cc @@ -0,0 +1,21 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#include "QGCSettings.h" + +/// @file +/// @brief Core Plugin Interface for QGroundControl. Settings element. +/// @author Gus Grubba + +QGCSettings::QGCSettings(QString title, QUrl url, QUrl icon) + : _title(title) + , _url(url) + , _icon(icon) +{ +} diff --git a/src/api/QGCSettings.h b/src/api/QGCSettings.h new file mode 100644 index 0000000000000000000000000000000000000000..682364cb20b796167f8a787e341001c26ebd6991 --- /dev/null +++ b/src/api/QGCSettings.h @@ -0,0 +1,37 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include +#include + +/// @file +/// @brief Core Plugin Interface for QGroundControl. Settings element. +/// @author Gus Grubba + +class QGCSettings : public QObject +{ + Q_OBJECT +public: + QGCSettings(QString title, QUrl url, QUrl icon = QUrl()); + + Q_PROPERTY(QString title READ title CONSTANT) + Q_PROPERTY(QUrl url READ url CONSTANT) + Q_PROPERTY(QUrl icon READ icon CONSTANT) + + virtual QString title () { return _title; } + virtual QUrl url () { return _url; } + virtual QUrl icon () { return _icon; } + +protected: + QString _title; + QUrl _url; + QUrl _icon; +}; diff --git a/src/comm/LinkConfiguration.cc b/src/comm/LinkConfiguration.cc index 367051b73b325befa918480a0cf27b327e2f7908..915c20cda6217c6c3fe51a135a4c7e4c95590651 100644 --- a/src/comm/LinkConfiguration.cc +++ b/src/comm/LinkConfiguration.cc @@ -15,12 +15,12 @@ */ #include "LinkConfiguration.h" -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif #include "UDPLink.h" #include "TCPLink.h" -#ifndef __mobile__ +#if !defined(__mobile__) #include "LogReplayLink.h" #endif #ifdef QGC_ENABLE_BLUETOOTH @@ -79,7 +79,7 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na { LinkConfiguration* config = NULL; switch(type) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK case LinkConfiguration::TypeSerial: config = new SerialConfiguration(name); break; @@ -117,7 +117,7 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc { LinkConfiguration* dupe = NULL; switch(source->type()) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK case TypeSerial: dupe = new SerialConfiguration(dynamic_cast(source)); break; diff --git a/src/comm/LinkConfiguration.h b/src/comm/LinkConfiguration.h index 0158cc4a5d449f376393a16d8fde22da17f937d1..59fa8f36ffc7ec07adbfb3f9bf4eae0f2f879c52 100644 --- a/src/comm/LinkConfiguration.h +++ b/src/comm/LinkConfiguration.h @@ -46,7 +46,7 @@ public: /// The link types supported by QGC /// Any changes here MUST be reflected in LinkManager::linkTypeStrings() enum LinkType { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK TypeSerial, ///< Serial Link #endif TypeUdp, ///< UDP Link diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 7aef4cad9f358d5a47461b18ead2c9dfda92ec7f..34a0320fd1e793550f4cf4dbf9ee3100b542dd90 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -21,7 +21,7 @@ #include #include -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "QGCSerialPortInfo.h" #endif @@ -85,7 +85,7 @@ LinkManager::LinkManager(QGCApplication* app) _autoconnectRTKGPS = settings.value(_autoconnectRTKGPSKey, true).toBool(); _autoconnectLibrePilot = settings.value(_autoconnectLibrePilotKey, true).toBool(); -#ifndef __ios__ +#ifndef NO_SERIAL_LINK _activeLinkCheckTimer.setInterval(_activeLinkCheckTimeoutMSecs); _activeLinkCheckTimer.setSingleShot(false); connect(&_activeLinkCheckTimer, &QTimer::timeout, this, &LinkManager::_activeLinkCheck); @@ -113,7 +113,7 @@ LinkInterface* LinkManager::createConnectedLink(LinkConfiguration* config) Q_ASSERT(config); LinkInterface* pLink = NULL; switch(config->type()) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK case LinkConfiguration::TypeSerial: { SerialConfiguration* serialConfig = dynamic_cast(config); @@ -373,7 +373,7 @@ void LinkManager::loadLinkConfigurationList() LinkConfiguration* pLink = NULL; bool autoConnect = settings.value(root + "/auto").toBool(); switch((LinkConfiguration::LinkType)type) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK case LinkConfiguration::TypeSerial: pLink = (LinkConfiguration*)new SerialConfiguration(name); break; @@ -443,7 +443,7 @@ void LinkManager::loadLinkConfigurationList() _configurationsLoaded = true; } -#ifndef __ios__ +#ifndef NO_SERIAL_LINK SerialConfiguration* LinkManager::_autoconnectConfigurationsContainsPort(const QString& portName) { QString searchPort = portName.trimmed(); @@ -488,7 +488,7 @@ void LinkManager::_updateAutoConnectLinks(void) emit linkConfigurationsChanged(); } -#ifndef __ios__ +#ifndef NO_SERIAL_LINK QStringList currentPorts; QList portList = QGCSerialPortInfo::availablePorts(); @@ -633,7 +633,7 @@ void LinkManager::_updateAutoConnectLinks(void) } delete pDeleteConfig; } -#endif // __ios__ +#endif // NO_SERIAL_LINK } void LinkManager::shutdown(void) @@ -704,7 +704,7 @@ QStringList LinkManager::linkTypeStrings(void) const static QStringList list; if(!list.size()) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK list += "Serial"; #endif list += "UDP"; @@ -727,7 +727,7 @@ void LinkManager::_updateSerialPorts() { _commPortList.clear(); _commPortDisplayList.clear(); -#ifndef __ios__ +#ifndef NO_SERIAL_LINK QList portList = QSerialPortInfo::availablePorts(); foreach (const QSerialPortInfo &info, portList) { @@ -758,7 +758,7 @@ QStringList LinkManager::serialPorts(void) QStringList LinkManager::serialBaudRates(void) { -#ifdef __ios__ +#ifdef NO_SERIAL_LINK QStringList foo; return foo; #else @@ -791,7 +791,7 @@ bool LinkManager::endCreateConfiguration(LinkConfiguration* config) LinkConfiguration* LinkManager::createConfiguration(int type, const QString& name) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK if((LinkConfiguration::LinkType)type == LinkConfiguration::TypeSerial) _updateSerialPorts(); #endif @@ -801,7 +801,7 @@ LinkConfiguration* LinkManager::createConfiguration(int type, const QString& nam LinkConfiguration* LinkManager::startConfigurationEditing(LinkConfiguration* config) { Q_ASSERT(config != NULL); -#ifndef __ios__ +#ifndef NO_SERIAL_LINK if(config->type() == LinkConfiguration::TypeSerial) _updateSerialPorts(); #endif @@ -815,7 +815,7 @@ void LinkManager::_fixUnnamed(LinkConfiguration* config) //-- Check for "Unnamed" if (config->name() == "Unnamed") { switch(config->type()) { -#ifndef __ios__ +#ifndef NO_SERIAL_LINK case LinkConfiguration::TypeSerial: { QString tname = dynamic_cast(config)->portName(); #ifdef Q_OS_WIN @@ -895,7 +895,7 @@ bool LinkManager::isBluetoothAvailable(void) return qgcApp()->isBluetoothAvailable(); } -#ifndef __ios__ +#ifndef NO_SERIAL_LINK void LinkManager::_activeLinkCheck(void) { SerialLink* link = NULL; diff --git a/src/comm/LinkManager.h b/src/comm/LinkManager.h index 330572033e848d670e3cb33a9abcdfc79c0a58eb..23cddcbdf47a25e56bd5f7cd42df288ab4ec28e0 100644 --- a/src/comm/LinkManager.h +++ b/src/comm/LinkManager.h @@ -24,12 +24,12 @@ #include "QGCToolbox.h" #include "ProtocolInterface.h" #include "MAVLinkProtocol.h" -#ifndef __mobile__ +#if !defined(__mobile__) #include "LogReplayLink.h" #endif #include "QmlObjectListModel.h" -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif @@ -199,7 +199,7 @@ private slots: void _linkConnected(void); void _linkDisconnected(void); void _linkConnectionRemoved(LinkInterface* link); -#ifndef __ios__ +#ifndef NO_SERIAL_LINK void _activeLinkCheck(void); #endif @@ -210,7 +210,7 @@ private: void _fixUnnamed(LinkConfiguration* config); bool _setAutoconnectWorker(bool& currentAutoconnect, bool newAutoconnect, const char* autoconnectKey); -#ifndef __ios__ +#ifndef NO_SERIAL_LINK SerialConfiguration* _autoconnectConfigurationsContainsPort(const QString& portName); #endif @@ -237,7 +237,7 @@ private: bool _autoconnectPX4Flow; bool _autoconnectRTKGPS; bool _autoconnectLibrePilot; -#ifndef __ios__ +#ifndef NO_SERIAL_LINK QTimer _activeLinkCheckTimer; ///< Timer which checks for a vehicle showing up on a usb direct link QList _activeLinkCheckList; ///< List of links we are waiting for a vehicle to show up on static const int _activeLinkCheckTimeoutMSecs = 15000; ///< Amount of time to wait for a heatbeat. Keep in mind ArduPilot stack heartbeat is slow to come. diff --git a/src/main.cc b/src/main.cc index eb8319cdf0a17487b6c9566e36d9af33c40cb1b4..80000cd33c10dcb4ef135d18830296df448681b2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -74,7 +74,7 @@ int WindowsCrtReportHook(int reportType, char* message, int* returnValue) #endif -#ifdef __android__ +#if defined(__android__) && !defined(NO_SERIAL_LINK) #include #include "qserialport.h" @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) // that we use these types in signals, and without calling qRegisterMetaType we can't queue // these signals. In general we don't queue these signals, but we do what the warning says // anyway to silence the debug output. -#ifndef __ios__ +#ifndef NO_SERIAL_LINK qRegisterMetaType(); #endif #ifdef QGC_ENABLE_BLUETOOTH diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 840bf7c3aa6f1fe1c1cfa84ce1e5049b0292760f..e313e87aa057f272660e96fd54aa1f7640e16989 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -36,7 +36,7 @@ #include "MAVLinkProtocol.h" #include "QGCMAVLink.h" #include "LinkManager.h" -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif #include "FirmwarePluginManager.h" diff --git a/src/ui/AppSettings.qml b/src/ui/AppSettings.qml index e807c815d798a871c712110acecece8b90408c9c..337aac725d54101f0820af470b351b632c004f32 100644 --- a/src/ui/AppSettings.qml +++ b/src/ui/AppSettings.qml @@ -30,13 +30,13 @@ Rectangle { readonly property real _buttonHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3 : ScreenTools.defaultFontPixelHeight * 2 readonly property real _buttonWidth: ScreenTools.defaultFontPixelWidth * 10 + property bool _first: true + QGCPalette { id: qgcPal } Component.onCompleted: { //-- Default to General Settings __rightPanel.source = "GeneralSettings.qml" - _generalButton.checked = true - panelActionGroup.current = _generalButton } QGCFlickable { @@ -81,90 +81,24 @@ Rectangle { visible: !ScreenTools.isShortScreen } - QGCButton { - id: _generalButton - height: _buttonHeight - text: qsTr("General") - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "GeneralSettings.qml") { - __rightPanel.source = "GeneralSettings.qml" - } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("Comm Links") - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "LinkSettings.qml") { - __rightPanel.source = "LinkSettings.qml" - } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("Offline Maps") - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "OfflineMap.qml") { - __rightPanel.source = "OfflineMap.qml" - } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("MAVLink") - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "MavlinkSettings.qml") { - __rightPanel.source = "MavlinkSettings.qml" - } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("Console") - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "QGroundControl/Controls/AppMessages.qml") { - __rightPanel.source = "QGroundControl/Controls/AppMessages.qml" - } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("Mock Link") - visible: ScreenTools.isDebug - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "MockLink.qml") { - __rightPanel.source = "MockLink.qml" + Repeater { + model: QGroundControl.corePlugin.settings + QGCButton { + height: _buttonHeight + text: modelData.title + exclusiveGroup: panelActionGroup + onClicked: { + if(__rightPanel.source !== modelData.url) { + __rightPanel.source = modelData.url + } + checked = true } - checked = true - } - } - - QGCButton { - height: _buttonHeight - text: qsTr("Debug") - visible: ScreenTools.isDebug - exclusiveGroup: panelActionGroup - onClicked: { - if(__rightPanel.source != "DebugWindow.qml") { - __rightPanel.source = "DebugWindow.qml" + Component.onCompleted: { + if(_first) { + _first = false + checked = true + } } - checked = true } } } diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 6cd378e1ffeffb050be3ef7b87325019246a8e49..cd40b192776c2ab8e73efa4bd94197813088b5b3 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -54,7 +54,7 @@ #include "AppMessages.h" #endif -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 3f7c31d381b0d9c1b7335b7973a74977d794811f..a8851c7e28ee4d046d53d7594612c2a559eab791 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -33,9 +33,7 @@ #include "UASInterface.h" #include "LogCompressor.h" #include "QGCMAVLinkInspector.h" -#ifndef __mobile__ #include "QGCMAVLinkLogPlayer.h" -#endif #include "MAVLinkDecoder.h" #include "Vehicle.h" #include "QGCDockWidget.h" @@ -117,12 +115,10 @@ signals: #endif //QGC_MOUSE_ENABLED_LINUX public: -#ifndef __mobile__ QGCMAVLinkLogPlayer* getLogPlayer() { return logPlayer; } -#endif protected: void connectCommonActions(); @@ -133,9 +129,7 @@ protected: QSettings settings; QPointer mavlinkDecoder; -#ifndef __mobile__ QGCMAVLinkLogPlayer* logPlayer; -#endif #ifdef QGC_MOUSE_ENABLED_WIN /** @brief 3d Mouse support (WIN only) */ Mouse3DInput* mouseInput; ///< 3dConnexion 3dMouse SDK @@ -164,10 +158,7 @@ protected: private slots: void _closeWindow(void) { close(); } void _vehicleAdded(Vehicle* vehicle); - -#ifndef __mobile__ void _showDockWidgetAction(bool show); -#endif #ifdef UNITTEST_BUILD void _showQmlTestWidget(void); @@ -179,22 +170,17 @@ private: void _openUrl(const QString& url, const QString& errorMessage); -#ifndef __mobile__ QMap _mapName2DockWidget; QMap _mapName2Action; -#endif void _storeCurrentViewState(void); void _loadCurrentViewState(void); - -#ifndef __mobile__ bool _createInnerDockWidget(const QString& widgetName); void _buildCommonWidgets(void); void _hideAllDockWidgets(void); void _showDockWidget(const QString &name, bool show); void _loadVisibleWidgetsSettings(void); void _storeVisibleWidgetsSettings(void); -#endif bool _lowPowerMode; ///< If enabled, QGC reduces the update rates of all widgets bool _showStatusBar; diff --git a/src/ui/QGCMAVLinkLogPlayer.cc b/src/ui/QGCMAVLinkLogPlayer.cc index e3242e1c3f560dc1809cba023be78027f8106fca..22267f376ba0cf3f90a91f90221acefdb55f55f4 100644 --- a/src/ui/QGCMAVLinkLogPlayer.cc +++ b/src/ui/QGCMAVLinkLogPlayer.cc @@ -2,7 +2,7 @@ #include #include "MainWindow.h" -#ifndef __ios__ +#ifndef NO_SERIAL_LINK #include "SerialLink.h" #endif #include "QGCMAVLinkLogPlayer.h" @@ -17,7 +17,7 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(QWidget *parent) : QWidget(parent), _replayLink(NULL), _ui(new Ui::QGCMAVLinkLogPlayer) -{ +{ _ui->setupUi(this); _ui->horizontalLayout->setAlignment(Qt::AlignTop); @@ -26,7 +26,7 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(QWidget *parent) : connect(_ui->playButton, &QPushButton::clicked, this, &QGCMAVLinkLogPlayer::_playPauseToggle); connect(_ui->positionSlider, &QSlider::valueChanged, this, &QGCMAVLinkLogPlayer::_setPlayheadFromSlider); connect(_ui->positionSlider, &QSlider::sliderPressed, this, &QGCMAVLinkLogPlayer::_pause); - + #if 0 // Speed slider is removed from 3.0 release. Too broken to fix. connect(_ui->speedSlider, &QSlider::valueChanged, this, &QGCMAVLinkLogPlayer::_setAccelerationFromSlider); @@ -36,10 +36,10 @@ QGCMAVLinkLogPlayer::QGCMAVLinkLogPlayer(QWidget *parent) : #endif _enablePlaybackControls(false); - + _ui->positionSlider->setMinimum(0); _ui->positionSlider->setMaximum(100); - + } QGCMAVLinkLogPlayer::~QGCMAVLinkLogPlayer() @@ -68,7 +68,7 @@ void QGCMAVLinkLogPlayer::_selectLogFileForPlayback(void) QGCMessageBox::information(tr("Log Replay"), tr("You must close all connections prior to replaying a log.")); return; } - + QString logFilename = QGCFileDialog::getOpenFileName( this, tr("Load MAVLink Log File"), @@ -78,21 +78,21 @@ void QGCMAVLinkLogPlayer::_selectLogFileForPlayback(void) if (logFilename.isEmpty()) { return; } - + LinkInterface* createConnectedLink(LinkConfiguration* config); - + LogReplayLinkConfiguration* linkConfig = new LogReplayLinkConfiguration(QString("Log Replay")); linkConfig->setLogFilename(logFilename); linkConfig->setName(linkConfig->logFilenameShort()); _ui->logFileNameLabel->setText(linkConfig->logFilenameShort()); _replayLink = (LogReplayLink*)qgcApp()->toolbox()->linkManager()->createConnectedLink(linkConfig); - + connect(_replayLink, &LogReplayLink::logFileStats, this, &QGCMAVLinkLogPlayer::_logFileStats); connect(_replayLink, &LogReplayLink::playbackStarted, this, &QGCMAVLinkLogPlayer::_playbackStarted); connect(_replayLink, &LogReplayLink::playbackPaused, this, &QGCMAVLinkLogPlayer::_playbackPaused); connect(_replayLink, &LogReplayLink::playbackPercentCompleteChanged, this, &QGCMAVLinkLogPlayer::_playbackPercentCompleteChanged); connect(_replayLink, &LogReplayLink::disconnected, this, &QGCMAVLinkLogPlayer::_replayLinkDisconnected); - + _ui->positionSlider->setValue(0); #if 0 _ui->speedSlider->setValue(0); @@ -123,9 +123,9 @@ void QGCMAVLinkLogPlayer::_logFileStats(bool logTimestamped, ///< tru { Q_UNUSED(logTimestamped); Q_UNUSED(binaryBaudRate); - + _logDurationSeconds = logDurationSeconds; - + _ui->logStatsLabel->setText(_secondsToHMS(logDurationSeconds)); } @@ -174,9 +174,9 @@ void QGCMAVLinkLogPlayer::_setAccelerationFromSlider(int value) if (_replayLink) { _replayLink->setAccelerationFactor(value); } - + // Factor: -100: 0.01x, 0: 1.0x, 100: 100x - + float accelerationFactor; if (value < 0) { accelerationFactor = 0.01f; @@ -189,7 +189,7 @@ void QGCMAVLinkLogPlayer::_setAccelerationFromSlider(int value) } else { accelerationFactor = 1.0f; } - + _ui->speedLabel->setText(QString("Speed: %1X").arg(accelerationFactor, 5, 'f', 2, '0')); } #endif diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 324c5af6a45138e214a8d3cf4b18f031ffe8eeaa..1d81a84a1834d1ad6f9b8bc87d2a76e346c1af66 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -364,6 +364,7 @@ QGCView { text: qsTr("Virtual Joystick") checked: QGroundControl.virtualTabletJoystick onClicked: QGroundControl.virtualTabletJoystick = checked + visible: QGroundControl.corePlugin.options.enableVirtualJoystick } //----------------------------------------------------------------- //-- Map Providers @@ -433,6 +434,7 @@ QGCView { height: autoConnectLabel.height anchors.margins: ScreenTools.defaultFontPixelWidth anchors.horizontalCenter: parent.horizontalCenter + visible: QGroundControl.corePlugin.options.enableAutoConnectOptions QGCLabel { id: autoConnectLabel text: qsTr("Autoconnect to the following devices:") @@ -443,6 +445,7 @@ QGCView { height: autoConnectCol.height + (ScreenTools.defaultFontPixelHeight * 2) width: qgcView.width * 0.8 color: qgcPal.windowShade + visible: QGroundControl.corePlugin.options.enableAutoConnectOptions anchors.margins: ScreenTools.defaultFontPixelWidth anchors.horizontalCenter: parent.horizontalCenter Column { @@ -494,6 +497,7 @@ QGCView { Item { width: qgcView.width * 0.8 height: videoLabel.height + visible: QGroundControl.corePlugin.options.enableVideoSourceOptions anchors.margins: ScreenTools.defaultFontPixelWidth anchors.horizontalCenter: parent.horizontalCenter QGCLabel { @@ -506,6 +510,7 @@ QGCView { height: videoCol.height + (ScreenTools.defaultFontPixelHeight * 2) width: qgcView.width * 0.8 color: qgcPal.windowShade + visible: QGroundControl.corePlugin.options.enableVideoSourceOptions anchors.margins: ScreenTools.defaultFontPixelWidth anchors.horizontalCenter: parent.horizontalCenter Column { diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index 84dd088118abde59f38eb244b0e003dee3a320ad..2d5670039a8e0c02cfe4f97b8a3aa03e061cfb7f 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -338,6 +338,7 @@ Rectangle { source: "/res/QGCLogoWhite" logo: true onClicked: toolBar.showSettingsView() + visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup } QGCToolBarButton {