Commit 505236a6 authored by lm's avatar lm

Fixed control widget, made QGCToolWidgets more general, preparing the parameter interface widget

parent 713474b0
......@@ -454,18 +454,10 @@ void DebugConsole::handleConnectButton()
if (currLink->isConnected())
{
currLink->disconnect();
m_ui->connectButton->setText(tr("Connect"));
}
else
{
if (currLink->connect())
{
m_ui->connectButton->setText(tr("Disconn."));
}
else
{
m_ui->receiveText->appendHtml(QString("<font color=\"%1\">%2</font>").arg(QGC::colorRed.name(), tr("Could not connect link %1 ! Please check link hardware.").arg(currLink->getName())));
}
currLink->connect();
}
}
}
......
......@@ -745,6 +745,7 @@ void MainWindow::connectSlugsWidgets()
void MainWindow::arrangeCommonCenterStack()
{
centerStack = new QStackedWidget(this);
centerStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
if (!centerStack) return;
......
......@@ -38,7 +38,7 @@
<x>0</x>
<y>0</y>
<width>1000</width>
<height>22</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuMGround">
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>210</width>
<height>141</height>
<width>222</width>
<height>172</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -18,14 +18,23 @@
</property>
<property name="minimumSize">
<size>
<width>210</width>
<height>130</height>
<width>222</width>
<height>172</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>267</width>
<height>194</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,100,50,50,100,0">
<property name="toolTip">
<string>Control widget to send basic control actions to the micro air vehicle</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="60,150,80,80,80,100" columnstretch="1,100,40,40,100,1" rowminimumheight="0,0,0,0,0,0">
<item row="0" column="0" rowspan="6">
<spacer name="horizontalSpacer">
<property name="orientation">
......@@ -93,7 +102,7 @@
</size>
</property>
<property name="text">
<string>Liftoff</string>
<string>Start</string>
</property>
<property name="icon">
<iconset resource="../../mavground.qrc">
......
......@@ -42,17 +42,12 @@ const char* kActionLabels[MAV_ACTION_NB] =
"RESET MAP"};
QGCActionButton::QGCActionButton(QWidget *parent) :
QGCToolWidgetItem(parent),
QGCToolWidgetItem("Button", parent),
ui(new Ui::QGCActionButton),
uas(NULL)
{
ui->setupUi(this);
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
// Set first UAS if it exists
this->setActiveUAS(UASManager::instance()->getActiveUAS());
connect(ui->actionButton, SIGNAL(clicked()), this, SLOT(sendAction()));
connect(ui->editFinishButton, SIGNAL(clicked()), this, SLOT(endEditMode()));
connect(ui->editButtonName, SIGNAL(textChanged(QString)), this, SLOT(setActionButtonName(QString)));
......@@ -73,12 +68,16 @@ QGCActionButton::~QGCActionButton()
void QGCActionButton::sendAction()
{
if (uas)
if (QGCToolWidgetItem::uas)
{
MAV_ACTION action = static_cast<MAV_ACTION>(
ui->editActionComboBox->currentIndex());
uas->setAction(action);
QGCToolWidgetItem::uas->setAction(action);
}
else
{
qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
}
}
......@@ -110,8 +109,3 @@ void QGCActionButton::endEditMode()
isInEditMode = false;
}
void QGCActionButton::setActiveUAS(UASInterface *uas)
{
this->uas = uas;
}
......@@ -23,9 +23,6 @@ public slots:
void startEditMode();
void endEditMode();
private slots:
void setActiveUAS(UASInterface* uas);
private:
Ui::QGCActionButton *ui;
UASInterface* uas;
......
......@@ -3,9 +3,16 @@
#include "QGCParamSlider.h"
#include "ui_QGCParamSlider.h"
#include "UASInterface.h"
QGCParamSlider::QGCParamSlider(QWidget *parent) :
QGCToolWidgetItem(parent),
QGCToolWidgetItem("Slider", parent),
parameterName(""),
parameterValue(0.0f),
parameterScalingFactor(0.0),
parameterMin(0.0f),
parameterMax(0.0f),
component(0),
ui(new Ui::QGCParamSlider)
{
ui->setupUi(this);
......@@ -48,6 +55,18 @@ void QGCParamSlider::endEditMode()
isInEditMode = false;
}
void QGCParamSlider::sendParameter()
{
if (QGCToolWidgetItem::uas)
{
QGCToolWidgetItem::uas->setParameter(component, parameterName, parameterValue);
}
else
{
qDebug() << __FILE__ << __LINE__ << "NO UAS SET, DOING NOTHING";
}
}
void QGCParamSlider::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
......
......@@ -22,8 +22,16 @@ public:
public slots:
void startEditMode();
void endEditMode();
/** @brief Send the parameter to the MAV */
void sendParameter();
protected:
QString parameterName; ///< Key/Name of the parameter
float parameterValue; ///< Value of the parameter
double parameterScalingFactor; ///< Factor to scale the parameter between slider and true value
float parameterMin;
float parameterMax;
int component; ///< ID of the MAV component to address
void changeEvent(QEvent *e);
private:
......
......@@ -50,7 +50,7 @@ void QGCToolWidget::addUAS(UASInterface* uas)
void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event)
{
QMenu menu(this);
menu.addAction(addParamAction);
//menu.addAction(addParamAction);
menu.addAction(addButtonAction);
menu.addAction(setTitleAction);
menu.exec(event->globalPos());
......
......@@ -3,16 +3,25 @@
#include <QMenu>
#include <QContextMenuEvent>
QGCToolWidgetItem::QGCToolWidgetItem(QWidget *parent) :
#include "UASManager.h"
QGCToolWidgetItem::QGCToolWidgetItem(const QString& name, QWidget *parent) :
QWidget(parent),
isInEditMode(false),
qgcToolWidgetItemName(name),
uas(NULL),
_component(-1)
{
startEditAction = new QAction("Edit Slider", this);
startEditAction = new QAction("Edit "+qgcToolWidgetItemName, this);
connect(startEditAction, SIGNAL(triggered()), this, SLOT(startEditMode()));
stopEditAction = new QAction("Finish Editing Slider", this);
connect(stopEditAction, SIGNAL(triggered()), this, SLOT(endEditMode()));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
this, SLOT(setActiveUAS(UASInterface*)));
// Set first UAS if it exists
setActiveUAS(UASManager::instance()->getActiveUAS());
endEditMode();
}
......@@ -35,3 +44,8 @@ void QGCToolWidgetItem::contextMenuEvent (QContextMenuEvent* event)
}
menu.exec(event->globalPos());
}
void QGCToolWidgetItem::setActiveUAS(UASInterface *uas)
{
this->uas = uas;
}
......@@ -4,11 +4,13 @@
#include <QWidget>
#include <QAction>
#include "UASInterface.h"
class QGCToolWidgetItem : public QWidget
{
Q_OBJECT
public:
explicit QGCToolWidgetItem(QWidget *parent = 0);
QGCToolWidgetItem(const QString& name, QWidget *parent = 0);
~QGCToolWidgetItem();
int component() {return _component;}
......@@ -17,12 +19,14 @@ public slots:
virtual void startEditMode() {}
virtual void endEditMode() {}
virtual void setComponent(int comp) {_component = comp;}
void setActiveUAS(UASInterface *uas);
protected:
QAction* startEditAction;
QAction* stopEditAction;
bool isInEditMode;
QString qgcToolWidgetItemName;
UASInterface* uas;
int _component; ///< The MAV component (the process or device ID)
void contextMenuEvent (QContextMenuEvent* event);
......
......@@ -114,18 +114,18 @@ void UASControlWidget::setUAS(UASInterface* uas)
// Check if additional controls should be loaded
UAS* mav = dynamic_cast<UAS*>(uas);
if (mav)
{
{
QPushButton* startRecButton = new QPushButton(tr("Record"));
connect(startRecButton, SIGNAL(clicked()), mav, SLOT(startDataRecording()));
ui.gridLayout->addWidget(startRecButton, 10, 0, 0, 2);
ui.gridLayout->addWidget(startRecButton, 7, 1);
QPushButton* pauseRecButton = new QPushButton(tr("Pause"));
connect(pauseRecButton, SIGNAL(clicked()), mav, SLOT(pauseDataRecording()));
ui.gridLayout->addWidget(pauseRecButton, 10, 2, 0, 2);
ui.gridLayout->addWidget(pauseRecButton, 7, 3);
QPushButton* stopRecButton = new QPushButton(tr("Stop"));
connect(stopRecButton, SIGNAL(clicked()), mav, SLOT(stopDataRecording()));
ui.gridLayout->addWidget(stopRecButton, 10, 4, 0, 2);
ui.gridLayout->addWidget(stopRecButton, 7, 4);
}
......
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