Commit b76b7282 authored by Lorenz Meier's avatar Lorenz Meier

Placed connect button better, added simple message console

parent 796a8d85
......@@ -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
......
......@@ -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");
......
......@@ -4,6 +4,7 @@
#include <QWidget>
#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;
......
#include "QGCMessageView.h"
#include "ui_QGCMessageView.h"
#include "UASManager.h"
#include "QGCUnconnectedInfoWidget.h"
#include <QMenu>
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("<font color=\"%1\">[%2:%3] %4</font>\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());
}
#ifndef QGCMESSAGEVIEW_H
#define QGCMESSAGEVIEW_H
#include <QWidget>
#include <UASInterface.h>
#include <QVBoxLayout>
#include <QAction>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCMessageView</class>
<widget class="QWidget" name="QGCMessageView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>305</width>
<height>283</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>303</width>
<height>273</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -13,223 +13,141 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>241</width>
<height>161</height>
</rect>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>6</number>
</property>
<property name="title">
<string>Mission Controls</string>
</property>
<widget class="QPushButton" name="goToWaypointButton">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>131</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Go To Waypoint</string>
</property>
</widget>
<widget class="QComboBox" name="waypointComboBox">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>131</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>221</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="speedSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="changeSpeedButton">
<property name="text">
<string>Change Speed</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>81</y>
<width>221</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSpinBox" name="altitudeSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="changeAltitudeButton">
<property name="text">
<string>Change Altitude</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="currentWaypointLabel">
<property name="geometry">
<rect>
<x>150</x>
<y>20</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Current:</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_6">
<property name="geometry">
<rect>
<x>150</x>
<y>50</y>
<width>81</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Restart Mission</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>0</x>
<y>180</y>
<width>311</width>
<height>161</height>
</rect>
</property>
<property name="title">
<string>Auto Actions</string>
</property>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>141</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_8">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>141</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Execute Action</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_3">
<property name="geometry">
<rect>
<x>160</x>
<y>20</y>
<width>141</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButton_5">
<property name="geometry">
<rect>
<x>160</x>
<y>50</y>
<width>141</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Set Mode</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Auto</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>110</x>
<y>80</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Manual</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>210</x>
<y>80</y>
<width>91</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>RTL</string>
</property>
</widget>
<widget class="QPushButton" name="armDisarmButton">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>291</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>ARM</string>
</property>
</widget>
</widget>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Mission Controls</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="waypointComboBox"/>
</item>
<item row="0" column="1">
<widget class="QLabel" name="currentWaypointLabel">
<property name="text">
<string>Current:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="goToWaypointButton">
<property name="text">
<string>Go To Waypoint</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_6">
<property name="text">
<string>Restart Mission</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QSpinBox" name="altitudeSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="changeAltitudeButton">
<property name="text">
<string>Change Altitude</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="speedSpinBox"/>
</item>
<item>
<widget class="QPushButton" name="changeSpeedButton">
<property name="text">
<string>Change Speed</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Auto Actions</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>6</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="0" column="2" colspan="2">
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_8">
<property name="text">
<string>Execute Action</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<widget class="QPushButton" name="pushButton_5">
<property name="text">
<string>Set Mode</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Auto</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Manual</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pushButton_4">
<property name="text">
<string>RTL</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QPushButton" name="armDisarmButton">
<property name="text">
<string>ARM</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
......
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment