Commit d3e93a35 authored by Bill Bonney's avatar Bill Bonney

APM Tool Bar: connected coonect(bool) signal to connect button.

parent e36b3c1c
......@@ -168,38 +168,9 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv)
// Remove splash screen
splashScreen->finish(mainWindow);
if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"), tr("APM Planner has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION));
if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"),
tr("APM Planner has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION));
// Check if link could be connected
if (!udpLink->connect())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?");
msgBox.setInformativeText("You will not be able to receive data via UDP. Please check that you're running the right executable and then re-start " + qAppName() + ". Do you want to close the application?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(15000, &msgBox, SLOT(reject()));
// Exit application
if (ret == QMessageBox::Yes)
{
//mainWindow->close();
QTimer::singleShot(200, mainWindow, SLOT(close()));
}
}
// forever
// {
// QGC::SLEEP::msleep(5000);
// }
// mainWindow->close();
// mainWindow->deleteLater();
// QGC::SLEEP::msleep(200);
}
/**
......
......@@ -189,26 +189,6 @@ MainWindow::MainWindow(QWidget *parent):
advancedActions << ui.actionEngineersView;
toolBar->setPerspectiveChangeAdvancedActions(advancedActions);
#else
// Add the APM 'toolbar'
APMToolBar *apmToolBar = new APMToolBar(this);
apmToolBar->setFlightViewAction(ui.actionFlightView);
apmToolBar->setFlightPlanViewAction(ui.actionMissionView);
apmToolBar->setHardwareViewAction(ui.actionHardwareConfig);
apmToolBar->setSoftwareViewAction(ui.actionSoftwareConfig);
apmToolBar->setSimulationViewAction(ui.actionSimulation_View);
apmToolBar->setTerminalViewAction(ui.actionSimulation_View);
QDockWidget *widget = new QDockWidget(tr("APM Tool Bar"),this);
widget->setWidget(apmToolBar);
widget->setMinimumHeight(72);
widget->setMaximumHeight(72);
widget->setMinimumWidth(1024);
widget->setFeatures(QDockWidget::NoDockWidgetFeatures);
widget->setTitleBarWidget(new QWidget(this)); // Disables the title bar
// /*widget*/->setStyleSheet("QDockWidget { border: 0px solid #FFFFFF; border-radius: 0px; border-bottom: 0px;}");
this->addDockWidget(Qt::TopDockWidgetArea, widget);
#endif
customStatusBar = new QGCStatusBar(this);
......@@ -235,6 +215,28 @@ MainWindow::MainWindow(QWidget *parent):
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*)));
#ifndef QGC_TOOLBAR_ENABLED
// Add the APM 'toolbar'
APMToolBar *apmToolBar = new APMToolBar(this);
apmToolBar->setFlightViewAction(ui.actionFlightView);
apmToolBar->setFlightPlanViewAction(ui.actionMissionView);
apmToolBar->setHardwareViewAction(ui.actionHardwareConfig);
apmToolBar->setSoftwareViewAction(ui.actionSoftwareConfig);
apmToolBar->setSimulationViewAction(ui.actionSimulation_View);
apmToolBar->setTerminalViewAction(ui.actionSimulation_View);
QDockWidget *widget = new QDockWidget(tr("APM Tool Bar"),this);
widget->setWidget(apmToolBar);
widget->setMinimumHeight(72);
widget->setMaximumHeight(72);
widget->setMinimumWidth(1024);
widget->setFeatures(QDockWidget::NoDockWidgetFeatures);
widget->setTitleBarWidget(new QWidget(this)); // Disables the title bar
// /*widget*/->setStyleSheet("QDockWidget { border: 0px solid #FFFFFF; border-radius: 0px; border-bottom: 0px;}");
this->addDockWidget(Qt::TopDockWidgetArea, widget);
#endif
// Connect user interface devices
emit initStatusChanged("Initializing joystick interface.");
joystickWidget = 0;
......@@ -918,6 +920,8 @@ void MainWindow::showTool(bool show)
}*/
void MainWindow::addCentralWidget(QWidget* widget, const QString& title)
{
Q_UNUSED(title);
// Check if this widget already has been added
if (centerStack->indexOf(widget) == -1)
{
......@@ -1729,6 +1733,7 @@ void MainWindow::commsWidgetDestroyed(QObject *obj)
void MainWindow::setActiveUAS(UASInterface* uas)
{
Q_UNUSED(uas);
// Enable and rename menu
// ui.menuUnmanned_System->setTitle(uas->getUASName());
// if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true);
......@@ -1950,6 +1955,7 @@ void MainWindow::UASCreated(UASInterface* uas)
void MainWindow::UASDeleted(UASInterface* uas)
{
Q_UNUSED(uas);
if (UASManager::instance()->getUASList().count() == 0)
{
// Last system deleted
......
......@@ -49,16 +49,11 @@ QGCStatusBar::QGCStatusBar(QWidget *parent) :
void QGCStatusBar::paintEvent(QPaintEvent * event)
{
Q_UNUSED(event);
QPainter p(this);
QStyleOption opt;
opt.initFrom(this);
style()->drawPrimitive(QStyle::PE_PanelStatusBar, &opt, &p, this);
//QStatusBar::paintEvent(event);
// if (currentMessage().length() == 0) {
// QStatusBar::paintEvent(event);
// } else {
// }
}
void QGCStatusBar::setLogPlayer(QGCMAVLinkLogPlayer* player)
......@@ -66,12 +61,6 @@ void QGCStatusBar::setLogPlayer(QGCMAVLinkLogPlayer* player)
this->player = player;
addPermanentWidget(player);
connect(toggleLoggingButton, SIGNAL(clicked(bool)), this, SLOT(logging(bool)));
//connect(MainWindow::instance()->getMAVLink(), SIGNAL(loggingChanged(bool)), toggleLoggingButton, SLOT(setChecked(bool)));
// XXX Mutex issue if called like this
// toggleLoggingButton->blockSignals(true);
// toggleLoggingButton->setChecked(MainWindow::instance()->getMAVLink()->loggingEnabled());
// toggleLoggingButton->blockSignals(false);
}
void QGCStatusBar::logging(bool checked)
......
......@@ -423,6 +423,8 @@ void QGCToolBar::updateBatteryRemaining(UASInterface* uas, double voltage, doubl
{
Q_UNUSED(uas);
Q_UNUSED(seconds);
Q_UNUSED(current);
if (batteryPercent != percent || batteryVoltage != voltage) changed = true;
batteryPercent = percent;
batteryVoltage = voltage;
......
......@@ -20,9 +20,7 @@ APMToolBar::APMToolBar(QWidget *parent):
updateLinkDisplay(LinkManager::instance()->getLinks().last());
}
QObject *object = rootObject();
if (object)
object->setProperty("connected", false);
setConnection(false);
}
void APMToolBar::setFlightViewAction(QAction *action)
......@@ -116,12 +114,18 @@ void APMToolBar::connectMAV()
qDebug() << "result = " << result;
// Change the image to represent the state
QObject *object = rootObject();
object->setProperty("connected", result);
setConnection(result);
emit MAVConnected(result);
}
void APMToolBar::setConnection(bool connection)
{
// Change the image to represent the state
QObject *object = rootObject();
object->setProperty("connected", connection);
}
APMToolBar::~APMToolBar()
{
qDebug() << "Destory APM Toolbar";
......@@ -161,5 +165,10 @@ void APMToolBar::updateLinkDisplay(LinkInterface* newLink)
QString linkName = newLink->getName();
object->setProperty("linkNameLabel", linkName);
connect(newLink, SIGNAL(connected(bool)),
this, SLOT(setConnection(bool)));
setConnection(newLink->isConnected());
}
}
......@@ -41,6 +41,7 @@ public slots:
void connectMAV();
void showConnectionDialog();
void setConnection(bool connection);
void updateLinkDisplay(LinkInterface *newLink);
};
......
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