Commit d55937a1 authored by Lorenz Meier's avatar Lorenz Meier

Another cleanup round

parent 7aa3ca2d
......@@ -28,8 +28,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_stopp(false),
m_reqReset(false)
{
qDebug() << "create SerialLink " << portname << baudRate << hardwareFlowControl
<< parity << dataBits << stopBits;
// Setup settings
m_portName = portname.trimmed();
......@@ -38,8 +36,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_portName = m_ports.first().trimmed();
}
qDebug() << "m_portName " << m_portName;
// Set unique ID and add link to the list of links
m_id = getNextLinkId();
......@@ -66,6 +62,11 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl,
m_stopBits = stopBits;
loadSettings();
qDebug() << "create SerialLink " << portname << baudRate << hardwareFlowControl
<< parity << dataBits << stopBits;
qDebug() << "m_portName " << m_portName;
LinkManager::instance()->add(this);
}
void SerialLink::requestReset()
......
......@@ -223,6 +223,8 @@ QGCPX4VehicleConfig::QGCPX4VehicleConfig(QWidget *parent) :
updateTimer.setInterval(150);
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateView()));
updateTimer.start();
firmwareMenuButtonClicked();
}
QGCPX4VehicleConfig::~QGCPX4VehicleConfig()
......
......@@ -182,8 +182,8 @@ void QGCToolBar::createUI()
baudcomboBox->addItem("921600", 921600);
baudcomboBox->setCurrentIndex(baudcomboBox->findData(57600));
addWidget(baudcomboBox);
connect(baudcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(baudSelected(int)));
connect(portComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(portSelected(int)));
connect(baudcomboBox, SIGNAL(activated(int)), this, SLOT(baudSelected(int)));
connect(portComboBox, SIGNAL(activated(int)), this, SLOT(portSelected(int)));
connectButton = new QPushButton(tr("Connect"), this);
connectButton->setObjectName("connectButton");
......@@ -666,6 +666,10 @@ void QGCToolBar::updateComboBox()
{
if (currentLink)
{
// Do not update if not visible
if (!portComboBox->isVisible())
return;
SerialLink *slink = qobject_cast<SerialLink*>(currentLink);
QList<QString> portlist = slink->getCurrentPorts();
foreach (QString port, portlist)
......@@ -715,6 +719,8 @@ void QGCToolBar::updateLinkState(bool connected)
connectButton->blockSignals(true);
connectButton->setChecked(true);
connectButton->blockSignals(false);
portComboBox->hide();
baudcomboBox->hide();
}
else
{
......@@ -722,6 +728,8 @@ void QGCToolBar::updateLinkState(bool connected)
connectButton->blockSignals(true);
connectButton->setChecked(false);
connectButton->blockSignals(false);
portComboBox->show();
baudcomboBox->show();
}
}
......
......@@ -64,6 +64,8 @@ UASListWidget::UASListWidget(QWidget *parent) : QWidget(parent),
this->setVisible(false);
connect(LinkManager::instance(), SIGNAL(linkRemoved(LinkInterface*)), this, SLOT(removeLink(LinkInterface*)));
// Listen for when UASes are added or removed. This does not manage the UASView
// widgets that are displayed within this widget.
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
......@@ -96,12 +98,30 @@ void UASListWidget::changeEvent(QEvent *e)
}
}
// XXX This is just to prevent
// upfront crashes, will probably need further inspection
void UASListWidget::removeLink(LinkInterface* link)
{
QGroupBox* box = linkToBoxMapping.value(link, NULL);
if (box) {
// Just stop updating the status for now - we should
// remove the UAS probably
linkToBoxMapping.remove(link);
}
}
void UASListWidget::updateStatus()
{
QMapIterator<LinkInterface*, QGroupBox*> i(linkToBoxMapping);
while (i.hasNext()) {
i.next();
LinkInterface* link = i.key();
// Paranoid sanity check
if (!LinkManager::instance()->getLinks().contains(link))
continue;
if (!link)
continue;
......
......@@ -53,6 +53,7 @@ public slots:
void addUAS(UASInterface* uas);
void activeUAS(UASInterface* uas);
void removeUAS(UASInterface* uas);
void removeLink(LinkInterface* link);
protected:
// Keep a mapping from UASes to their GroupBox. Useful for determining when groupboxes are empty.
......
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