Skip to content
MainWindow.cc 37.7 KiB
Newer Older
        _currentView = VIEW_SETUP;
dogmaphobic's avatar
dogmaphobic committed
        _ui.actionSetup->setChecked(true);
        _loadCurrentViewState();
void MainWindow::loadFlightView()
    if (_currentView != VIEW_FLIGHT)
        _storeCurrentViewState();
        _currentView = VIEW_FLIGHT;
        _ui.actionFlight->setChecked(true);
        _loadCurrentViewState();
void MainWindow::loadSimulationView()
{
    if (_currentView != VIEW_SIMULATION)
        _storeCurrentViewState();
        _currentView = VIEW_SIMULATION;
dogmaphobic's avatar
dogmaphobic committed
        _ui.actionSimulationView->setChecked(true);
        _loadCurrentViewState();
Don Gagne's avatar
Don Gagne committed
/// @brief Hides the spash screen if it is currently being shown
void MainWindow::hideSplashScreen(void)
Don Gagne's avatar
Don Gagne committed
{
    if (_splashScreen) {
        _splashScreen->hide();
        _splashScreen = NULL;
    }
}

dogmaphobic's avatar
dogmaphobic committed
    SettingsDialog settings(this, SettingsDialog::ShowCommLinks);
    settings.exec();
}

/// @brief Saves the last used connection
void MainWindow::saveLastUsedConnection(const QString connection)
{
    QSettings settings;
    QString key(MAIN_SETTINGS_GROUP);
    key += "/LAST_CONNECTION";
    settings.setValue(key, connection);
}

/// @brief Restore (and connects) the last used connection (if any)
void MainWindow::restoreLastUsedConnection()
{
    // TODO This should check and see of the port/whatever is present
    // first. That is, if the last connection was to a PX4 on some serial
    // port, it should check and see if the port is present before making
    // the connection.
    QSettings settings;
    QString key(MAIN_SETTINGS_GROUP);
    key += "/LAST_CONNECTION";
    if(settings.contains(key)) {
        QString connection = settings.value(key).toString();
        LinkManager::instance()->createConnectedLink(connection);
void MainWindow::_linkStateChange(LinkInterface*)
{
    emit repaintCanvas();
}

#ifdef QGC_MOUSE_ENABLED_LINUX
bool MainWindow::x11Event(XEvent *event)
{
    emit x11EventOccured(event);
#endif // QGC_MOUSE_ENABLED_LINUX

#ifdef UNITTEST_BUILD
void MainWindow::_showQmlTestWidget(void)
{
    new QmlTestWidget();
}
#endif