diff --git a/QGCCommon.pri b/QGCCommon.pri
index ef571bdfad2efbcba853cd72ed9bb68b6908714d..52d71ef099cf882dd3f386e5adba0cb86a884f77 100644
--- a/QGCCommon.pri
+++ b/QGCCommon.pri
@@ -37,7 +37,6 @@ linux {
DEFINES += __android__
DEFINES += __STDC_LIMIT_MACROS
target.path = $$DESTDIR
- warning("Android build is experimental and not fully functional")
} else {
error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported")
}
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index c4f265c899a866060564ba25fd2caf9f27bd5e5c..98dc921a741789bd76a1d412d8792936169f2081 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -278,7 +278,6 @@ HEADERS += \
src/uas/UAS.h \
src/uas/UASInterface.h \
src/uas/UASMessageHandler.h \
- src/ui/MainWindow.h \
src/ui/toolbar/MainToolBarController.h \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.h \
src/QmlControls/QGCImageProvider.h \
@@ -327,6 +326,7 @@ HEADERS += \
src/ui/linechart/Scrollbar.h \
src/ui/linechart/ScrollZoomer.h \
src/ui/LogReplayLinkConfigurationWidget.h \
+ src/ui/MainWindow.h \
src/ui/MAVLinkDecoder.h \
src/ui/MAVLinkSettingsWidget.h \
src/ui/MultiVehicleDockWidget.h \
@@ -400,7 +400,6 @@ SOURCES += \
src/QmlControls/QmlObjectListModel.cc \
src/uas/UAS.cc \
src/uas/UASMessageHandler.cc \
- src/ui/MainWindow.cc \
src/ui/toolbar/MainToolBarController.cc \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.cc \
src/QmlControls/QGCImageProvider.cc \
@@ -453,6 +452,7 @@ SOURCES += \
src/ui/linechart/LinechartWidget.cc \
src/ui/linechart/Scrollbar.cc \
src/ui/linechart/ScrollZoomer.cc \
+ src/ui/MainWindow.cc \
src/ui/MultiVehicleDockWidget.cc \
src/ui/QGCDataPlot2D.cc \
src/ui/QGCHilConfiguration.cc \
diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index f6e741bfe1ccb35c662e71fdf80427fbe8b3b467..54bf367301f55cbf33133ac224ee6ec76c33e506 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -32,7 +32,9 @@
src/VehicleSetup/JoystickConfig.qml
src/ui/toolbar/MainToolBar.qml
- src/ui/MainWindow.qml
+ src/ui/MainWindowHybrid.qml
+ src/ui/MainWindowInner.qml
+ src/ui/MainWindowNative.qml
src/ui/MainWindowLeftPanel.qml
src/MissionEditor/MissionEditor.qml
src/MissionEditor/MissionEditorHelp.qml
diff --git a/src/AutoPilotPlugins/AutoPilotPlugin.cc b/src/AutoPilotPlugins/AutoPilotPlugin.cc
index d44f95dd62662a25489393f3282822da02ca9ae5..dd92394c3cb0ee9ff59d06d6bec8ef0066120c9a 100644
--- a/src/AutoPilotPlugins/AutoPilotPlugin.cc
+++ b/src/AutoPilotPlugins/AutoPilotPlugin.cc
@@ -26,7 +26,6 @@
#include "AutoPilotPlugin.h"
#include "QGCApplication.h"
-#include "MainWindow.h"
#include "ParameterLoader.h"
#include "UAS.h"
#include "FirmwarePlugin.h"
@@ -65,7 +64,7 @@ void AutoPilotPlugin::_parametersReadyChanged(bool parametersReady)
qgcApp()->showMessage("One or more vehicle components require setup prior to flight.");
// Take the user to Vehicle Summary
- MainWindow::instance()->showSetupView();
+ qgcApp()->showSetupView();
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents);
}
}
diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index 50ee6e73690cfbe184c98bd161f49a533cfd45c5..a0462f68febbbe45c6fbc967e85653525b569d1c 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -43,10 +43,8 @@
#include "QGC.h"
#include "QGCApplication.h"
-#include "MainWindow.h"
#include "GAudioOutput.h"
#include "CmdLineOptParser.h"
-#include "MainWindow.h"
#include "UDPLink.h"
#include "LinkManager.h"
#include "HomePositionManager.h"
@@ -101,6 +99,7 @@
#include "QGCMessageBox.h"
#include "FirmwareUpgradeController.h"
#include "JoystickConfigController.h"
+ #include "MainWindow.h"
#endif
#ifdef QGC_RTLAB_ENABLED
@@ -154,7 +153,12 @@ static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine*, QJSEngine*)
**/
QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
+#ifdef __mobile__
+ : QGuiApplication(argc, argv)
+ , _qmlAppEngine(NULL)
+#else
: QApplication(argc, argv)
+#endif
, _runningUnitTests(unitTesting)
#if defined (__mobile__)
, _styleIsDark(false)
@@ -323,10 +327,12 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
QGCApplication::~QGCApplication()
{
+#ifndef __mobile__
MainWindow* mainWindow = MainWindow::instance();
if (mainWindow) {
delete mainWindow;
}
+#endif
shutdownVideoStreaming();
delete _toolbox;
}
@@ -446,18 +452,23 @@ bool QGCApplication::_initForNormalAppBoot(void)
// Exit main application when last window is closed
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
+#ifdef __mobile__
+ _qmlAppEngine = new QQmlApplicationEngine(this);
+ _qmlAppEngine->addImportPath("qrc:/qml");
+ _qmlAppEngine->rootContext()->setContextProperty("multiVehicleManager", toolbox()->multiVehicleManager());
+ _qmlAppEngine->rootContext()->setContextProperty("joystickManager", toolbox()->joystickManager());
+ _qmlAppEngine->load(QUrl(QStringLiteral("qrc:/qml/MainWindowNative.qml")));
+#else
// Start the user interface
MainWindow* mainWindow = MainWindow::_create();
Q_CHECK_PTR(mainWindow);
-#ifndef __mobile__
// If we made it this far and we still don't have a location. Either the specfied location was invalid
// or we coudn't create a default location. Either way, we need to let the user know and prompt for a new
/// settings.
QString savedFilesLocation = settings.value(_savedFilesLocationKey).toString();
if (savedFilesLocation.isEmpty()) {
showMessage("The location to save files to is invalid, or cannot be written to. Please provide a new one.");
- mainWindow->showSettings();
}
// Now that main window is up check for lost log files
@@ -653,12 +664,10 @@ void QGCApplication::setStyle(bool styleIsDark)
void QGCApplication::_loadCurrentStyle(void)
{
+#ifndef __mobile__
bool success = true;
QString styles;
- // Signal to the user that the app will pause to apply a new stylesheet
- setOverrideCursor(Qt::WaitCursor);
-
// The dark style sheet is the master. Any other selected style sheet just overrides
// the colors of the master sheet.
QFile masterStyleSheet(_darkStyleFile);
@@ -687,11 +696,9 @@ void QGCApplication::_loadCurrentStyle(void)
// Fall back to plastique if we can't load our own
setStyle("plastique");
}
+#endif
QGCPalette::setGlobalTheme(_styleIsDark ? QGCPalette::Dark : QGCPalette::Light);
-
- // Finally restore the cursor before returning.
- restoreOverrideCursor();
}
void QGCApplication::reportMissingParameter(int componentId, const QString& name)
@@ -718,12 +725,64 @@ void QGCApplication::_missingParamsDisplay(void)
showMessage(QString("Parameters missing from firmware: %1.\n\nYou should quit QGroundControl immediately and update your firmware.").arg(params));
}
+QObject* QGCApplication::_rootQmlObject(void)
+{
+#ifdef __mobile__
+ return _qmlAppEngine->rootObjects()[0];
+#else
+ return MainWindow::instance()->rootQmlObject();
+#endif
+}
+
+
void QGCApplication::showMessage(const QString& message)
{
- MainWindow* mainWindow = MainWindow::instance();
- if (mainWindow) {
- mainWindow->showMessage(message);
- } else {
- qWarning() << "showMessage with no mainWindow" << message;
- }
+ QVariant varReturn;
+ QVariant varMessage = QVariant::fromValue(message);
+
+ QMetaObject::invokeMethod(_rootQmlObject(), "showMessage", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varMessage));
+}
+
+void QGCApplication::showFlyView(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showFlyView");
+}
+
+void QGCApplication::showPlanView(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showPlanView");
+}
+
+void QGCApplication::showSetupView(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showSetupView");
+}
+
+void QGCApplication::showWindowCloseMessage(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showWindowCloseMessage");
+}
+
+
+void QGCApplication::_showSetupFirmware(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showSetupFirmware");
+}
+
+void QGCApplication::_showSetupParameters(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showSetupParameters");
+}
+
+void QGCApplication::_showSetupSummary(void)
+{
+ QMetaObject::invokeMethod(_rootQmlObject(), "showSetupSummary");
+}
+
+void QGCApplication::_showSetupVehicleComponent(VehicleComponent* vehicleComponent)
+{
+ QVariant varReturn;
+ QVariant varComponent = QVariant::fromValue(vehicleComponent);
+
+ QMetaObject::invokeMethod(_rootQmlObject(), "showSetupVehicleComponent", Q_RETURN_ARG(QVariant, varReturn), Q_ARG(QVariant, varComponent));
}
diff --git a/src/QGCApplication.h b/src/QGCApplication.h
index 3d0e62d05e51ccf7b4baa279b4ba8ec072c1ebda..49280395093720f22d28a1ea655f1731a0fd6ba3 100644
--- a/src/QGCApplication.h
+++ b/src/QGCApplication.h
@@ -64,7 +64,12 @@ class QGCToolbox;
* the central management unit of the groundstation application.
*
**/
-class QGCApplication : public QApplication
+class QGCApplication : public
+#ifdef __mobile__
+ QGuiApplication // Native Qml based application
+#else
+ QApplication // QtWidget based application
+#endif
{
Q_OBJECT
@@ -138,6 +143,12 @@ public slots:
/// You can connect to this slot to show a critical message box from a different thread.
void criticalMessageBoxOnMainThread(const QString& title, const QString& msg);
+ void showFlyView(void);
+ void showPlanView(void);
+ void showSetupView(void);
+
+ void showWindowCloseMessage(void);
+
#ifndef __mobile__
/// Save the specified Flight Data Log
void saveTempFlightDataLogOnMainThread(QString tempLogfile);
@@ -166,6 +177,11 @@ public:
/// @brief Intialize the application for normal application boot. Or in other words we are not going to run
/// unit tests. Although public should only be called by main.
bool _initForUnitTests(void);
+
+ void _showSetupFirmware(void);
+ void _showSetupParameters(void);
+ void _showSetupSummary(void);
+ void _showSetupVehicleComponent(VehicleComponent* vehicleComponent);
static QGCApplication* _app; ///< Our own singleton. Should be reference directly by qgcApp
@@ -174,6 +190,11 @@ private slots:
private:
void _loadCurrentStyle(void);
+ QObject* _rootQmlObject(void);
+
+#ifdef __mobile__
+ QQmlApplicationEngine* _qmlAppEngine;
+#endif
static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
diff --git a/src/QmlControls/ParameterEditorController.cc b/src/QmlControls/ParameterEditorController.cc
index 364e14cb479d521a03cff2b999525dcdb63c4cb9..6f441ec3ce621f7cd0a3bc5053009352405a6f5b 100644
--- a/src/QmlControls/ParameterEditorController.cc
+++ b/src/QmlControls/ParameterEditorController.cc
@@ -26,12 +26,12 @@
#include "ParameterEditorController.h"
#include "AutoPilotPluginManager.h"
-#include "MainWindow.h"
#include "QGCApplication.h"
#ifndef __mobile__
#include "QGCFileDialog.h"
#include "QGCMapRCToParamDialog.h"
+#include "MainWindow.h"
#endif
/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens.
diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc
index 5feb34ae9c9da0db724e26c42744f5e6ce4ea4bf..67e64834311cf18a3d7b907d5d0d21af1b895e7b 100644
--- a/src/QmlControls/QGroundControlQmlGlobal.cc
+++ b/src/QmlControls/QGroundControlQmlGlobal.cc
@@ -138,12 +138,6 @@ void QGroundControlQmlGlobal::setIsAudioMuted(bool muted)
emit isAudioMutedChanged(muted);
}
-void QGroundControlQmlGlobal::setIsLowPowerMode(bool low)
-{
- MainWindow::instance()->enableLowPowerMode(low);
- emit isLowPowerModeChanged(low);
-}
-
void QGroundControlQmlGlobal::setIsSaveLogPrompt(bool prompt)
{
qgcApp()->setPromptFlightDataSave(prompt);
diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h
index d5436982fa30b2a853ed47472c6ffc6d4442612c..ab7057ff006373a2f3db458b769849e4a1c7622c 100644
--- a/src/QmlControls/QGroundControlQmlGlobal.h
+++ b/src/QmlControls/QGroundControlQmlGlobal.h
@@ -30,7 +30,6 @@
#include
#include "QGCApplication.h"
-#include "MainWindow.h"
#include "LinkManager.h"
#include "HomePositionManager.h"
#include "FlightMapSettings.h"
@@ -63,7 +62,6 @@ public:
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 isLowPowerMode READ isLowPowerMode WRITE setIsLowPowerMode NOTIFY isLowPowerModeChanged)
Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged)
Q_PROPERTY(bool isSaveLogPromptNotArmed READ isSaveLogPromptNotArmed WRITE setIsSaveLogPromptNotArmed NOTIFY isSaveLogPromptNotArmedChanged)
Q_PROPERTY(bool isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged)
@@ -99,7 +97,6 @@ public:
bool isDarkStyle () { return qgcApp()->styleIsDark(); }
bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); }
- bool isLowPowerMode () { return MainWindow::instance()->lowPowerModeEnabled(); }
bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); }
bool isSaveLogPromptNotArmed () { return qgcApp()->promptFlightDataSaveNotArmed(); }
bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
@@ -112,7 +109,6 @@ public:
void setIsDarkStyle (bool dark);
void setIsAudioMuted (bool muted);
- void setIsLowPowerMode (bool low);
void setIsSaveLogPrompt (bool prompt);
void setIsSaveLogPromptNotArmed (bool prompt);
void setIsHeartBeatEnabled (bool enable);
@@ -123,7 +119,6 @@ public:
signals:
void isDarkStyleChanged (bool dark);
void isAudioMutedChanged (bool muted);
- void isLowPowerModeChanged (bool lowPower);
void isSaveLogPromptChanged (bool prompt);
void isSaveLogPromptNotArmedChanged (bool prompt);
void isHeartBeatEnabledChanged (bool enabled);
diff --git a/src/QmlControls/ScreenToolsController.cc b/src/QmlControls/ScreenToolsController.cc
index 9380bf7cf0052f8a50c430cecaa520675022eef1..9717284d7ee8228c9dbd055a2e9a84c9df2cd4ba 100644
--- a/src/QmlControls/ScreenToolsController.cc
+++ b/src/QmlControls/ScreenToolsController.cc
@@ -25,7 +25,6 @@
/// @author Gus Grubba
#include "ScreenToolsController.h"
-#include "MainWindow.h"
#ifdef Q_OS_WIN
const double ScreenToolsController::_defaultFontPixelSizeRatio = 1.0;
diff --git a/src/VehicleSetup/SetupViewTest.cc b/src/VehicleSetup/SetupViewTest.cc
index 649d9a30d9b5373d2617047c32d4b39e1b909395..5da316bd45dbd533b7aa42a1ac64638e77f0fb36 100644
--- a/src/VehicleSetup/SetupViewTest.cc
+++ b/src/VehicleSetup/SetupViewTest.cc
@@ -39,25 +39,25 @@ void SetupViewTest::_clickThrough_test(void)
_createMainWindow();
// Switch to the Setup view
- _mainWindow->showSetupView();
+ qgcApp()->showSetupView();
QTest::qWait(1000);
// Click through fixed buttons
qDebug() << "Showing firmware";
- _mainWindow->showSetupFirmware();
+ qgcApp()->_showSetupFirmware();
QTest::qWait(1000);
qDebug() << "Showing parameters";
- _mainWindow->showSetupParameters();
+ qgcApp()->_showSetupParameters();
QTest::qWait(1000);
qDebug() << "Showing summary";
- _mainWindow->showSetupSummary();
+ qgcApp()->_showSetupSummary();
QTest::qWait(1000);
const QVariantList& components = autopilot->vehicleComponents();
foreach(QVariant varComponent, components) {
VehicleComponent* component = qobject_cast(qvariant_cast(varComponent));
qDebug() << "Showing" << component->name();
- _mainWindow->showSetupVehicleComponent(component);
+ qgcApp()->_showSetupVehicleComponent(component);
QTest::qWait(1000);
}
diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc
index 0e12c749f747e33c5f6e25806d449caf0adfb7f3..a023ad559118aca33f84170bb21b5987f232a13b 100644
--- a/src/comm/LinkManager.cc
+++ b/src/comm/LinkManager.cc
@@ -38,7 +38,6 @@ This file is part of the QGROUNDCONTROL project
#endif
#include "LinkManager.h"
-#include "MainWindow.h"
#include "QGCApplication.h"
#include "QGCApplication.h"
#include "UDPLink.h"
@@ -189,14 +188,11 @@ void LinkManager::_addLink(LinkInterface* link)
emit newLink(link);
}
- // MainWindow may be around when doing things like running unit tests
- if (MainWindow::instance()) {
- connect(link, &LinkInterface::communicationError, _app, &QGCApplication::criticalMessageBoxOnMainThread);
- }
+ connect(link, &LinkInterface::communicationError, _app, &QGCApplication::criticalMessageBoxOnMainThread);
+ connect(link, &LinkInterface::bytesReceived, _mavlinkProtocol, &MAVLinkProtocol::receiveBytes);
+ connect(link, &LinkInterface::connected, _mavlinkProtocol, &MAVLinkProtocol::linkConnected);
+ connect(link, &LinkInterface::disconnected, _mavlinkProtocol, &MAVLinkProtocol::linkDisconnected);
- connect(link, &LinkInterface::bytesReceived, _mavlinkProtocol, &MAVLinkProtocol::receiveBytes);
- connect(link, &LinkInterface::connected, _mavlinkProtocol, &MAVLinkProtocol::linkConnected);
- connect(link, &LinkInterface::disconnected, _mavlinkProtocol, &MAVLinkProtocol::linkDisconnected);
_mavlinkProtocol->resetMetadataForLink(link);
connect(link, &LinkInterface::connected, this, &LinkManager::_linkConnected);
diff --git a/src/comm/LinkManager.h b/src/comm/LinkManager.h
index ff1b1a841569783bed2a03f67f09743cb82a2e22..473a2067987f8d1dd7794a4f92b52d86db5d679e 100644
--- a/src/comm/LinkManager.h
+++ b/src/comm/LinkManager.h
@@ -169,7 +169,7 @@ public:
void _addLink(LinkInterface* link);
// Called to signal app shutdown. Disconnects all links while turning off auto-connect.
- void shutdown(void);
+ Q_INVOKABLE void shutdown(void);
#ifdef QT_DEBUG
// Only used by unit test tp restart after a shutdown
diff --git a/src/main.cc b/src/main.cc
index 12ab5816add68a0c265447f73ee6b259e95bf9e9..d377c9d76c84f3a0a06af9a104c5801fb1cd2aad 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -34,7 +34,6 @@ This file is part of the QGROUNDCONTROL project
#include
#include "QGCApplication.h"
-#include "MainWindow.h"
#ifndef __mobile__
#include "QGCSerialPortInfo.h"
diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc
index 39089fb4094700bb06872007aa768a14c3190aed..b577618de8a9f95c626e5a1abea7183b8b98cb51 100644
--- a/src/ui/MainWindow.cc
+++ b/src/ui/MainWindow.cc
@@ -159,7 +159,7 @@ MainWindow::MainWindow()
_mainQmlWidgetHolder->setVisible(true);
_mainQmlWidgetHolder->setContextPropertyObject("controller", this);
- _mainQmlWidgetHolder->setSource(QUrl::fromUserInput("qrc:qml/MainWindow.qml"));
+ _mainQmlWidgetHolder->setSource(QUrl::fromUserInput("qrc:qml/MainWindowHybrid.qml"));
// Image provider
QQuickImageProvider* pImgProvider = dynamic_cast(qgcApp()->toolbox()->imageProvider());
@@ -436,7 +436,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
{
// Disallow window close if there are active connections
if (qgcApp()->toolbox()->multiVehicleManager()->vehicles()->count()) {
- emit showWindowCloseMessage();
+ qgcApp()->showWindowCloseMessage();
event->ignore();
return;
}
@@ -548,12 +548,12 @@ void MainWindow::connectCommonActions()
connect(_ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
// Views actions
- connect(_ui.actionFlight, &QAction::triggered, this, &MainWindow::showFlyView);
- connect(_ui.actionPlan, &QAction::triggered, this, &MainWindow::showPlanView);
- connect(_ui.actionSetup, &QAction::triggered, this, &MainWindow::showSetupView);
- connect(_ui.actionFlight, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
- connect(_ui.actionPlan, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
- connect(_ui.actionSetup, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
+ connect(_ui.actionFlight, &QAction::triggered, qgcApp(), &QGCApplication::showFlyView);
+ connect(_ui.actionPlan, &QAction::triggered, qgcApp(), &QGCApplication::showPlanView);
+ connect(_ui.actionSetup, &QAction::triggered, qgcApp(), &QGCApplication::showSetupView);
+ connect(_ui.actionFlight, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
+ connect(_ui.actionPlan, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
+ connect(_ui.actionSetup, &QAction::triggered, this, &MainWindow::handleActiveViewActionState);
// Connect internal actions
connect(qgcApp()->toolbox()->multiVehicleManager(), &MultiVehicleManager::vehicleAdded, this, &MainWindow::_vehicleAdded);
@@ -670,7 +670,7 @@ void MainWindow::_storeVisibleWidgetsSettings(void)
}
#endif
-void MainWindow::showMessage(const QString message)
+QObject* MainWindow::rootQmlObject(void)
{
- emit showCriticalMessage(message);
+ return _mainQmlWidgetHolder->getRootObject();
}
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index 6f9b103c7bd9d0c7edec4b7ae0374d06fc74dde2..4077f05dda570ed9867c662785a69deaea22e69e 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -31,6 +31,10 @@ This file is part of the QGROUNDCONTROL project
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_
+#ifdef __mobile__
+#error Should not be include in mobile build
+#endif
+
#include
#include
#include
@@ -91,12 +95,12 @@ public:
/// @brief Saves the last used connection
void saveLastUsedConnection(const QString connection);
- /// @brief Show message in lower message window
- void showMessage(const QString message);
-
// Called from MainWindow.qml when the user accepts the window close dialog
Q_INVOKABLE void acceptWindowClose(void);
+ /// @return Root qml object of main window QML
+ QObject* rootQmlObject(void);
+
public slots:
#ifndef __mobile__
void showSettings();
@@ -140,20 +144,6 @@ protected slots:
void handleActiveViewActionState(bool triggered);
signals:
- // Signals the Qml to show the specified view
- void showFlyView(void);
- void showPlanView(void);
- void showSetupView(void);
-
- void showCriticalMessage(const QString& message);
- void showWindowCloseMessage(void);
-
- // These are used for unit testing
- void showSetupFirmware(void);
- void showSetupParameters(void);
- void showSetupSummary(void);
- void showSetupVehicleComponent(VehicleComponent* vehicleComponent);
-
void initStatusChanged(const QString& message, int alignment, const QColor &color);
/** Emitted when any value changes from any source */
void valueChanged(const int uasId, const QString& name, const QString& unit, const QVariant& value, const quint64 msec);
@@ -173,6 +163,7 @@ public:
return logPlayer;
}
#endif
+
protected:
void connectCommonActions();
diff --git a/src/ui/MainWindowHybrid.qml b/src/ui/MainWindowHybrid.qml
new file mode 100644
index 0000000000000000000000000000000000000000..aa8b206d4b9c8828a0344ecb3be42770e4e68e52
--- /dev/null
+++ b/src/ui/MainWindowHybrid.qml
@@ -0,0 +1,75 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 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 .
+
+======================================================================*/
+
+import QtQuick 2.5
+import QtQuick.Controls 1.2
+
+import QGroundControl.Controls 1.0
+
+/// Native QML top level window
+Item {
+ function showFlyView() {
+ mainWindowInner.item.showFlyView()
+ }
+
+ function showPlanView() {
+ mainWindowInner.item.showPlanView()
+ }
+
+ function showSetupView() {
+ mainWindowInner.item.showSetupView()
+ }
+
+ function showWindowCloseMessage() {
+ mainWindowInner.item.showWindowCloseMessage()
+ }
+
+ // The following are use for unit testing only
+
+ function showSetupFirmware() {
+ mainWindowInner.item.showSetupFirmware()
+ }
+
+ function showSetupParameters() {
+ mainWindowInner.item.showSetupParameters()
+ }
+
+ function showSetupSummary() {
+ mainWindowInner.item.showSetupSummary()
+ }
+
+ function showSetupVehicleComponent(vehicleComponent) {
+ mainWindowInner.item.showSetupVehicleComponent(vehicleComponent)
+ }
+
+ function showMessage(message) {
+ mainWindowInner.item.showMessage(message)
+ }
+
+ Loader {
+ id: mainWindowInner
+ anchors.fill: parent
+ source: "MainWindowInner.qml"
+ }
+}
+
diff --git a/src/ui/MainWindow.qml b/src/ui/MainWindowInner.qml
similarity index 87%
rename from src/ui/MainWindow.qml
rename to src/ui/MainWindowInner.qml
index 1c373d4faceac3a08bb568ac67a32d78b72a40f1..40ed4232a493c52dfc1d465b2e432700e5030026 100644
--- a/src/ui/MainWindow.qml
+++ b/src/ui/MainWindowInner.qml
@@ -33,9 +33,9 @@ import QGroundControl.FlightDisplay 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0
-/// Qml for MainWindow
+/// Inner common QML for MainWindow
Item {
- id: mainWindow
+ id: mainWindow
readonly property string _planViewSource: "MissionEditor.qml"
readonly property string _setupViewSource: "SetupView.qml"
@@ -57,53 +57,62 @@ Item {
property var activeVehicle: multiVehicleManager.activeVehicle
property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : ""
- Connections {
-
- target: controller
-
- onShowFlyView: {
- if(currentPopUp) {
- currentPopUp.close()
- }
- flightView.visible = true
- setupViewLoader.visible = false
- planViewLoader.visible = false
+ function showFlyView() {
+ if(currentPopUp) {
+ currentPopUp.close()
}
+ flightView.visible = true
+ setupViewLoader.visible = false
+ planViewLoader.visible = false
+ toolbar.checkFlyButton()
+ }
- onShowPlanView: {
- if(currentPopUp) {
- currentPopUp.close()
- }
- if (planViewLoader.source != _planViewSource) {
- planViewLoader.source = _planViewSource
- }
- flightView.visible = false
- setupViewLoader.visible = false
- planViewLoader.visible = true
+ function showPlanView() {
+ if(currentPopUp) {
+ currentPopUp.close()
}
+ if (planViewLoader.source != _planViewSource) {
+ planViewLoader.source = _planViewSource
+ }
+ flightView.visible = false
+ setupViewLoader.visible = false
+ planViewLoader.visible = true
+ toolBar.checkPlanButton()
+ }
- onShowSetupView: {
- if(currentPopUp) {
- currentPopUp.close()
- }
- if (setupViewLoader.source != _setupViewSource) {
- setupViewLoader.source = _setupViewSource
- }
- flightView.visible = false
- setupViewLoader.visible = true
- planViewLoader.visible = false
+ function showSetupView() {
+ if(currentPopUp) {
+ currentPopUp.close()
+ }
+ if (setupViewLoader.source != _setupViewSource) {
+ setupViewLoader.source = _setupViewSource
}
+ flightView.visible = false
+ setupViewLoader.visible = true
+ planViewLoader.visible = false
+ toolBar.checkSetupButton()
+ }
- onShowCriticalMessage: showCriticalMessage(message)
+ function showWindowCloseMessage() {
+ windowCloseDialog.open()
+ }
+
+ // The following are use for unit testing only
+
+ function showSetupFirmware() {
+ setupViewLoader.item.showFirmwarePanel()
+ }
- onShowWindowCloseMessage: windowCloseDialog.open()
+ function showSetupParameters() {
+ setupViewLoader.item.showParametersPanel()
+ }
- // The following are use for unit testing only
+ function showSetupSummary() {
+ setupViewLoader.item.showSummaryPanel()
+ }
- onShowSetupFirmware: setupViewLoader.item.showFirmwarePanel()
- onShowSetupParameters: setupViewLoader.item.showParametersPanel()
- onShowSetupSummary: setupViewLoader.item.showSummaryPanel()
- onShowSetupVehicleComponent: setupViewLoader.item.showVehicleComponentPanel(vehicleComponent)
+ function showSetupVehicleComponent(vehicleComponent) {
+ setupViewLoader.item.showVehicleComponentPanel(vehicleComponent)
}
//-- Detect tablet position
@@ -129,7 +138,7 @@ Item {
property var messageQueue: []
- function showCriticalMessage(message) {
+ function showMessage(message) {
if(criticalMmessageArea.visible) {
messageQueue.push(message)
} else {
@@ -209,7 +218,7 @@ Item {
//-- Left Settings Menu
Loader {
id: leftPanel
- anchors.fill: mainWindow
+ anchors.fill: parent
visible: false
z: QGroundControl.zOrderTopMost + 100
}
@@ -226,9 +235,14 @@ Item {
opaqueBackground: leftPanel.visible
isBackgroundDark: flightView.isBackgroundDark
z: QGroundControl.zOrderTopMost
+
Component.onCompleted: {
leftPanel.source = "MainWindowLeftPanel.qml"
}
+
+ onShowSetupView: mainWindow.showSetupView()
+ onShowPlanView: mainWindow.showPlanView()
+ onShowFlyView: mainWindow.showFlyView()
}
FlightDisplayView {
@@ -420,5 +434,5 @@ Item {
}
}
}
-
}
+
diff --git a/src/ui/MainWindowNative.qml b/src/ui/MainWindowNative.qml
new file mode 100644
index 0000000000000000000000000000000000000000..26399ab7475b6c1520515474b577b5da34fe569e
--- /dev/null
+++ b/src/ui/MainWindowNative.qml
@@ -0,0 +1,90 @@
+/*=====================================================================
+
+QGroundControl Open Source Ground Control Station
+
+(c) 2009, 2015 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 .
+
+======================================================================*/
+
+import QtQuick 2.5
+import QtQuick.Window 2.2
+
+import QGroundControl 1.0
+
+/// Native QML top level window
+Window {
+ visible: true
+
+ onClosing: {
+ // Disallow window close if there are active connections
+ if (QGroundControl.multiVehicleManager.activeVehicle) {
+ showWindowCloseMessage()
+ close.accepted = false
+ return
+ }
+
+ // We still need to shutdown LinkManager even though no active connections so that we don't get any
+ // more auto-connect links during shutdown.
+ QGroundControl.linkManager.shutdown();
+ }
+
+ function showFlyView() {
+ mainWindowInner.item.showFlyView()
+ }
+
+ function showPlanView() {
+ mainWindowInner.item.showPlanView()
+ }
+
+ function showSetupView() {
+ mainWindowInner.item.showSetupView()
+ }
+
+ function showWindowCloseMessage() {
+ mainWindowInner.item.showWindowCloseMessage()
+ }
+
+ // The following are use for unit testing only
+
+ function showSetupFirmware() {
+ mainWindowInner.item.showSetupFirmware()
+ }
+
+ function showSetupParameters() {
+ mainWindowInner.item.showSetupParameters()
+ }
+
+ function showSetupSummary() {
+ mainWindowInner.item.showSetupSummary()
+ }
+
+ function showSetupVehicleComponent(vehicleComponent) {
+ mainWindowInner.showSetupVehicleComponent(vehicleComponent)
+ }
+
+ function showMessage(message) {
+ mainWindowInner.item.showMessage(message)
+ }
+
+ Loader {
+ id: mainWindowInner
+ anchors.fill: parent
+ source: "MainWindowInner.qml"
+ }
+}
+
diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml
index 5ad4f90e17bc1bdff9e43853889f46eeeaa83449..d4a92183cfb1918e7d7a4b729b66aa5e8dc3f6d2 100644
--- a/src/ui/preferences/GeneralSettings.qml
+++ b/src/ui/preferences/GeneralSettings.qml
@@ -81,15 +81,6 @@ Rectangle {
}
}
//-----------------------------------------------------------------
- //-- Low power mode
- QGCCheckBox {
- text: "Enable low power mode"
- checked: QGroundControl.isLowPowerMode
- onClicked: {
- QGroundControl.isLowPowerMode = checked
- }
- }
- //-----------------------------------------------------------------
//-- Prompt Save Log
QGCCheckBox {
id: promptSaveLog
diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml
index 37b9756886eb954cd6ada0266830611001965205..ab6589567c1d89ecc3103c2c1756b5212222d5bd 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -145,8 +145,24 @@ Rectangle {
readonly property var colorBlue: "#636efe"
readonly property var colorWhite: "#ffffff"
+ signal showSetupView()
+ signal showPlanView()
+ signal showFlyView()
+
MainToolBarController { id: _controller }
+ function checkSetupButton() {
+ setupButton.checked = true
+ }
+
+ function checkPlanButton() {
+ planButton.checked = true
+ }
+
+ function checkFlyButton() {
+ flyButton.checked = true
+ }
+
function getBatteryColor() {
if(activeVehicle) {
if(activeVehicle.batteryPercent > 75) {
@@ -193,13 +209,6 @@ Rectangle {
flyButton.checked = true
}
- Connections {
- target: controller
- onShowFlyView: { flyButton.checked = true }
- onShowPlanView: { planButton.checked = true }
- onShowSetupView:{ setupButton.checked = true }
- }
-
//---------------------------------------------
// GPS Info
Component {
@@ -496,9 +505,7 @@ Rectangle {
height: mainWindow.tbCellHeight
exclusiveGroup: mainActionGroup
source: "/qmlimages/Gears.svg"
- onClicked: {
- _controller.onSetupView();
- }
+ onClicked: toolBar.showSetupView()
}
Rectangle {
@@ -513,9 +520,7 @@ Rectangle {
height: mainWindow.tbCellHeight
exclusiveGroup: mainActionGroup
source: "/qmlimages/Plan.svg"
- onClicked: {
- _controller.onPlanView();
- }
+ onClicked: toolBar.showPlanView()
}
Rectangle {
@@ -530,9 +535,7 @@ Rectangle {
height: mainWindow.tbCellHeight
exclusiveGroup: mainActionGroup
source: "/qmlimages/PaperPlane.svg"
- onClicked: {
- _controller.onFlyView();
- }
+ onClicked: toolBar.showFlyView()
}
Rectangle {
diff --git a/src/ui/toolbar/MainToolBarController.cc b/src/ui/toolbar/MainToolBarController.cc
index bab5ff613d4cd9efdf18a64fb17f6927595c0a36..5af18e7cc2b076300e6f2b8d346b9b73a92dbc9f 100644
--- a/src/ui/toolbar/MainToolBarController.cc
+++ b/src/ui/toolbar/MainToolBarController.cc
@@ -32,7 +32,6 @@ This file is part of the QGROUNDCONTROL project
#include "MainToolBarController.h"
#include "ScreenToolsController.h"
-#include "MainWindow.h"
#include "UASMessageView.h"
#include "UASMessageHandler.h"
#include "QGCApplication.h"
@@ -60,21 +59,6 @@ MainToolBarController::~MainToolBarController()
}
-void MainToolBarController::onSetupView()
-{
- MainWindow::instance()->showSetupView();
-}
-
-void MainToolBarController::onPlanView()
-{
- MainWindow::instance()->showPlanView();
-}
-
-void MainToolBarController::onFlyView()
-{
- MainWindow::instance()->showFlyView();
-}
-
void MainToolBarController::_activeVehicleChanged(Vehicle* vehicle)
{
// Disconnect the previous one (if any)
diff --git a/src/ui/toolbar/MainToolBarController.h b/src/ui/toolbar/MainToolBarController.h
index 9977eacd7d057807b99e7061b608e66425a997b4..6b6bc5508f7a0f233fea9bfca26a40129778115c 100644
--- a/src/ui/toolbar/MainToolBarController.h
+++ b/src/ui/toolbar/MainToolBarController.h
@@ -50,10 +50,6 @@ public:
MainToolBarController(QObject* parent = NULL);
~MainToolBarController();
- Q_INVOKABLE void onSetupView();
- Q_INVOKABLE void onPlanView();
- Q_INVOKABLE void onFlyView();
-
Q_PROPERTY(double height MEMBER _toolbarHeight NOTIFY heightChanged)
Q_PROPERTY(float progressBarValue MEMBER _progressBarValue NOTIFY progressBarValueChanged)
Q_PROPERTY(int telemetryRRSSI READ telemetryRRSSI NOTIFY telemetryRRSSIChanged)