Newer
Older
Lorenz Meier
committed
if (centerStack->indexOf(engineeringView) == index)
{
// Rewrite to realtime plot
Michael Carpenter
committed
//index = centerStack->indexOf(linechartWidget);
}
if (index != -1)
{
centerStack->setCurrentIndex(index);
}
else
{
// Hide custom widgets
if (detectionDockWidget) detectionDockWidget->hide();
if (watchdogControlDockWidget) watchdogControlDockWidget->hide();
// Load defaults
switch (currentView)
{
Michael Carpenter
committed
case VIEW_HARDWARE_CONFIG:
Michael Carpenter
committed
centerStack->setCurrentWidget(configView);
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);
break;
case VIEW_MAVLINK:
Lorenz Meier
committed
centerStack->setCurrentWidget(mavlinkView);
// case VIEW_FIRMWAREUPDATE:
// centerStack->setCurrentWidget(firmwareUpdateWidget);
// break;
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_UNCONNECTED:
case VIEW_FULL:
default:
Michael Carpenter
committed
//centerStack->setCurrentWidget(mapWidget);
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());
//settings.setValue(getWindowStateKey(), win->saveState(QGC::applicationVersion()))
win->restoreState(settings.value(getWindowStateKey()).toByteArray(), QGC::applicationVersion());
Michael Carpenter
committed
void MainWindow::setAdvancedMode()
{
isAdvancedMode = !isAdvancedMode;
ui.actionAdvanced_Mode->setChecked(isAdvancedMode);
settings.setValue("ADVANCED_MODE",isAdvancedMode);
Michael Carpenter
committed
for (int i = 0; i < dockWidgets.size(); i++)
Michael Carpenter
committed
{
setDockWidgetTitleBar(dockWidgets[i]);
Michael Carpenter
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();
}
}
Michael Carpenter
committed
void MainWindow::loadHardwareConfigView()
{
if (currentView != VIEW_HARDWARE_CONFIG)
{
storeViewState();
currentView = VIEW_HARDWARE_CONFIG;
ui.actionHardwareConfig->setChecked(true);
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();
}
}
void MainWindow::loadUnconnectedView()
{
if (currentView != VIEW_UNCONNECTED)
{
storeViewState();
currentView = VIEW_UNCONNECTED;
ui.actionUnconnectedView->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.actionSimulation_View->setChecked(true);
loadViewState();
}
}
void MainWindow::loadMAVLinkView()
{
if (currentView != VIEW_MAVLINK)
{
storeViewState();
currentView = VIEW_MAVLINK;
ui.actionMavlinkView->setChecked(true);
loadViewState();
}
}
Lorenz Meier
committed
//void MainWindow::loadDataView(QString fileName)
//{
// // Plot is now selected, now load data from file
// if (dataView)
// {
// //dataView->setCentralWidget(new QGCDataPlot2D(this));
// QGCDataPlot2D *plot = qobject_cast<QGCDataPlot2D*>(dataView->centralWidget());
// if (plot)
// {
// plot->loadFile(fileName);
// }
// }
// /*QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
// if (centerStack)
// {
// centerStack->setCurrentWidget(dataView);
// dataplotWidget->loadFile(fileName);
// }*/
//}
QList<QAction*> MainWindow::listLinkMenuActions(void)
{
return ui.menuNetwork->actions();
}
#ifdef MOUSE_ENABLED_LINUX
bool MainWindow::x11Event(XEvent *event)
{
emit x11EventOccured(event);
Matthias Krebs
committed
//qDebug("XEvent occured...");
return false;
}
#endif // MOUSE_ENABLED_LINUX