diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 659bfbf3182c99c68de4c1b65216fdf168b63d64..98caae7b895ffad70e97a5607a374156199f76e8 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -282,6 +282,7 @@ HEADERS += \ src/QGCQuickWidget.h \ src/QGCTemporaryFile.h \ src/QGCToolbox.h \ + src/QmlControls/AppMessages.h \ src/QmlControls/CoordinateVector.h \ src/QmlControls/MavlinkQmlSingleton.h \ src/QmlControls/ParameterEditorController.h \ @@ -297,7 +298,7 @@ HEADERS += \ src/AutoPilotPlugins/APM/APMAirframeLoader.h \ src/QmlControls/QGCImageProvider.h \ src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.h \ - src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h + src/QtLocationPlugin/QMLControl/QGCMapEngineManager.h \ DebugBuild { HEADERS += \ @@ -370,7 +371,6 @@ HEADERS += \ src/ViewWidgets/LogDownload.h \ src/ViewWidgets/LogDownloadController.h \ src/ViewWidgets/ViewWidgetController.h \ - src/ViewWidgets/AppMessagesDialog.h } iOSBuild { @@ -424,6 +424,7 @@ SOURCES += \ src/QGCTemporaryFile.cc \ src/QGCToolbox.cc \ src/QGCGeo.cc \ + src/QmlControls/AppMessages.cc \ src/QmlControls/CoordinateVector.cc \ src/QmlControls/ParameterEditorController.cc \ src/QmlControls/ScreenToolsController.cc \ @@ -437,7 +438,7 @@ SOURCES += \ src/AutoPilotPlugins/APM/APMAirframeLoader.cc \ src/QmlControls/QGCImageProvider.cc \ src/AutoPilotPlugins/APM/APMRemoteParamsDownloader.cc \ - src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc + src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc \ DebugBuild { SOURCES += \ @@ -502,8 +503,7 @@ SOURCES += \ src/ViewWidgets/CustomCommandWidgetController.cc \ src/ViewWidgets/LogDownload.cc \ src/ViewWidgets/LogDownloadController.cc \ - src/ViewWidgets/ViewWidgetController.cc \ - src/ViewWidgets/AppMessagesDialog.cc + src/ViewWidgets/ViewWidgetController.cc } # diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 1e00af6bb08e47504e72b738fda2c0647041c274..dcabab456577ab7aa7fc305a9c68060ca545e3cb 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -12,7 +12,6 @@ src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml src/ViewWidgets/CustomCommandWidget.qml src/ViewWidgets/LogDownload.qml - src/ViewWidgets/AppMessagesDialog.qml src/VehicleSetup/FirmwareUpgrade.qml src/FlightDisplay/FlightDisplayView.qml src/AutoPilotPlugins/PX4/PX4FlightModes.qml @@ -86,6 +85,7 @@ src/QmlControls/SubMenuButton.qml src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml + src/QmlControls/AppMessages.qml src/ViewWidgets/ViewWidget.qml src/MissionEditor/SimpleItemEditor.qml diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index ff6fc2b7fb40a2ed026a788caaebaa4b9008dbd8..4fb148412114354b337c0b8b6d50232eb51e35ec 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -100,6 +100,7 @@ #include "LogDownloadController.h" #include "PX4AirframeLoader.h" #include "ValuesWidgetController.h" +#include "AppMessages.h" #ifndef __ios__ #include "SerialLink.h" @@ -484,6 +485,7 @@ bool QGCApplication::_initForNormalAppBoot(void) _qmlAppEngine = new QQmlApplicationEngine(this); _qmlAppEngine->addImportPath("qrc:/qml"); _qmlAppEngine->rootContext()->setContextProperty("joystickManager", toolbox()->joystickManager()); + _qmlAppEngine->rootContext()->setContextProperty("debugMessageModel", &AppMessages::getModel()); _qmlAppEngine->load(QUrl(QStringLiteral("qrc:/qml/MainWindowNative.qml"))); #else // Start the user interface diff --git a/src/ViewWidgets/AppMessagesDialog.cc b/src/QmlControls/AppMessages.cc similarity index 82% rename from src/ViewWidgets/AppMessagesDialog.cc rename to src/QmlControls/AppMessages.cc index 4b908fd51b7d00b790bcf42c67e747d419c955f6..31fac6bc88f15ee238d2be873edc4e3f8fd35b61 100644 --- a/src/ViewWidgets/AppMessagesDialog.cc +++ b/src/QmlControls/AppMessages.cc @@ -21,7 +21,7 @@ This file is part of the QGROUNDCONTROL project ======================================================================*/ -#include "AppMessagesDialog.h" +#include "AppMessages.h" #include #include @@ -46,18 +46,12 @@ static void msgHandler(QtMsgType type, const QMessageLogContext &context, const if( type == QtFatalMsg ) abort(); } - -AppMessagesDialog::AppMessagesDialog(const QString &title, QAction *action, QWidget *parent) : - QGCQmlWidgetHolder(title, action, parent) +void AppMessages::installHandler() { - resize(800, 600); - setContextPropertyObject("debugMessageModel", &debug_strings); - setSource(QUrl::fromUserInput("qrc:/qml/AppMessagesDialog.qml")); - loadSettings(); + old_handler = qInstallMessageHandler(msgHandler); } -void AppMessagesDialog::installHandler() +QStringListModel& AppMessages::getModel() { - old_handler = qInstallMessageHandler(msgHandler); + return debug_strings; } - diff --git a/src/ViewWidgets/AppMessagesDialog.h b/src/QmlControls/AppMessages.h similarity index 85% rename from src/ViewWidgets/AppMessagesDialog.h rename to src/QmlControls/AppMessages.h index e43b9f130683b6ea5a98b961d249fcb2a367f3b6..71704e664d703063f68e283ce502ecbedab4ae2b 100644 --- a/src/ViewWidgets/AppMessagesDialog.h +++ b/src/QmlControls/AppMessages.h @@ -23,15 +23,11 @@ This file is part of the QGROUNDCONTROL project #pragma once -#include "QGCQmlWidgetHolder.h" - class QStringListModel; -class AppMessagesDialog : public QGCQmlWidgetHolder +class AppMessages { - Q_OBJECT public: - AppMessagesDialog(const QString& title, QAction* action, QWidget *parent = 0); - static void installHandler(); + static QStringListModel& getModel(); }; diff --git a/src/ViewWidgets/AppMessagesDialog.qml b/src/QmlControls/AppMessages.qml similarity index 100% rename from src/ViewWidgets/AppMessagesDialog.qml rename to src/QmlControls/AppMessages.qml diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index fe2a7457db0c7c105b3c115e2321bd89ab5b5afc..64990fbe04a75f6a7a2206a8f8dd9380f4f95492 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -1,5 +1,6 @@ Module QGroundControl.Controls +AppMessages 1.0 AppMessages.qml ClickableColor 1.0 ClickableColor.qml DropButton 1.0 DropButton.qml ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml diff --git a/src/main.cc b/src/main.cc index abbbd1eee3fa39ce4795de2222abefe9329dc49c..e8877d62c34ab4c0b5f8e7f7953ce0f01858b09a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -42,7 +42,7 @@ This file is part of the QGROUNDCONTROL project #ifndef __mobile__ #include "QGCSerialPortInfo.h" - #include "AppMessagesDialog.h" + #include "AppMessages.h" #endif #ifdef QT_DEBUG @@ -117,7 +117,7 @@ int main(int argc, char *argv[]) #ifndef __mobile__ // install the message handler - AppMessagesDialog::installHandler(); + AppMessages::installHandler(); //-- Test for another instance already running. If that's the case, we simply exit. QHostAddress host("127.0.0.1"); diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index e6f42e6fffec0fb288a000a53aa814fad8c87305..d843ff5fed8092b806603bcf3d6fec4ad0469542 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -66,7 +66,7 @@ This file is part of the QGROUNDCONTROL project #include "UASInfoWidget.h" #include "HILDockWidget.h" #include "LogDownload.h" -#include "AppMessagesDialog.h" +#include "AppMessages.h" #endif #ifndef __ios__ @@ -89,8 +89,7 @@ enum DockWidgetTypes { INFO_VIEW, HIL_CONFIG, ANALYZE, - LOG_DOWNLOAD, - DEBUG_MESSAGES + LOG_DOWNLOAD }; static const char *rgDockWidgetNames[] = { @@ -101,8 +100,7 @@ static const char *rgDockWidgetNames[] = { "Info View", "HIL Config", "Analyze", - "Log Download", - "Debug Messages" + "Log Download" }; #define ARRAY_SIZE(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0])) @@ -167,6 +165,7 @@ MainWindow::MainWindow() QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); _mainQmlWidgetHolder->setContextPropertyObject("controller", this); + _mainQmlWidgetHolder->setContextPropertyObject("debugMessageModel", &AppMessages::getModel()); _mainQmlWidgetHolder->setSource(QUrl::fromUserInput("qrc:qml/MainWindowHybrid.qml")); // Image provider @@ -355,9 +354,6 @@ bool MainWindow::_createInnerDockWidget(const QString& widgetName) case LOG_DOWNLOAD: widget = new LogDownload(widgetName, action, this); break; - case DEBUG_MESSAGES: - widget = new AppMessagesDialog(widgetName, action, this); - break; case STATUS_DETAILS: widget = new UASInfoWidget(widgetName, action, this); break; diff --git a/src/ui/MainWindowLeftPanel.qml b/src/ui/MainWindowLeftPanel.qml index 6ce2dbc360baec73ec17a146ce518fe72d31966a..e3a56452b13dba40b90b0900a3a6ae2d0790d85e 100644 --- a/src/ui/MainWindowLeftPanel.qml +++ b/src/ui/MainWindowLeftPanel.qml @@ -213,6 +213,19 @@ Item { } } + QGCButton { + anchors.left: parent.left + anchors.right: parent.right + text: "Console" + exclusiveGroup: panelActionGroup + onClicked: { + if(__rightPanel.source != "QGroundControl/Controls/AppMessages.qml") { + __rightPanel.source = "QGroundControl/Controls/AppMessages.qml" + } + checked = true + } + } + QGCButton { anchors.left: parent.left anchors.right: parent.right