Newer
Older
void MainWindow::updateLocationSettings (Qt::DockWidgetArea location)
{
QDockWidget* temp = qobject_cast<QDockWidget *>(sender());
Mariano Lizarraga
committed
QHashIterator<int, QWidget*> i(dockWidgets);
while (i.hasNext())
{
i.next();
if ((static_cast <QDockWidget *>(dockWidgets[i.key()])) == temp)
{
QString posKey = buildMenuKey (SUB_SECTION_LOCATION,static_cast<TOOLS_WIDGET_NAMES>(i.key()), currentView);
settings.setValue(posKey,location);
break;
}
}
Mariano Lizarraga
committed
}
Mariano Lizarraga
committed
Mariano Lizarraga
committed
/**
* Connect the signals and slots of the common window widgets
*/
Mariano Lizarraga
committed
void MainWindow::connectCommonWidgets()
{
if (infoDockWidget && infoDockWidget->widget())
{
connect(mavlink, SIGNAL(receiveLossChanged(int, float)),
infoDockWidget->widget(), SLOT(updateSendLoss(int, float)));
}
Mariano Lizarraga
committed
pixhawk
committed
Mariano Lizarraga
committed
//
connect(waypointsDockWidget->widget(), SIGNAL(changePointList()), mapWidget, SLOT(clearWaypoints()));
Mariano Lizarraga
committed
}
//TODO temporaly debug
if (slugsHilSimWidget && slugsHilSimWidget->widget()){
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
slugsHilSimWidget->widget(), SLOT(activeUasSet(UASInterface*)));
}
lm
committed
}
Mariano Lizarraga
committed
lm
committed
void MainWindow::createCustomWidget()
{
QGCToolWidget* tool = new QGCToolWidget("Unnamed Tool", this);
if (QGCToolWidget::instances()->size() < 2)
{
// This is the first widget
ui.menuTools->addSeparator();
}
lm
committed
QDockWidget* dock = new QDockWidget("Unnamed Tool", this);
connect(tool, SIGNAL(destroyed()), dock, SLOT(deleteLater()));
lm
committed
dock->setWidget(tool);
Mariano Lizarraga
committed
QAction* showAction = new QAction("Show Unnamed Tool", this);
showAction->setCheckable(true);
connect(dock, SIGNAL(visibilityChanged(bool)), showAction, SLOT(setChecked(bool)));
connect(showAction, SIGNAL(triggered(bool)), dock, SLOT(setVisible(bool)));
tool->setMainMenuAction(showAction);
ui.menuTools->addAction(showAction);
this->addDockWidget(Qt::BottomDockWidgetArea, dock);
lm
committed
dock->setVisible(true);
Mariano Lizarraga
committed
}
void MainWindow::connectPxWidgets()
{
// No special connections necessary at this point
Mariano Lizarraga
committed
}
void MainWindow::connectSlugsWidgets()
{
Mariano Lizarraga
committed
if (slugsHilSimWidget && slugsHilSimWidget->widget()){
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
slugsHilSimWidget->widget(), SLOT(activeUasSet(UASInterface*)));
Mariano Lizarraga
committed
}
if (slugsDataWidget && slugsDataWidget->widget()){
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
slugsDataWidget->widget(), SLOT(setActiveUAS(UASInterface*)));
if (controlParameterWidget && controlParameterWidget->widget()){
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)),
controlParameterWidget->widget(), SLOT(activeUasSet(UASInterface*)));
}
if(controlDockWidget && controlParameterWidget)
{
connect(controlDockWidget->widget(), SIGNAL(changedMode(int)), controlParameterWidget->widget(), SLOT(changedMode(int)));
}
Mariano Lizarraga
committed
}
Mariano Lizarraga
committed
void MainWindow::arrangeCommonCenterStack()
{
Mariano Lizarraga
committed
centerStack = new QStackedWidget(this);
lm
committed
centerStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Mariano Lizarraga
committed
Mariano Lizarraga
committed
if (mapWidget && (centerStack->indexOf(mapWidget) == -1)) centerStack->addWidget(mapWidget);
if (dataplotWidget && (centerStack->indexOf(dataplotWidget) == -1)) centerStack->addWidget(dataplotWidget);
if (protocolWidget && (centerStack->indexOf(protocolWidget) == -1)) centerStack->addWidget(protocolWidget);
Mariano Lizarraga
committed
setCentralWidget(centerStack);
}
void MainWindow::arrangePxCenterStack()
{
if (!centerStack) {
qDebug() << "Center Stack not Created!";
return;
}
Mariano Lizarraga
committed
if (linechartWidget && (centerStack->indexOf(linechartWidget) == -1)) centerStack->addWidget(linechartWidget);
Mariano Lizarraga
committed
pixhawk
committed
#ifdef QGC_OSG_ENABLED
if (_3DWidget && (centerStack->indexOf(_3DWidget) == -1)) centerStack->addWidget(_3DWidget);
pixhawk
committed
#ifdef QGC_OSGEARTH_ENABLED
if (_3DMapWidget && (centerStack->indexOf(_3DMapWidget) == -1)) centerStack->addWidget(_3DMapWidget);
pixhawk
committed
#endif
#if (defined _MSC_VER) | (defined Q_OS_MAC)
if (gEarthWidget && (centerStack->indexOf(gEarthWidget) == -1)) centerStack->addWidget(gEarthWidget);
pixhawk
committed
#endif
if (hudWidget && (centerStack->indexOf(hudWidget) == -1)) centerStack->addWidget(hudWidget);
if (dataplotWidget && (centerStack->indexOf(dataplotWidget) == -1)) centerStack->addWidget(dataplotWidget);
Mariano Lizarraga
committed
}
void MainWindow::arrangeSlugsCenterStack()
{
if (!centerStack) {
qDebug() << "Center Stack not Created!";
return;
}
Mariano Lizarraga
committed
if (linechartWidget && (centerStack->indexOf(linechartWidget) == -1)) centerStack->addWidget(linechartWidget);
if (hudWidget && (centerStack->indexOf(hudWidget) == -1)) centerStack->addWidget(hudWidget);
Mariano Lizarraga
committed
Mariano Lizarraga
committed
#if (defined _MSC_VER) | (defined Q_OS_MAC)
if (gEarthWidget && (centerStack->indexOf(gEarthWidget) == -1)) centerStack->addWidget(gEarthWidget);
#endif
Mariano Lizarraga
committed
}
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
void MainWindow::loadSettings()
{
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
autoReconnect = settings.value("AUTO_RECONNECT", autoReconnect).toBool();
currentStyle = (QGC_MAINWINDOW_STYLE)settings.value("CURRENT_STYLE", currentStyle).toInt();
settings.endGroup();
}
void MainWindow::storeSettings()
{
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
settings.setValue("AUTO_RECONNECT", autoReconnect);
settings.setValue("CURRENT_STYLE", currentStyle);
settings.endGroup();
settings.setValue(getWindowGeometryKey(), saveGeometry());
// Save the last current view in any case
settings.setValue("CURRENT_VIEW", currentView);
// Save the current window state, but only if a system is connected (else no real number of widgets would be present)
if (UASManager::instance()->getUASList().length() > 0) settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion()));
// Save the current view only if a UAS is connected
if (UASManager::instance()->getUASList().length() > 0) settings.setValue("CURRENT_VIEW_WITH_UAS_CONNECTED", currentView);
settings.sync();
}
void MainWindow::configureWindowName()
{
QList<QHostAddress> hostAddresses = QNetworkInterface::allAddresses();
QString windowname = qApp->applicationName() + " " + qApp->applicationVersion();
bool prevAddr = false;
Mariano Lizarraga
committed
windowname.append(" (" + QHostInfo::localHostName() + ": ");
Mariano Lizarraga
committed
for (int i = 0; i < hostAddresses.size(); i++)
{
// Exclude loopback IPv4 and all IPv6 addresses
if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":"))
{
if(prevAddr) windowname.append("/");
windowname.append(hostAddresses.at(i).toString());
prevAddr = true;
}
}
Mariano Lizarraga
committed
Mariano Lizarraga
committed
Mariano Lizarraga
committed
#ifndef Q_WS_MAC
//qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
Mariano Lizarraga
committed
#endif
}
{
QString format = "bmp";
QString initialPath = QDir::currentPath() + tr("/untitled.") + format;
QString screenFileName = QFileDialog::getSaveFileName(this, tr("Save As"),
initialPath,
tr("%1 Files (*.%2);;All Files (*)")
.arg(format.toUpper())
.arg(format));
delete videoTimer;
videoTimer = new QTimer(this);
//videoTimer->setInterval(40);
//connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
//videoTimer->stop();
{
videoTimer->stop();
// TODO Convert raw images to PNG
}
{
QPixmap window = QPixmap::grabWindow(this->winId());
QString format = "bmp";
if (!screenFileName.isEmpty())
{
window.save(screenFileName, format.toAscii());
}
}
void MainWindow::enableAutoReconnect(bool enabled)
autoReconnect = enabled;
}
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
void MainWindow::loadNativeStyle()
{
loadStyle(QGC_MAINWINDOW_STYLE_NATIVE);
}
void MainWindow::loadIndoorStyle()
{
loadStyle(QGC_MAINWINDOW_STYLE_INDOOR);
}
void MainWindow::loadOutdoorStyle()
{
loadStyle(QGC_MAINWINDOW_STYLE_OUTDOOR);
}
void MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style)
{
switch (style)
{
case QGC_MAINWINDOW_STYLE_NATIVE:
{
// Native mode means setting no style
// so if we were already in native mode
// take no action
// Only if a style was set, remove it.
if (style != currentStyle)
{
qApp->setStyleSheet("");
showInfoMessage(tr("Please restart QGroundControl"), tr("Please restart QGroundControl to switch to fully native look and feel. Currently you have loaded Qt's plastique style."));
}
}
break;
case QGC_MAINWINDOW_STYLE_INDOOR:
qApp->setStyle("plastique");
styleFileName = ":/images/style-mission.css";
reloadStylesheet();
break;
case QGC_MAINWINDOW_STYLE_OUTDOOR:
qApp->setStyle("plastique");
styleFileName = ":/images/style-outdoor.css";
reloadStylesheet();
break;
}
currentStyle = style;
}
void MainWindow::selectStylesheet()
styleFileName = QFileDialog::getOpenFileName(this, tr("Specify stylesheet"), styleFileName, tr("CSS Stylesheet (*.css);;"));
if (!styleFileName.endsWith(".css"))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("QGroundControl did lot load a new style"));
msgBox.setInformativeText(tr("No suitable .css file selected. Please select a valid .css file."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
return;
}
reloadStylesheet();
}
void MainWindow::reloadStylesheet()
{
// Load style sheet
QFile* styleSheet = new QFile(styleFileName);
if (!styleSheet->exists())
{
styleSheet = new QFile(":/images/style-mission.css");
}
if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
{
QString style = QString(styleSheet->readAll());
style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "/images/");
}
else
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("QGroundControl did lot load a new style"));
msgBox.setInformativeText(tr("Stylesheet file %1 was not readable").arg(styleFileName));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
delete styleSheet;
/**
* The status message will be overwritten if a new message is posted to this function
*
* @param status message text
* @param timeout how long the status should be displayed
*/
void MainWindow::showStatusMessage(const QString& status, int timeout)
/**
* The status message will be overwritten if a new message is posted to this function.
* it will be automatically hidden after 5 seconds.
*
* @param status message text
*/
void MainWindow::showStatusMessage(const QString& status)
}
void MainWindow::showCriticalMessage(const QString& title, const QString& message)
{
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(title);
msgBox.setInformativeText(message);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
void MainWindow::showInfoMessage(const QString& title, const QString& message)
{
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(title);
msgBox.setInformativeText(message);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
/**
* @brief Create all actions associated to the main window
*
**/
Mariano Lizarraga
committed
void MainWindow::connectCommonActions()
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
ui.actionNewCustomWidget->setEnabled(false);
// Bind together the perspective actions
QActionGroup* perspectives = new QActionGroup(ui.menuPerspectives);
perspectives->addAction(ui.actionEngineersView);
perspectives->addAction(ui.actionMavlinkView);
perspectives->addAction(ui.actionPilotsView);
perspectives->addAction(ui.actionOperatorsView);
perspectives->addAction(ui.actionUnconnectedView);
perspectives->setExclusive(true);
// Mark the right one as selected
if (currentView == VIEW_ENGINEER) ui.actionEngineersView->setChecked(true);
if (currentView == VIEW_MAVLINK) ui.actionMavlinkView->setChecked(true);
if (currentView == VIEW_PILOT) ui.actionPilotsView->setChecked(true);
if (currentView == VIEW_OPERATOR) ui.actionOperatorsView->setChecked(true);
if (currentView == VIEW_UNCONNECTED) ui.actionUnconnectedView->setChecked(true);
// The pilot, engineer and operator view are not available on startup
// since they only make sense with a system connected.
ui.actionPilotsView->setEnabled(false);
ui.actionOperatorsView->setEnabled(false);
ui.actionEngineersView->setEnabled(false);
// The UAS actions are not enabled without connection to system
ui.actionLiftoff->setEnabled(false);
ui.actionLand->setEnabled(false);
ui.actionEmergency_Kill->setEnabled(false);
ui.actionEmergency_Land->setEnabled(false);
ui.actionShutdownMAV->setEnabled(false);
// Connect actions from ui
connect(ui.actionAdd_Link, SIGNAL(triggered()), this, SLOT(addLink()));
// Connect internal actions
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(UASCreated(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
Mariano Lizarraga
committed
// Unmanned System controls
connect(ui.actionLiftoff, SIGNAL(triggered()), UASManager::instance(), SLOT(launchActiveUAS()));
connect(ui.actionLand, SIGNAL(triggered()), UASManager::instance(), SLOT(returnActiveUAS()));
connect(ui.actionEmergency_Land, SIGNAL(triggered()), UASManager::instance(), SLOT(stopActiveUAS()));
connect(ui.actionEmergency_Kill, SIGNAL(triggered()), UASManager::instance(), SLOT(killActiveUAS()));
connect(ui.actionShutdownMAV, SIGNAL(triggered()), UASManager::instance(), SLOT(shutdownActiveUAS()));
connect(ui.actionConfiguration, SIGNAL(triggered()), UASManager::instance(), SLOT(configureActiveUAS()));
Mariano Lizarraga
committed
// Views actions
Mariano Lizarraga
committed
connect(ui.actionPilotsView, SIGNAL(triggered()), this, SLOT(loadPilotView()));
Mariano Lizarraga
committed
connect(ui.actionEngineersView, SIGNAL(triggered()), this, SLOT(loadEngineerView()));
Mariano Lizarraga
committed
connect(ui.actionOperatorsView, SIGNAL(triggered()), this, SLOT(loadOperatorView()));
connect(ui.actionUnconnectedView, SIGNAL(triggered()), this, SLOT(loadUnconnectedView()));
pixhawk
committed
Mariano Lizarraga
committed
connect(ui.actionMavlinkView, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
connect(ui.actionReloadStylesheet, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
connect(ui.actionSelectStylesheet, SIGNAL(triggered()), this, SLOT(selectStylesheet()));
Mariano Lizarraga
committed
// Help Actions
connect(ui.actionOnline_Documentation, SIGNAL(triggered()), this, SLOT(showHelp()));
Mariano Lizarraga
committed
connect(ui.actionDeveloper_Credits, SIGNAL(triggered()), this, SLOT(showCredits()));
connect(ui.actionProject_Roadmap_2, SIGNAL(triggered()), this, SLOT(showRoadMap()));
// Custom widget actions
connect(ui.actionNewCustomWidget, SIGNAL(triggered()), this, SLOT(createCustomWidget()));
// Audio output
ui.actionMuteAudioOutput->setChecked(GAudioOutput::instance()->isMuted());
connect(GAudioOutput::instance(), SIGNAL(mutedChanged(bool)), ui.actionMuteAudioOutput, SLOT(setChecked(bool)));
connect(ui.actionMuteAudioOutput, SIGNAL(triggered(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
// User interaction
// NOTE: Joystick thread is not started and
// configuration widget is not instantiated
// unless it is actually used
// so no ressources spend on this.
ui.actionJoystickSettings->setVisible(true);
// Configuration
// Joystick
connect(ui.actionJoystickSettings, SIGNAL(triggered()), this, SLOT(configure()));
// Application Settings
connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
Mariano Lizarraga
committed
}
void MainWindow::connectPxActions()
{
}
void MainWindow::connectSlugsActions()
{
void MainWindow::showHelp()
{
if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/users/")))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open help in browser");
msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/user_guide in a browser.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::showCredits()
{
if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/credits/")))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open credits in browser");
msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/credits in a browser.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void MainWindow::showRoadMap()
{
if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/roadmap/")))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open roadmap in browser");
msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/roadmap in a browser.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
if (!joystickWidget)
{
if (!joystick->isRunning())
{
joystick->start();
}
joystickWidget = new JoystickWidget(joystick);
}
joystickWidget->show();
void MainWindow::showSettings()
{
QGCSettingsWidget* settings = new QGCSettingsWidget(this);
settings->show();
}
{
SerialLink* link = new SerialLink();
// TODO This should be only done in the dialog itself
LinkManager::instance()->add(link);
// Go fishing for this link's configuration window
QList<QAction*> actions = ui.menuNetwork->actions();
foreach (QAction* act, actions)
{
if (act->data().toInt() == LinkManager::instance()->getLinks().indexOf(link))
{
act->trigger();
break;
}
}
void MainWindow::addLink(LinkInterface *link)
{
// IMPORTANT! KEEP THESE TWO LINES
// THEY MAKE SURE THE LINK IS PROPERLY REGISTERED
// BEFORE LINKING THE UI AGAINST IT
// Register (does nothing if already registered)
LinkManager::instance()->add(link);
LinkManager::instance()->addProtocol(link, mavlink);
// Go fishing for this link's configuration window
QList<QAction*> actions = ui.menuNetwork->actions();
bool found = false;
foreach (QAction* act, actions)
if (act->data().toInt() == LinkManager::instance()->getLinks().indexOf(link))
{
found = true;
}
}
UDPLink* udp = dynamic_cast<UDPLink*>(link);
if (!found || udp)
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
QAction* action = commWidget->getAction();
ui.menuNetwork->addAction(action);
// Error handling
connect(link, SIGNAL(communicationError(QString,QString)), this, SLOT(showCriticalMessage(QString,QString)), Qt::QueuedConnection);
// Special case for simulationlink
MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
if (sim)
{
//connect(sim, SIGNAL(valueChanged(int,QString,double,quint64)), linechart, SLOT(appendData(int,QString,double,quint64)));
connect(ui.actionSimulate, SIGNAL(triggered(bool)), sim, SLOT(connectLink(bool)));
}
void MainWindow::setActiveUAS(UASInterface* uas)
{
// Enable and rename menu
ui.menuUnmanned_System->setTitle(uas->getUASName());
if (!ui.menuUnmanned_System->isEnabled()) ui.menuUnmanned_System->setEnabled(true);
}
void MainWindow::UASSpecsChanged(int uas)
{
UASInterface* activeUAS = UASManager::instance()->getActiveUAS();
if (activeUAS)
{
if (activeUAS->getUASID() == uas)
{
ui.menuUnmanned_System->setTitle(activeUAS->getUASName());
}
}
}
if (uas != NULL)
{
// Set default settings
setDefaultSettingsForAp();
// The pilot, operator and engineer views were not available on startup, enable them now
ui.actionOperatorsView->setEnabled(true);
ui.actionEngineersView->setEnabled(true);
// The UAS actions are not enabled without connection to system
ui.actionLiftoff->setEnabled(true);
ui.actionLand->setEnabled(true);
ui.actionEmergency_Kill->setEnabled(true);
ui.actionEmergency_Land->setEnabled(true);
ui.actionShutdownMAV->setEnabled(true);
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
QIcon icon;
// Set matching icon
switch (uas->getSystemType())
{
case 0:
icon = QIcon(":/images/mavs/generic.svg");
break;
case 1:
icon = QIcon(":/images/mavs/fixed-wing.svg");
break;
case 2:
icon = QIcon(":/images/mavs/quadrotor.svg");
break;
case 3:
icon = QIcon(":/images/mavs/coaxial.svg");
break;
case 4:
icon = QIcon(":/images/mavs/helicopter.svg");
break;
case 5:
icon = QIcon(":/images/mavs/groundstation.svg");
break;
default:
icon = QIcon(":/images/mavs/unknown.svg");
break;
}
QAction* uasAction = new QAction(icon, tr("Select %1 for control").arg(uas->getUASName()), ui.menuConnected_Systems);
connect(uas, SIGNAL(systemRemoved()), uasAction, SLOT(deleteLater()));
connect(uasAction, SIGNAL(triggered()), uas, SLOT(setSelected()));
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
ui.menuConnected_Systems->addAction(uasAction);
// FIXME Should be not inside the mainwindow
if (debugConsoleDockWidget)
{
DebugConsole *debugConsole = dynamic_cast<DebugConsole*>(debugConsoleDockWidget->widget());
if (debugConsole)
{
connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)),
debugConsole, SLOT(receiveTextMessage(int,int,int,QString)));
}
// Health / System status indicator
if (infoDockWidget)
{
UASInfoWidget *infoWidget = dynamic_cast<UASInfoWidget*>(infoDockWidget->widget());
if (infoWidget)
{
infoWidget->addUAS(uas);
}
// UAS List
if (listDockWidget)
{
UASListWidget *listWidget = dynamic_cast<UASListWidget*>(listDockWidget->widget());
if (listWidget)
{
listWidget->addUAS(uas);
}
switch (uas->getAutopilotType())
{
case (MAV_AUTOPILOT_SLUGS):
{
// Build Slugs Widgets
buildSlugsWidgets();
// Connect Slugs Widgets
connectSlugsWidgets();
// Arrange Slugs Centerstack
arrangeSlugsCenterStack();
// Connect Slugs Actions
connectSlugsActions();
Mariano Lizarraga
committed
// if(slugsDataWidget)
// {
// SlugsDataSensorView *mm = dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget());
// if(mm)
// {
// mm->addUAS(uas);
// }
// }
// FIXME: This type checking might be redundant
Mariano Lizarraga
committed
// // if (slugsDataWidget) {
// // SlugsDataSensorView* dataWidget = dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget());
// // if (dataWidget) {
// // SlugsMAV* mav2 = dynamic_cast<SlugsMAV*>(uas);
// // if (mav2) {
// (dynamic_cast<SlugsDataSensorView*>(slugsDataWidget->widget()))->addUAS(uas);
// // //loadSlugsView();
// // loadGlobalOperatorView();
// // }
// // }
// // }
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
}
break;
default:
case (MAV_AUTOPILOT_GENERIC):
case (MAV_AUTOPILOT_ARDUPILOTMEGA):
case (MAV_AUTOPILOT_PIXHAWK):
{
// Build Pixhawk Widgets
buildPxWidgets();
// Connect Pixhawk Widgets
connectPxWidgets();
// Arrange Pixhawk Centerstack
arrangePxCenterStack();
// Connect Pixhawk Actions
connectPxActions();
}
break;
}
// Change the view only if this is the first UAS
// If this is the first connected UAS, it is both created as well as
// the currently active UAS
if (UASManager::instance()->getUASList().size() == 1)
{
// Load last view if setting is present
if (settings.contains("CURRENT_VIEW_WITH_UAS_CONNECTED"))
int view = settings.value("CURRENT_VIEW_WITH_UAS_CONNECTED").toInt();
case VIEW_ENGINEER:
loadEngineerView();
break;
case VIEW_MAVLINK:
loadMAVLinkView();
break;
case VIEW_PILOT:
loadPilotView();
break;
case VIEW_UNCONNECTED:
loadUnconnectedView();
break;
case VIEW_OPERATOR:
default:
loadOperatorView();
break;
Mariano Lizarraga
committed
if (!ui.menuConnected_Systems->isEnabled()) ui.menuConnected_Systems->setEnabled(true);
// Custom widgets, added last to all menus and layouts
buildCustomWidget();
// Restore the mainwindow size
if (settings.contains(getWindowGeometryKey()))
{
restoreGeometry(settings.value(getWindowGeometryKey()).toByteArray());
}
/**
* Clears the current view completely
*/
if (UASManager::instance()->getUASList().count() > 0) settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion()));
// Although we want save the state of the window, we do not want to change the top-leve state (minimized, maximized, etc)
// therefore this state is stored here and restored after applying the rest of the settings in the new
// perspective.
windowStateVal = this->windowState();
settings.setValue(getWindowGeometryKey(), saveGeometry());
QAction* temp;
// Set tool widget visibility settings for this view
foreach (int key, toolsMenuActions.keys())
{
temp = toolsMenuActions[key];
QString chKey = buildMenuKey (SUB_SECTION_CHECKED,static_cast<TOOLS_WIDGET_NAMES>(key), currentView);
if (temp)
{
//qDebug() << "TOOL:" << chKey << "IS:" << temp->isChecked();
settings.setValue(chKey,temp->isChecked());
}
else
{
//qDebug() << "TOOL:" << chKey << "IS DEFAULT AND UNCHECKED";
settings.setValue(chKey,false);
}
}
changingViewsFlag = true;
// Remove all dock widgets from main window
QObjectList childList( this->children() );
QObjectList::iterator i;
QDockWidget* dockWidget;
for (i = childList.begin(); i != childList.end(); ++i)
dockWidget = dynamic_cast<QDockWidget*>(*i);
if (dockWidget)
// Remove dock widget from main window
changingViewsFlag = false;
Mariano Lizarraga
committed
void MainWindow::loadEngineerView()
if (currentView != VIEW_ENGINEER)
{
clearView();
currentView = VIEW_ENGINEER;
ui.actionEngineersView->setChecked(true);
presentView();
Mariano Lizarraga
committed
void MainWindow::loadOperatorView()
if (currentView != VIEW_OPERATOR)
{
clearView();
currentView = VIEW_OPERATOR;
ui.actionOperatorsView->setChecked(true);
presentView();
}
}
void MainWindow::loadUnconnectedView()
{
if (currentView != VIEW_UNCONNECTED)
{
clearView();
currentView = VIEW_UNCONNECTED;
ui.actionUnconnectedView->setChecked(true);
presentView();
Mariano Lizarraga
committed
void MainWindow::loadPilotView()
clearView();
currentView = VIEW_PILOT;
ui.actionPilotsView->setChecked(true);
presentView();
Mariano Lizarraga
committed
void MainWindow::loadMAVLinkView()
clearView();
currentView = VIEW_MAVLINK;
ui.actionMavlinkView->setChecked(true);
presentView();
}
showTheCentralWidget(CENTRAL_LINECHART, currentView);
// MAP
showTheCentralWidget(CENTRAL_MAP, currentView);
// PROTOCOL
showTheCentralWidget(CENTRAL_PROTOCOL, currentView);
// HEAD UP DISPLAY
showTheCentralWidget(CENTRAL_HUD, currentView);
// GOOGLE EARTH
showTheCentralWidget(CENTRAL_GOOGLE_EARTH, currentView);
// LOCAL 3D VIEW
showTheCentralWidget(CENTRAL_3D_LOCAL, currentView);
// GLOBAL 3D VIEW
showTheCentralWidget(CENTRAL_3D_MAP, currentView);
// DATA PLOT
showTheCentralWidget(CENTRAL_DATA_PLOT, currentView);
// Show docked widgets based on current view and autopilot type
// UAS CONTROL
showTheWidget(MENU_UAS_CONTROL, currentView);
showTheWidget(MENU_UAS_CONTROL_PARAM, currentView);
// UAS LIST
showTheWidget(MENU_UAS_LIST, currentView);
// WAYPOINT LIST
showTheWidget(MENU_WAYPOINTS, currentView);
// UAS STATUS
showTheWidget(MENU_STATUS, currentView);
Mariano Lizarraga
committed
// DETECTION
showTheWidget(MENU_DETECTION, currentView);
Mariano Lizarraga
committed
// DEBUG CONSOLE
showTheWidget(MENU_DEBUG_CONSOLE, currentView);
Mariano Lizarraga
committed
// ONBOARD PARAMETERS
showTheWidget(MENU_PARAMETERS, currentView);
Mariano Lizarraga
committed
// WATCHDOG
showTheWidget(MENU_WATCHDOG, currentView);
Mariano Lizarraga
committed
// HUD
showTheWidget(MENU_HUD, currentView);
if (headUpDockWidget)
{
HUD* tmpHud = dynamic_cast<HUD*>( headUpDockWidget->widget() );
if (tmpHud)
{
if (settings.value(buildMenuKey (SUB_SECTION_CHECKED,MENU_HUD,currentView)).toBool())
{
addDockWidget(static_cast <Qt::DockWidgetArea>(settings.value(buildMenuKey (SUB_SECTION_LOCATION,MENU_HUD, currentView)).toInt()),
headUpDockWidget);