diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 91be4c17f87b541ad8f8ab7d0ea55cd1800daac6..25c6633efe90092a672868a11c25415e18decb56 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -231,7 +231,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/uas/UASQuickViewItemSelect.ui \ src/ui/uas/UASActionsWidget.ui \ src/ui/QGCTabbedInfoView.ui \ - src/ui/UASRawStatusView.ui + src/ui/UASRawStatusView.ui \ + src/ui/uas/QGCMessageView.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -388,7 +389,8 @@ HEADERS += src/MG.h \ src/ui/designer/QGCRadioChannelDisplay.h \ src/ui/QGCTabbedInfoView.h \ src/ui/UASRawStatusView.h \ - src/ui/PrimaryFlightDisplay.h + src/ui/PrimaryFlightDisplay.h \ + src/ui/uas/QGCMessageView.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -564,7 +566,8 @@ SOURCES += src/main.cc \ src/ui/designer/QGCRadioChannelDisplay.cpp \ src/ui/QGCTabbedInfoView.cpp \ src/ui/UASRawStatusView.cpp \ - src/ui/PrimaryFlightDisplay.cpp + src/ui/PrimaryFlightDisplay.cpp \ + src/ui/uas/QGCMessageView.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010|win32-msvc2012::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/ui/QGCTabbedInfoView.cpp b/src/ui/QGCTabbedInfoView.cpp index b2707616786e4709b60e57d4bcc5baf3b62ec8a4..e319471386ee593485a33fc0d4bdc1ddba147b2a 100644 --- a/src/ui/QGCTabbedInfoView.cpp +++ b/src/ui/QGCTabbedInfoView.cpp @@ -3,9 +3,11 @@ QGCTabbedInfoView::QGCTabbedInfoView(QWidget *parent) : QWidget(parent) { ui.setupUi(this); + messageView = new QGCMessageView(this); actionsWidget = new UASActionsWidget(this); quickView = new UASQuickView(this); rawView = new UASRawStatusView(this); + ui.tabWidget->addTab(messageView,"Messages"); ui.tabWidget->addTab(quickView,"Quick"); ui.tabWidget->addTab(actionsWidget,"Actions"); ui.tabWidget->addTab(rawView,"Status"); diff --git a/src/ui/QGCTabbedInfoView.h b/src/ui/QGCTabbedInfoView.h index a4c93a7a172e6d5e49a4701d66a725b9881ed817..b8ba5faa144572dab68ae4c26afc53713c1c605f 100644 --- a/src/ui/QGCTabbedInfoView.h +++ b/src/ui/QGCTabbedInfoView.h @@ -4,6 +4,7 @@ #include #include "ui_QGCTabbedInfoView.h" #include "MAVLinkDecoder.h" +#include "QGCMessageView.h" #include "UASActionsWidget.h" #include "UASQuickView.h" #include "UASRawStatusView.h" @@ -18,6 +19,7 @@ public: private: MAVLinkDecoder *m_decoder; Ui::QGCTabbedInfoView ui; + QGCMessageView *messageView; UASActionsWidget *actionsWidget; UASQuickView *quickView; UASRawStatusView *rawView; diff --git a/src/ui/uas/QGCMessageView.cc b/src/ui/uas/QGCMessageView.cc new file mode 100644 index 0000000000000000000000000000000000000000..fcd0f18d7f8bac9dcb7c9015c4f09cac390f6fbc --- /dev/null +++ b/src/ui/uas/QGCMessageView.cc @@ -0,0 +1,68 @@ +#include "QGCMessageView.h" +#include "ui_QGCMessageView.h" + +#include "UASManager.h" +#include "QGCUnconnectedInfoWidget.h" +#include + +QGCMessageView::QGCMessageView(QWidget *parent) : + QWidget(parent), + activeUAS(NULL), + clearAction(new QAction(tr("Clear Text"), this)), + ui(new Ui::QGCMessageView) +{ + setObjectName("QUICKVIEW_MESSAGE_CONSOLE"); + + ui->setupUi(this); + setStyleSheet("QScrollArea { border: 0px; } QPlainTextEdit { border: 0px }"); + + // Construct initial widget + connectWidget = new QGCUnconnectedInfoWidget(this); + ui->horizontalLayout->addWidget(connectWidget); + ui->plainTextEdit->hide(); + + connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); +} + +QGCMessageView::~QGCMessageView() +{ + delete ui; +} + +void QGCMessageView::setActiveUAS(UASInterface* uas) +{ + if (!uas) + return; + + if (activeUAS) { + disconnect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); + ui->plainTextEdit->clear(); + } else { + + // First time UI setup, clear layout + ui->horizontalLayout->removeWidget(connectWidget); + connectWidget->deleteLater(); + ui->plainTextEdit->show(); + + connect(clearAction, SIGNAL(triggered()), ui->plainTextEdit, SLOT(clear())); + } + + connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); + activeUAS = uas; +} + +void QGCMessageView::handleTextMessage(int uasid, int componentid, int severity, QString text) +{ + // XXX color messages according to severity + + ui->plainTextEdit->appendHtml(QString("[%2:%3] %4\n").arg(UASManager::instance()->getUASForId(uasid)->getColor().name()).arg(UASManager::instance()->getUASForId(uasid)->getUASName()).arg(componentid).arg(text)); + // Ensure text area scrolls correctly + ui->plainTextEdit->ensureCursorVisible(); +} + +void QGCMessageView::contextMenuEvent(QContextMenuEvent* event) +{ + QMenu menu(this); + menu.addAction(clearAction); + menu.exec(event->globalPos()); +} diff --git a/src/ui/uas/QGCMessageView.h b/src/ui/uas/QGCMessageView.h new file mode 100644 index 0000000000000000000000000000000000000000..67c69ce74c61b95365397f1282ee358e3fe54eff --- /dev/null +++ b/src/ui/uas/QGCMessageView.h @@ -0,0 +1,53 @@ +#ifndef QGCMESSAGEVIEW_H +#define QGCMESSAGEVIEW_H + +#include +#include +#include +#include +#include "QGCUnconnectedInfoWidget.h" + +namespace Ui { +class QGCMessageView; +} + +class QGCMessageView : public QWidget +{ + Q_OBJECT + +public: + explicit QGCMessageView(QWidget *parent = 0); + ~QGCMessageView(); + +public slots: + /** + * @brief Set currently active UAS + * @param uas the current active UAS + */ + void setActiveUAS(UASInterface* uas); + /** + * @brief Handle text message from current active UAS + * @param uasid + * @param componentid + * @param severity + * @param text + */ + void handleTextMessage(int uasid, int componentid, int severity, QString text); + + /** + * @brief Hand context menu event + * @param event + */ + virtual void contextMenuEvent(QContextMenuEvent* event); + +protected: + UASInterface* activeUAS; + QVBoxLayout* initialLayout; + QGCUnconnectedInfoWidget *connectWidget; + QAction* clearAction; + +private: + Ui::QGCMessageView *ui; +}; + +#endif // QGCMESSAGEVIEW_H diff --git a/src/ui/uas/QGCMessageView.ui b/src/ui/uas/QGCMessageView.ui new file mode 100644 index 0000000000000000000000000000000000000000..069ee2f02e909466905d0ee7ddf621bf7186ffbf --- /dev/null +++ b/src/ui/uas/QGCMessageView.ui @@ -0,0 +1,62 @@ + + + QGCMessageView + + + + 0 + 0 + 305 + 283 + + + + Form + + + + 0 + + + 8 + + + 0 + + + 0 + + + + + true + + + + + 0 + 0 + 303 + 273 + + + + + 0 + + + + + true + + + + + + + + + + + + diff --git a/src/ui/uas/UASActionsWidget.ui b/src/ui/uas/UASActionsWidget.ui index 01c1ff0e348ac5273fc4d3231d9f95cfbcaac706..ae22a05da05a86afd42db9e0b6c4134650a6cea6 100644 --- a/src/ui/uas/UASActionsWidget.ui +++ b/src/ui/uas/UASActionsWidget.ui @@ -13,223 +13,141 @@ Form - - - - 10 - 10 - 241 - 161 - + + + 6 - - Mission Controls - - - - - 10 - 50 - 131 - 23 - - - - Go To Waypoint - - - - - - 10 - 20 - 131 - 22 - - - - - - - 10 - 120 - 221 - 31 - - - - - - - - - - Change Speed - - - - - - - - - 10 - 81 - 221 - 31 - - - - - - - - - - Change Altitude - - - - - - - - - 150 - 20 - 81 - 20 - - - - Current: - - - - - - 150 - 50 - 81 - 23 - - - - Restart Mission - - - - - - - 0 - 180 - 311 - 161 - - - - Auto Actions - - - - - 10 - 20 - 141 - 22 - - - - - - - 10 - 50 - 141 - 23 - - - - Execute Action - - - - - - 160 - 20 - 141 - 22 - - - - - - - 160 - 50 - 141 - 23 - - - - Set Mode - - - - - - 10 - 80 - 91 - 23 - - - - Auto - - - - - - 110 - 80 - 91 - 23 - - - - Manual - - - - - - 210 - 80 - 91 - 23 - - - - RTL - - - - - - 10 - 110 - 291 - 41 - - - - ARM - - - + + + + Mission Controls + + + + 6 + + + 6 + + + + + + + + Current: + + + + + + + Go To Waypoint + + + + + + + Restart Mission + + + + + + + + + + + + Change Altitude + + + + + + + + + + + + + + Change Speed + + + + + + + + + + + + Auto Actions + + + + 6 + + + 6 + + + + + + + + + + + Execute Action + + + + + + + Set Mode + + + + + + + Auto + + + + + + + Manual + + + + + + + RTL + + + + + + + ARM + + + + + + + diff --git a/src/ui/uas/UASListWidget.cc b/src/ui/uas/UASListWidget.cc index 26f64a949d2ff33fa188cfc721f4d60e3ded08af..1a1e97562fbe1d6e436660065fe1500238603eb2 100644 --- a/src/ui/uas/UASListWidget.cc +++ b/src/ui/uas/UASListWidget.cc @@ -45,7 +45,9 @@ This file is part of the PIXHAWK project #include "MAVLinkSimulationLink.h" #include "LinkManager.h" -UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UASList) +UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), + uWidget(NULL), + m_ui(new Ui::UASList) { m_ui->setupUi(this); @@ -57,8 +59,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent), m_ui(new Ui::UA setObjectName("UNMANNED_SYSTEMS_LIST"); // Construct initial widget - uWidget = new QGCUnconnectedInfoWidget(this); - listLayout->addWidget(uWidget); + //uWidget = new QGCUnconnectedInfoWidget(this); + //listLayout->addWidget(uWidget); this->setMinimumWidth(262); @@ -98,9 +100,12 @@ void UASListWidget::addUAS(UASInterface* uas) { if (uasViews.isEmpty()) { - listLayout->removeWidget(uWidget); - delete uWidget; - uWidget = NULL; + if (uWidget) + { + listLayout->removeWidget(uWidget); + delete uWidget; + uWidget = NULL; + } } if (!uasViews.contains(uas))