Newer
Older
void MainWindow::showHelp()
{
_openUrl("http://qgroundcontrol.org/users/start",
tr("To get to the online help, please open http://qgroundcontrol.org/user_guide in a browser."));
}
void MainWindow::showCredits()
{
_openUrl("http://qgroundcontrol.org/credits",
tr("To get to the credits, please open http://qgroundcontrol.org/credits in a browser."));
}
void MainWindow::showRoadMap()
{
_openUrl("http://qgroundcontrol.org/dev/roadmap",
tr("To get to the online help, please open http://qgroundcontrol.org/roadmap in a browser."));
}
void MainWindow::showSettings()
{
SettingsDialog settings(joystick, this);
settings.exec();
// FIXME: Where is this called from
LinkInterface* MainWindow::addLink()
{
SerialLink* link = new SerialLink();
// TODO This should be only done in the dialog itself
LinkManager::instance()->addLink(link);
// Go fishing for this link's configuration window
QList<QAction*> actions = ui.menuNetwork->actions();
const int32_t& linkIndex(LinkManager::instance()->getLinks().indexOf(link));
const int32_t& linkID(LinkManager::instance()->getLinks()[linkIndex]->getId());
foreach (QAction* act, actions)
{
if (act->data().toInt() == linkID)
act->trigger();
break;
}
}
bool MainWindow::configLink(LinkInterface *link)
{
// Go searching for this link's configuration window
QList<QAction*> actions = ui.menuNetwork->actions();
bool found(false);
const int32_t& linkIndex(LinkManager::instance()->getLinks().indexOf(link));
const int32_t& linkID(LinkManager::instance()->getLinks()[linkIndex]->getId());
foreach (QAction* action, actions)
{
if (action->data().toInt() == linkID)
found = true;
action->trigger(); // Show the Link Config Dialog
}
}
return found;
}
void MainWindow::_addLinkMenu(LinkInterface *link)
{
// Go fishing for this link's configuration window
QList<QAction*> actions = ui.menuNetwork->actions();
const int32_t& linkIndex(LinkManager::instance()->getLinks().indexOf(link));
const int32_t& linkID(LinkManager::instance()->getLinks()[linkIndex]->getId());
foreach (QAction* act, actions) {
if (act->data().toInt() == linkID) {
alreadyAdded = true;
break;
if (!alreadyAdded) {
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, this);
Michael Carpenter
committed
commsWidgetList.append(commWidget);
connect(commWidget,SIGNAL(destroyed(QObject*)),this,SLOT(commsWidgetDestroyed(QObject*)));
QAction* action = commWidget->getAction();
ui.menuNetwork->addAction(action);
}
}
void MainWindow::simulateLink(bool simulate) {
if (simulate) {
if (!simulationLink) {
simulationLink = new MAVLinkSimulationLink(":/demo-log.txt");
Q_CHECK_PTR(simulationLink);
}
LinkManager::instance()->connectLink(simulationLink);
} else {
Q_ASSERT(simulationLink);
LinkManager::instance()->disconnectLink(simulationLink);
}
Michael Carpenter
committed
void MainWindow::commsWidgetDestroyed(QObject *obj)
{
// Do not dynamic cast or de-reference QObject, since object is either in destructor or may have already
// been destroyed.
Michael Carpenter
committed
if (commsWidgetList.contains(obj))
{
commsWidgetList.removeOne(obj);
}
}
void MainWindow::setActiveUAS(UASInterface* uas)
{
Michael Carpenter
committed
if (settings.contains(getWindowStateKey()))
{
restoreState(settings.value(getWindowStateKey()).toByteArray());
Michael Carpenter
committed
}
}
void MainWindow::UASSpecsChanged(int uas)
{
Q_UNUSED(uas);
// TODO: Update UAS properties if its specs change
}
void MainWindow::UASCreated(UASInterface* uas)
{
1146
1147
1148
1149
1150
1151
1152
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
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
// 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);
QIcon icon;
// Set matching icon
switch (uas->getSystemType())
{
case MAV_TYPE_GENERIC:
icon = QIcon(":files/images/mavs/generic.svg");
break;
case MAV_TYPE_FIXED_WING:
icon = QIcon(":files/images/mavs/fixed-wing.svg");
break;
case MAV_TYPE_QUADROTOR:
icon = QIcon(":files/images/mavs/quadrotor.svg");
break;
case MAV_TYPE_COAXIAL:
icon = QIcon(":files/images/mavs/coaxial.svg");
break;
case MAV_TYPE_HELICOPTER:
icon = QIcon(":files/images/mavs/helicopter.svg");
break;
case MAV_TYPE_ANTENNA_TRACKER:
icon = QIcon(":files/images/mavs/antenna-tracker.svg");
break;
case MAV_TYPE_GCS:
icon = QIcon(":files/images/mavs/groundstation.svg");
break;
case MAV_TYPE_AIRSHIP:
icon = QIcon(":files/images/mavs/airship.svg");
break;
case MAV_TYPE_FREE_BALLOON:
icon = QIcon(":files/images/mavs/free-balloon.svg");
break;
case MAV_TYPE_ROCKET:
icon = QIcon(":files/images/mavs/rocket.svg");
break;
case MAV_TYPE_GROUND_ROVER:
icon = QIcon(":files/images/mavs/ground-rover.svg");
break;
case MAV_TYPE_SURFACE_BOAT:
icon = QIcon(":files/images/mavs/surface-boat.svg");
break;
case MAV_TYPE_SUBMARINE:
icon = QIcon(":files/images/mavs/submarine.svg");
break;
case MAV_TYPE_HEXAROTOR:
icon = QIcon(":files/images/mavs/hexarotor.svg");
break;
case MAV_TYPE_OCTOROTOR:
icon = QIcon(":files/images/mavs/octorotor.svg");
break;
case MAV_TYPE_TRICOPTER:
icon = QIcon(":files/images/mavs/tricopter.svg");
break;
case MAV_TYPE_FLAPPING_WING:
icon = QIcon(":files/images/mavs/flapping-wing.svg");
break;
case MAV_TYPE_KITE:
icon = QIcon(":files/images/mavs/kite.svg");
break;
default:
icon = QIcon(":files/images/mavs/unknown.svg");
break;
}
Lorenz Meier
committed
connect(uas, SIGNAL(systemSpecsChanged(int)), this, SLOT(UASSpecsChanged(int)));
connect(uas, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), this, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)));
Lorenz Meier
committed
connect(uas, SIGNAL(misconfigurationDetected(UASInterface*)), this, SLOT(handleMisconfiguration(UASInterface*)));
Lorenz Meier
committed
// HIL
_showHILConfigurationWidgets();
Lorenz Meier
committed
if (!linechartWidget)
{
linechartWidget = new Linecharts(this);
linechartWidget->setVisible(false);
Lorenz Meier
committed
}
Michael Carpenter
committed
Lorenz Meier
committed
linechartWidget->addSource(mavlinkDecoder);
if (_engineeringView != linechartWidget)
Lorenz Meier
committed
{
_engineeringView = linechartWidget;
Lorenz Meier
committed
}
// Reload view state in case new widgets were added
_loadCurrentViewState();
}
void MainWindow::UASDeleted(UASInterface* uas)
{
// TODO: Update the UI when a UAS is deleted
/// Stores the state of the toolbar, status bar and widgets associated with the current view
void MainWindow::_storeCurrentViewState(void)
// HIL dock widgets are dynamic and are not part of the saved state
_hideAllHilDockWidgets();
// Save list of visible widgets
bool firstWidget = true;
QString widgetNames = "";
foreach(QDockWidget* dockWidget, _mapName2DockWidget) {
if (dockWidget->isVisible()) {
if (!firstWidget) {
widgetNames += ",";
}
widgetNames += dockWidget->objectName();
firstWidget = false;
}
settings.setValue(getWindowStateKey() + "WIDGETS", widgetNames);
settings.setValue(getWindowStateKey(), saveState());
settings.setValue(getWindowGeometryKey(), saveGeometry());
/// Restores the state of the toolbar, status bar and widgets associated with the current view
void MainWindow::_loadCurrentViewState(void)
QString defaultWidgets;
switch (_currentView) {
_buildSetupView();
centerView = _setupView;
break;
case VIEW_ENGINEER:
_buildEngineeringView();
centerView = _engineeringView;
defaultWidgets = "MAVLINK_INSPECTOR_DOCKWIDGET,PARAMETER_INTERFACE_DOCKWIDGET,FILE_VIEW_DOCKWIDGET,HEAD_UP_DISPLAY_DOCKWIDGET";
case VIEW_FLIGHT:
_buildPilotView();
centerView = _pilotView;
defaultWidgets = "COMMUNICATION_CONSOLE_DOCKWIDGET,UAS_INFO_INFOVIEW_DOCKWIDGET";
case VIEW_MISSION:
_buildPlannerView();
centerView = _plannerView;
defaultWidgets = "UNMANNED_SYSTEM_LIST_DOCKWIDGET,WAYPOINT_LIST_DOCKWIDGET";
case VIEW_SIMULATION:
_buildSimView();
centerView = _simView;
defaultWidgets = "UNMANNED_SYSTEM_CONTROL_DOCKWIDGET,WAYPOINT_LIST_DOCKWIDGET,PARAMETER_INTERFACE_DOCKWIDGET,PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET";
_buildTerminalView();
centerView = _terminalView;
case VIEW_GOOGLEEARTH:
_buildGoogleEarthView();
centerView = _googleEarthView;
case VIEW_LOCAL3D:
_buildLocal3DView();
centerView = _local3DView;
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
}
// Remove old view
if (_currentViewWidget) {
_currentViewWidget->setVisible(false);
Q_ASSERT(_centralLayout->count() == 1);
QLayoutItem *child = _centralLayout->takeAt(0);
Q_ASSERT(child);
delete child;
}
// Add the new one
Q_ASSERT(centerView);
Q_ASSERT(_centralLayout->count() == 0);
_currentViewWidget = centerView;
_centralLayout->addWidget(_currentViewWidget);
_currentViewWidget->setVisible(true);
// Hide all widgets from previous view
_hideAllDockWidgets();
// Restore the widgets for the new view
QString widgetNames = settings.value(getWindowStateKey() + "WIDGETS", defaultWidgets).toString();
if (!widgetNames.isEmpty()) {
QStringList split = widgetNames.split(",");
foreach (QString widgetName, split) {
Q_ASSERT(!widgetName.isEmpty());
_showDockWidget(widgetName, true);
if (settings.contains(getWindowStateKey())) {
restoreState(settings.value(getWindowStateKey()).toByteArray());
Michael Carpenter
committed
}
// HIL dock widget are dynamic and don't take part in the saved window state, so this
// need to happen after we restore state
_showHILConfigurationWidgets();
}
void MainWindow::_hideAllHilDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapUasId2HilDockWidget) {
dockWidget->setVisible(false);
}
}
void MainWindow::_hideAllDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapName2DockWidget) {
dockWidget->setVisible(false);
_hideAllHilDockWidgets();
void MainWindow::_showDockWidgetAction(bool show)
Michael Carpenter
committed
{
QAction* action = dynamic_cast<QAction*>(QObject::sender());
Q_ASSERT(action);
_showDockWidget(action->data().toString(), show);
Michael Carpenter
committed
}
void MainWindow::handleMisconfiguration(UASInterface* uas)
{
static QTime lastTime;
// We have to debounce this signal
if (!lastTime.isValid()) {
lastTime.start();
} else {
if (lastTime.elapsed() < 10000) {
lastTime.start();
return;
}
}
Lorenz Meier
committed
// Ask user if he wants to handle this now
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Missing or Invalid Onboard Configuration"),
tr("The onboard system configuration is missing or incomplete. Do you want to resolve this now?"),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
if (button == QMessageBox::Ok) {
Lorenz Meier
committed
// He wants to handle it, make sure this system is selected
UASManager::instance()->setActiveUAS(uas);
// Flick to config view
Lorenz Meier
committed
}
}
void MainWindow::loadEngineerView()
{
if (_currentView != VIEW_ENGINEER)
_storeCurrentViewState();
_currentView = VIEW_ENGINEER;
ui.actionEngineersView->setChecked(true);
_loadCurrentViewState();
}
}
void MainWindow::loadOperatorView()
{
if (_currentView != VIEW_MISSION)
_storeCurrentViewState();
_currentView = VIEW_MISSION;
ui.actionMissionView->setChecked(true);
_loadCurrentViewState();
void MainWindow::loadSetupView()
Michael Carpenter
committed
{
if (_currentView != VIEW_SETUP)
Michael Carpenter
committed
{
_storeCurrentViewState();
_currentView = VIEW_SETUP;
ui.actionSetup->setChecked(true);
_loadCurrentViewState();
Michael Carpenter
committed
}
}
void MainWindow::loadTerminalView()
{
if (_currentView != VIEW_TERMINAL)
_storeCurrentViewState();
_currentView = VIEW_TERMINAL;
ui.actionTerminalView->setChecked(true);
_loadCurrentViewState();
void MainWindow::loadGoogleEarthView()
{
if (_currentView != VIEW_GOOGLEEARTH)
_storeCurrentViewState();
_currentView = VIEW_GOOGLEEARTH;
ui.actionGoogleEarthView->setChecked(true);
_loadCurrentViewState();
}
}
void MainWindow::loadLocal3DView()
{
if (_currentView != VIEW_LOCAL3D)
_storeCurrentViewState();
_currentView = VIEW_LOCAL3D;
ui.actionLocal3DView->setChecked(true);
_loadCurrentViewState();
}
}
void MainWindow::loadPilotView()
{
if (_currentView != VIEW_FLIGHT)
_storeCurrentViewState();
_currentView = VIEW_FLIGHT;
ui.actionFlightView->setChecked(true);
_loadCurrentViewState();
void MainWindow::loadSimulationView()
{
if (_currentView != VIEW_SIMULATION)
_storeCurrentViewState();
_currentView = VIEW_SIMULATION;
ui.actionSimulationView->setChecked(true);
_loadCurrentViewState();
John Tapsell
committed
QList<QAction*> MainWindow::listLinkMenuActions()
{
return ui.menuNetwork->actions();
}
/// @brief Hides the spash screen if it is currently being shown
void MainWindow::hideSplashScreen(void)
{
if (_splashScreen) {
_splashScreen->hide();
_splashScreen = NULL;
}
}
bool MainWindow::x11Event(XEvent *event)
{
emit x11EventOccured(event);
Matthias Krebs
committed
return false;