Browse Source

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

QGC4.4
Bill Bonney 12 years ago
parent
commit
45bad6d10a
  1. 33
      src/QGCCore.cc
  2. 46
      src/ui/MainWindow.cc
  3. 13
      src/ui/QGCStatusBar.cc
  4. 2
      src/ui/QGCToolBar.cc
  5. 19
      src/ui/apmtoolbar.cpp
  6. 1
      src/ui/apmtoolbar.h

33
src/QGCCore.cc

@ -168,38 +168,9 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv)
// Remove splash screen // Remove splash screen
splashScreen->finish(mainWindow); 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);
} }
/** /**

46
src/ui/MainWindow.cc

@ -189,26 +189,6 @@ MainWindow::MainWindow(QWidget *parent):
advancedActions << ui.actionEngineersView; advancedActions << ui.actionEngineersView;
toolBar->setPerspectiveChangeAdvancedActions(advancedActions); 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 #endif
customStatusBar = new QGCStatusBar(this); customStatusBar = new QGCStatusBar(this);
@ -235,6 +215,28 @@ MainWindow::MainWindow(QWidget *parent):
connect(LinkManager::instance(), SIGNAL(newLink(LinkInterface*)), this, SLOT(addLink(LinkInterface*))); 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 // Connect user interface devices
emit initStatusChanged("Initializing joystick interface."); emit initStatusChanged("Initializing joystick interface.");
joystickWidget = 0; joystickWidget = 0;
@ -918,6 +920,8 @@ void MainWindow::showTool(bool show)
}*/ }*/
void MainWindow::addCentralWidget(QWidget* widget, const QString& title) void MainWindow::addCentralWidget(QWidget* widget, const QString& title)
{ {
Q_UNUSED(title);
// Check if this widget already has been added // Check if this widget already has been added
if (centerStack->indexOf(widget) == -1) if (centerStack->indexOf(widget) == -1)
{ {
@ -1729,6 +1733,7 @@ void MainWindow::commsWidgetDestroyed(QObject *obj)
void MainWindow::setActiveUAS(UASInterface* uas) void MainWindow::setActiveUAS(UASInterface* uas)
{ {
Q_UNUSED(uas);
// Enable and rename menu // Enable and rename menu
// ui.menuUnmanned_System->setTitle(uas->getUASName()); // ui.menuUnmanned_System->setTitle(uas->getUASName());
// if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true); // if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true);
@ -1950,6 +1955,7 @@ void MainWindow::UASCreated(UASInterface* uas)
void MainWindow::UASDeleted(UASInterface* uas) void MainWindow::UASDeleted(UASInterface* uas)
{ {
Q_UNUSED(uas);
if (UASManager::instance()->getUASList().count() == 0) if (UASManager::instance()->getUASList().count() == 0)
{ {
// Last system deleted // Last system deleted

13
src/ui/QGCStatusBar.cc

@ -49,16 +49,11 @@ QGCStatusBar::QGCStatusBar(QWidget *parent) :
void QGCStatusBar::paintEvent(QPaintEvent * event) void QGCStatusBar::paintEvent(QPaintEvent * event)
{ {
Q_UNUSED(event);
QPainter p(this); QPainter p(this);
QStyleOption opt; QStyleOption opt;
opt.initFrom(this); opt.initFrom(this);
style()->drawPrimitive(QStyle::PE_PanelStatusBar, &opt, &p, 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) void QGCStatusBar::setLogPlayer(QGCMAVLinkLogPlayer* player)
@ -66,12 +61,6 @@ void QGCStatusBar::setLogPlayer(QGCMAVLinkLogPlayer* player)
this->player = player; this->player = player;
addPermanentWidget(player); addPermanentWidget(player);
connect(toggleLoggingButton, SIGNAL(clicked(bool)), this, SLOT(logging(bool))); 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) void QGCStatusBar::logging(bool checked)

2
src/ui/QGCToolBar.cc

@ -423,6 +423,8 @@ void QGCToolBar::updateBatteryRemaining(UASInterface* uas, double voltage, doubl
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
Q_UNUSED(seconds); Q_UNUSED(seconds);
Q_UNUSED(current);
if (batteryPercent != percent || batteryVoltage != voltage) changed = true; if (batteryPercent != percent || batteryVoltage != voltage) changed = true;
batteryPercent = percent; batteryPercent = percent;
batteryVoltage = voltage; batteryVoltage = voltage;

19
src/ui/apmtoolbar.cpp

@ -20,9 +20,7 @@ APMToolBar::APMToolBar(QWidget *parent):
updateLinkDisplay(LinkManager::instance()->getLinks().last()); updateLinkDisplay(LinkManager::instance()->getLinks().last());
} }
QObject *object = rootObject(); setConnection(false);
if (object)
object->setProperty("connected", false);
} }
void APMToolBar::setFlightViewAction(QAction *action) void APMToolBar::setFlightViewAction(QAction *action)
@ -116,12 +114,18 @@ void APMToolBar::connectMAV()
qDebug() << "result = " << result; qDebug() << "result = " << result;
// Change the image to represent the state // Change the image to represent the state
QObject *object = rootObject(); setConnection(result);
object->setProperty("connected", result);
emit MAVConnected(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() APMToolBar::~APMToolBar()
{ {
qDebug() << "Destory APM Toolbar"; qDebug() << "Destory APM Toolbar";
@ -161,5 +165,10 @@ void APMToolBar::updateLinkDisplay(LinkInterface* newLink)
QString linkName = newLink->getName(); QString linkName = newLink->getName();
object->setProperty("linkNameLabel", linkName); object->setProperty("linkNameLabel", linkName);
connect(newLink, SIGNAL(connected(bool)),
this, SLOT(setConnection(bool)));
setConnection(newLink->isConnected());
} }
} }

1
src/ui/apmtoolbar.h

@ -41,6 +41,7 @@ public slots:
void connectMAV(); void connectMAV();
void showConnectionDialog(); void showConnectionDialog();
void setConnection(bool connection);
void updateLinkDisplay(LinkInterface *newLink); void updateLinkDisplay(LinkInterface *newLink);
}; };

Loading…
Cancel
Save