Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
prevAddr = true;
}
}
windowname.append(")");
setWindowTitle(windowname);
}
void MainWindow::startVideoCapture()
{
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);
}
void MainWindow::stopVideoCapture()
{
videoTimer->stop();
// TODO Convert raw images to PNG
}
void MainWindow::saveScreen()
{
QPixmap window = QPixmap::grabWindow(this->winId());
QString format = "bmp";
if (!screenFileName.isEmpty())
{
window.save(screenFileName, format.toLatin1());
Michael Carpenter
committed
void MainWindow::enableDockWidgetTitleBars(bool enabled)
{
John Tapsell
committed
menuActionHelper->setDockWidgetTitleBarsEnabled(enabled);
QSettings settings;
settings.beginGroup("QGC_MAINWINDOW");
John Tapsell
committed
settings.setValue("DOCK_WIDGET_TITLEBARS",enabled);
settings.endGroup();
settings.sync();
Michael Carpenter
committed
}
void MainWindow::enableAutoReconnect(bool enabled)
{
autoReconnect = enabled;
}
bool MainWindow::loadStyle(QGC_MAINWINDOW_STYLE style)
bool success = true;
QString styles;
// Signal to the user that the app will pause to apply a new stylesheet
qApp->setOverrideCursor(Qt::WaitCursor);
// Store the new style classification.
currentStyle = style;
// The dark style sheet is the master. Any other selected style sheet just overrides
// the colors of the master sheet.
QFile masterStyleSheet(defaultDarkStyle);
if (masterStyleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) {
styles = masterStyleSheet.readAll();
} else {
qDebug() << "Unable to load master dark style sheet";
if (success && style == QGC_MAINWINDOW_STYLE_LIGHT) {
qDebug() << "LOADING LIGHT";
// Load the slave light stylesheet.
QFile styleSheet(defaultLightStyle);
if (styleSheet.open(QIODevice::ReadOnly | QIODevice::Text)) {
styles += styleSheet.readAll();
} else {
qDebug() << "Unable to load slave light sheet:";
if (!styles.isEmpty()) {
qApp->setStyleSheet(styles);
emit styleChanged(style);
}
// Finally restore the cursor before returning.
qApp->restoreOverrideCursor();
return success;
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
}
/**
* 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)
{
statusBar()->showMessage(status, 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)
{
statusBar()->showMessage(status, 20000);
}
void MainWindow::showCriticalMessage(const QString& title, const QString& message)
{
QMessageBox msgBox(this);
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)
{
QMessageBox msgBox(this);
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
*
**/
void MainWindow::connectCommonActions()
{
// Bind together the perspective actions
QActionGroup* perspectives = new QActionGroup(ui.menuPerspectives);
perspectives->addAction(ui.actionEngineersView);
perspectives->addAction(ui.actionFlightView);
perspectives->addAction(ui.actionSimulationView);
perspectives->addAction(ui.actionMissionView);
perspectives->addAction(ui.actionSetup);
perspectives->addAction(ui.actionTerminalView);
perspectives->addAction(ui.actionGoogleEarthView);
perspectives->addAction(ui.actionLocal3DView);
perspectives->setExclusive(true);
/* Hide the actions that are not relevant */
John Tapsell
committed
#ifndef QGC_GOOGLE_EARTH_ENABLED
ui.actionGoogleEarthView->setVisible(false);
#endif
#ifndef QGC_OSG_ENABLED
ui.actionLocal3DView->setVisible(false);
#endif
// Mark the right one as selected
if (currentView == VIEW_ENGINEER)
{
ui.actionEngineersView->setChecked(true);
ui.actionEngineersView->activate(QAction::Trigger);
}
if (currentView == VIEW_FLIGHT)
{
ui.actionFlightView->setChecked(true);
ui.actionFlightView->activate(QAction::Trigger);
}
if (currentView == VIEW_SIMULATION)
{
ui.actionSimulationView->setChecked(true);
ui.actionSimulationView->activate(QAction::Trigger);
}
if (currentView == VIEW_MISSION)
{
ui.actionMissionView->setChecked(true);
ui.actionMissionView->activate(QAction::Trigger);
}
if (currentView == VIEW_SETUP)
ui.actionSetup->setChecked(true);
ui.actionSetup->activate(QAction::Trigger);
Michael Carpenter
committed
}
if (currentView == VIEW_SOFTWARE_CONFIG)
Michael Carpenter
committed
ui.actionSoftwareConfig->setChecked(true);
ui.actionSoftwareConfig->activate(QAction::Trigger);
if (currentView == VIEW_TERMINAL)
{
ui.actionTerminalView->setChecked(true);
ui.actionTerminalView->activate(QAction::Trigger);
}
if (currentView == VIEW_GOOGLEEARTH)
{
ui.actionGoogleEarthView->setChecked(true);
ui.actionGoogleEarthView->activate(QAction::Trigger);
}
if (currentView == VIEW_LOCAL3D)
{
ui.actionLocal3DView->setChecked(true);
ui.actionLocal3DView->activate(QAction::Trigger);
}
// 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()));
John Tapsell
committed
ui.actionAdvanced_Mode->setChecked(menuActionHelper->isAdvancedMode());
connect(ui.actionAdvanced_Mode,SIGNAL(toggled(bool)),this,SLOT(setAdvancedMode(bool)));
// Connect internal actions
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(UASCreated(UASInterface*)));
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
// 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()));
// Views actions
connect(ui.actionFlightView, SIGNAL(triggered()), this, SLOT(loadPilotView()));
connect(ui.actionSimulationView, SIGNAL(triggered()), this, SLOT(loadSimulationView()));
connect(ui.actionEngineersView, SIGNAL(triggered()), this, SLOT(loadEngineerView()));
connect(ui.actionMissionView, SIGNAL(triggered()), this, SLOT(loadOperatorView()));
connect(ui.actionSetup,SIGNAL(triggered()),this,SLOT(loadSetupView()));
connect(ui.actionGoogleEarthView, SIGNAL(triggered()), this, SLOT(loadGoogleEarthView()));
connect(ui.actionLocal3DView, SIGNAL(triggered()), this, SLOT(loadLocal3DView()));
connect(ui.actionSoftwareConfig,SIGNAL(triggered()),this,SLOT(loadSoftwareConfigView()));
connect(ui.actionTerminalView,SIGNAL(triggered()),this,SLOT(loadTerminalView()));
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
// Help Actions
connect(ui.actionOnline_Documentation, SIGNAL(triggered()), this, SLOT(showHelp()));
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()));
connect(ui.actionLoadCustomWidgetFile, SIGNAL(triggered()), this, SLOT(loadCustomWidget()));
// 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);
// Application Settings
connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
connect(ui.actionSimulate, SIGNAL(triggered(bool)), this, SLOT(simulateLink(bool)));
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
}
void MainWindow::showHelp()
{
if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/users/start")))
{
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/dev/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();
}
}
void MainWindow::showSettings()
{
QGCSettingsWidget* settings = new QGCSettingsWidget(joystick, this);
settings->show();
}
LinkInterface* MainWindow::addLink()
{
SerialLink* link = new SerialLink();
// TODO This should be only done in the dialog itself
LinkManager::instance()->add(link);
LinkManager::instance()->addProtocol(link, mavlink);
// 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::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);
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)
found = true;
}
}
if (!found)
John Tapsell
committed
CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
Michael Carpenter
committed
commsWidgetList.append(commWidget);
connect(commWidget,SIGNAL(destroyed(QObject*)),this,SLOT(commsWidgetDestroyed(QObject*)));
QAction* action = commWidget->getAction();
ui.menuNetwork->addAction(action);
// Error handling
connect(link, SIGNAL(communicationError(QString,QString)), this, SLOT(showCriticalMessage(QString,QString)), Qt::QueuedConnection);
}
}
void MainWindow::simulateLink(bool simulate) {
if (!simulationLink)
simulationLink = new MAVLinkSimulationLink(":/demo-log.txt");
simulationLink->connectLink(simulate);
}
Michael Carpenter
committed
void MainWindow::commsWidgetDestroyed(QObject *obj)
{
if (commsWidgetList.contains(obj))
{
commsWidgetList.removeOne(obj);
}
}
void MainWindow::setActiveUAS(UASInterface* uas)
{
Michael Carpenter
committed
if (settings.contains(getWindowStateKey()))
{
SubMainWindow *win = qobject_cast<SubMainWindow*>(centerStack->currentWidget());
win->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)
{
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
// The pilot, operator and engineer views were not available on startup, enable them now
ui.actionFlightView->setEnabled(true);
ui.actionMissionView->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);
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
showHILConfigurationWidget(uas);
Lorenz Meier
committed
if (!linechartWidget)
{
linechartWidget = new Linecharts(this);
}
Michael Carpenter
committed
Lorenz Meier
committed
linechartWidget->addSource(mavlinkDecoder);
if (engineeringView->centralWidget() != linechartWidget)
{
engineeringView->setCentralWidget(linechartWidget);
linechartWidget->show();
}
Lorenz Meier
committed
// Load default custom widgets for this autopilot type
loadCustomWidgetsFromDefaults(uas->getSystemTypeName(), uas->getAutopilotTypeName());
Lorenz Meier
committed
if (uas->getAutopilotType() == MAV_AUTOPILOT_PIXHAWK)
{
// Dock widgets
if (!detectionDockWidget)
Lorenz Meier
committed
detectionDockWidget = new QDockWidget(tr("Object Recognition"), this);
detectionDockWidget->setWidget( new ObjectDetectionView("files/images/patterns", this) );
detectionDockWidget->setObjectName("OBJECT_DETECTION_DOCK_WIDGET");
}
Lorenz Meier
committed
if (!watchdogControlDockWidget)
{
watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this);
watchdogControlDockWidget->setWidget( new WatchdogControl(this) );
watchdogControlDockWidget->setObjectName("WATCHDOG_CONTROL_DOCKWIDGET");
Lorenz Meier
committed
}
// Reload view state in case new widgets were added
loadViewState();
}
void MainWindow::UASDeleted(UASInterface* uas)
{
// TODO: Update the UI when a UAS is deleted
}
/**
* Stores the current view state
*/
void MainWindow::storeViewState()
{
if (!aboutToCloseFlag)
{
// Save current state
Michael Carpenter
committed
SubMainWindow *win = qobject_cast<SubMainWindow*>(centerStack->currentWidget());
QList<QDockWidget*> widgets = win->findChildren<QDockWidget*>();
QString widgetnames = "";
for (int i=0;i<widgets.size();i++)
{
widgetnames += widgets[i]->objectName() + ",";
}
widgetnames = widgetnames.mid(0,widgetnames.length()-1);
settings.setValue(getWindowStateKey() + "WIDGETS",widgetnames);
settings.setValue(getWindowStateKey(), win->saveState());
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
settings.setValue(getWindowStateKey()+"CENTER_WIDGET", centerStack->currentIndex());
// 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());
}
}
void MainWindow::loadViewState()
{
// Restore center stack state
int index = settings.value(getWindowStateKey()+"CENTER_WIDGET", -1).toInt();
if (index != -1)
{
centerStack->setCurrentIndex(index);
}
else
{
// Hide custom widgets
if (detectionDockWidget) detectionDockWidget->hide();
if (watchdogControlDockWidget) watchdogControlDockWidget->hide();
// Load defaults
switch (currentView)
{
case VIEW_SETUP:
centerStack->setCurrentWidget(setupView);
break;
Michael Carpenter
committed
case VIEW_SOFTWARE_CONFIG:
if (softwareConfigView)
centerStack->setCurrentWidget(softwareConfigView);
Michael Carpenter
committed
break;
case VIEW_ENGINEER:
Lorenz Meier
committed
centerStack->setCurrentWidget(engineeringView);
case VIEW_FLIGHT:
Michael Carpenter
committed
centerStack->setCurrentWidget(pilotView);
case VIEW_MISSION:
Michael Carpenter
committed
centerStack->setCurrentWidget(plannerView);
case VIEW_SIMULATION:
Michael Carpenter
committed
centerStack->setCurrentWidget(simView);
case VIEW_TERMINAL:
centerStack->setCurrentWidget(terminalView);
break;
case VIEW_GOOGLEEARTH:
centerStack->setCurrentWidget(googleEarthView);
break;
case VIEW_LOCAL3D:
centerStack->setCurrentWidget(local3DView);
break;
Michael Carpenter
committed
if (controlDockWidget)
{
controlDockWidget->hide();
}
if (listDockWidget)
{
listDockWidget->show();
}
break;
}
}
// Restore the widget positions and size
Michael Carpenter
committed
if (settings.contains(getWindowStateKey() + "WIDGETS"))
{
QString widgetstr = settings.value(getWindowStateKey() + "WIDGETS").toString();
QStringList split = widgetstr.split(",");
foreach (QString widgetname,split)
{
if (widgetname != "")
{
Michael Carpenter
committed
qDebug() << "Loading widget:" << widgetname;
Michael Carpenter
committed
loadDockWidget(widgetname);
}
}
}
if (settings.contains(getWindowStateKey()))
{
Michael Carpenter
committed
SubMainWindow *win = qobject_cast<SubMainWindow*>(centerStack->currentWidget());
win->restoreState(settings.value(getWindowStateKey()).toByteArray());
John Tapsell
committed
void MainWindow::setAdvancedMode(bool isAdvancedMode)
Michael Carpenter
committed
{
John Tapsell
committed
menuActionHelper->setAdvancedMode(isAdvancedMode);
ui.actionAdvanced_Mode->setChecked(isAdvancedMode);
settings.setValue("ADVANCED_MODE",isAdvancedMode);
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 msgBox(this);
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Missing or Invalid Onboard Configuration"));
msgBox.setInformativeText(tr("The onboard system configuration is missing or incomplete. Do you want to resolve this now?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
int val = msgBox.exec();
if (val == QMessageBox::Ok) {
// 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)
{
storeViewState();
currentView = VIEW_ENGINEER;
ui.actionEngineersView->setChecked(true);
loadViewState();
}
}
void MainWindow::loadOperatorView()
{
if (currentView != VIEW_MISSION)
{
storeViewState();
currentView = VIEW_MISSION;
ui.actionMissionView->setChecked(true);
loadViewState();
}
}
void MainWindow::loadSetupView()
Michael Carpenter
committed
{
if (currentView != VIEW_SETUP)
Michael Carpenter
committed
{
storeViewState();
currentView = VIEW_SETUP;
ui.actionSetup->setChecked(true);
Michael Carpenter
committed
loadViewState();
}
}
void MainWindow::loadSoftwareConfigView()
Michael Carpenter
committed
if (currentView != VIEW_SOFTWARE_CONFIG)
{
storeViewState();
Michael Carpenter
committed
currentView = VIEW_SOFTWARE_CONFIG;
ui.actionSoftwareConfig->setChecked(true);
loadViewState();
}
}
void MainWindow::loadTerminalView()
{
if (currentView != VIEW_TERMINAL)
{
storeViewState();
currentView = VIEW_TERMINAL;
ui.actionTerminalView->setChecked(true);
loadViewState();
}
}
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
void MainWindow::loadGoogleEarthView()
{
if (currentView != VIEW_GOOGLEEARTH)
{
storeViewState();
currentView = VIEW_GOOGLEEARTH;
ui.actionGoogleEarthView->setChecked(true);
loadViewState();
}
}
void MainWindow::loadLocal3DView()
{
if (currentView != VIEW_LOCAL3D)
{
storeViewState();
currentView = VIEW_LOCAL3D;
ui.actionLocal3DView->setChecked(true);
loadViewState();
}
}
void MainWindow::loadPilotView()
{
if (currentView != VIEW_FLIGHT)
{
storeViewState();
currentView = VIEW_FLIGHT;
ui.actionFlightView->setChecked(true);
loadViewState();
}
}
void MainWindow::loadSimulationView()
{
if (currentView != VIEW_SIMULATION)
{
storeViewState();
currentView = VIEW_SIMULATION;
ui.actionSimulationView->setChecked(true);
loadViewState();
}
}
John Tapsell
committed
QList<QAction*> MainWindow::listLinkMenuActions()
{
return ui.menuNetwork->actions();
}
John Tapsell
committed
bool MainWindow::dockWidgetTitleBarsEnabled() const
{
return menuActionHelper->dockWidgetTitleBarsEnabled();
}
bool MainWindow::x11Event(XEvent *event)
{
emit x11EventOccured(event);
Matthias Krebs
committed
return false;