diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp index db684e4c1..c12919a14 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.cpp @@ -40,7 +40,7 @@ #include namespace Core { -ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack) : +ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow) : QWidget(mainWindow), m_availableDevList(0), m_connectBtn(0), @@ -73,8 +73,6 @@ ConnectionManager::ConnectionManager(Internal::MainWindow *mainWindow, QTabWidge setLayout(layout); - modeStack->setCornerWidget(this, Qt::TopRightCorner); - QObject::connect(m_connectBtn, SIGNAL(clicked()), this, SLOT(onConnectClicked())); QObject::connect(m_availableDevList, SIGNAL(currentIndexChanged(int)), this, SLOT(onDeviceSelectionChanged(int))); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h index 71eee425f..1f339818a 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/connectionmanager.h @@ -29,11 +29,11 @@ #ifndef CONNECTIONMANAGER_H #define CONNECTIONMANAGER_H -#include #include "mainwindow.h" #include "generalsettings.h" #include "telemetrymonitorwidget.h" #include +#include #include #include #include @@ -43,20 +43,14 @@ #include "core_global.h" #include -QT_BEGIN_NAMESPACE -class QTabWidget; -QT_END_NAMESPACE - namespace Core { + class IConnection; namespace Internal { -class FancyTabWidget; -class FancyActionBar; -class MainWindow; + class MainWindow; } // namespace Internal - class DevListItem { public: DevListItem(IConnection *c, IConnection::device d) : @@ -86,7 +80,7 @@ class CORE_EXPORT ConnectionManager : public QWidget { Q_OBJECT public: - ConnectionManager(Internal::MainWindow *mainWindow, QTabWidget *modeStack); + ConnectionManager(Internal::MainWindow *mainWindow); virtual ~ConnectionManager(); void init(); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp index d57393baf..849fa1828 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/mainwindow.cpp @@ -177,7 +177,8 @@ MainWindow::MainWindow() : #endif m_modeManager = new ModeManager(this, m_modeStack); - m_connectionManager = new ConnectionManager(this, m_modeStack); + m_connectionManager = new ConnectionManager(this); + m_modeStack->setCornerWidget(m_connectionManager, Qt::TopRightCorner); m_messageManager = new MessageManager; setCentralWidget(m_modeStack); @@ -1214,8 +1215,9 @@ void MainWindow::readSettings(QSettings *qs, bool workspaceDiffOnly) createWorkspaces(qs); - // Read tab ordering + // Restore tab ordering qs->beginGroup(QLatin1String(modePriorities)); + QStringList modeNames = qs->childKeys(); QMap map; foreach(QString modeName, modeNames) { @@ -1224,6 +1226,12 @@ void MainWindow::readSettings(QSettings *qs, bool workspaceDiffOnly) m_modeManager->reorderModes(map); qs->endGroup(); + + // Restore selected tab + if (m_workspaceSettings->restoreSelectedOnStartup()) { + int index = qs->value(QLatin1String("SelectedWorkspace")).toInt(); + m_modeStack->setCurrentIndex(index); + } } @@ -1262,12 +1270,16 @@ void MainWindow::saveSettings(QSettings *qs) } qs->endGroup(); + // Write selected tab + qs->setValue(QLatin1String("SelectedWorkspace"), m_modeStack->currentIndex()); + foreach(UAVGadgetManager * manager, m_uavGadgetManagers) { manager->saveSettings(qs); } m_actionManager->saveSettings(qs); m_generalSettings->saveSettings(qs); + qs->beginGroup("General"); qs->setValue("Description", m_config_description); qs->setValue("Details", m_config_details); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp index 751531ddf..be948b8f8 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/uavgadgetinstancemanager.cpp @@ -238,6 +238,10 @@ void UAVGadgetInstanceManager::createOptionsPages() while (ite.hasNext()) { IUAVGadgetConfiguration *config = ite.next(); IUAVGadgetFactory *f = factory(config->classId()); + if (!f) { + qWarning() << "No gadget factory for configuration " + config->classId(); + continue; + } IOptionsPage *p = f->createOptionsPage(config); if (p) { IOptionsPage *page = new UAVGadgetOptionsPageDecorator(p, config, f->isSingleConfigurationGadget()); diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp index 43d552f44..d3245f962 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.cpp @@ -33,18 +33,19 @@ #include "ui_workspacesettings.h" - using namespace Core; using namespace Core::Internal; const int WorkspaceSettings::MAX_WORKSPACES = 10; WorkspaceSettings::WorkspaceSettings(QObject *parent) : - IOptionsPage(parent) -{} + IOptionsPage(parent) +{ +} WorkspaceSettings::~WorkspaceSettings() -{} +{ +} // IOptionsPage @@ -84,7 +85,6 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent) m_page->iconPathChooser->setPromptDialogFilter(tr("Images (*.png *.jpg *.bmp *.xpm)")); m_page->iconPathChooser->setPromptDialogTitle(tr("Choose icon")); - connect(m_page->workspaceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectWorkspace(int))); connect(m_page->numberOfWorkspacesSpinBox, SIGNAL(valueChanged(int)), this, SLOT(numberOfWorkspacesChanged(int))); connect(m_page->nameEdit, SIGNAL(textEdited(QString)), this, SLOT(textEdited(QString))); @@ -97,6 +97,7 @@ QWidget *WorkspaceSettings::createPage(QWidget *parent) m_page->comboBoxTabBarPlacement->setCurrentIndex(m_tabBarPlacementIndex); } m_page->checkBoxAllowTabMovement->setChecked(m_allowTabBarMovement); + m_page->checkBoxRestoreSelectedOnStartup->setChecked(m_restoreSelectedOnStartup); return w; } @@ -122,7 +123,10 @@ void WorkspaceSettings::readSettings(QSettings *qs) } m_tabBarPlacementIndex = qs->value(QLatin1String("TabBarPlacementIndex"), 1).toInt(); // 1 == "Bottom" m_allowTabBarMovement = qs->value(QLatin1String("AllowTabBarMovement"), false).toBool(); + m_restoreSelectedOnStartup = qs->value(QLatin1String("RestoreSelectedOnStartup"), false).toBool(); + qs->endGroup(); + QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South; emit tabBarSettingsApplied(pos, m_allowTabBarMovement); } @@ -142,6 +146,7 @@ void WorkspaceSettings::saveSettings(QSettings *qs) } qs->setValue(QLatin1String("TabBarPlacementIndex"), m_tabBarPlacementIndex); qs->setValue(QLatin1String("AllowTabBarMovement"), m_allowTabBarMovement); + qs->setValue(QLatin1String("RestoreSelectedOnStartup"), m_restoreSelectedOnStartup); qs->endGroup(); } @@ -166,6 +171,8 @@ void WorkspaceSettings::apply() } m_tabBarPlacementIndex = m_page->comboBoxTabBarPlacement->currentIndex(); m_allowTabBarMovement = m_page->checkBoxAllowTabMovement->isChecked(); + m_restoreSelectedOnStartup = m_page->checkBoxRestoreSelectedOnStartup->isChecked(); + QTabWidget::TabPosition pos = m_tabBarPlacementIndex == 0 ? QTabWidget::North : QTabWidget::South; emit tabBarSettingsApplied(pos, m_allowTabBarMovement); } diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h index 37d2897ae..de2c96732 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.h @@ -77,6 +77,10 @@ public: { return m_modeNames.at(i); } + bool restoreSelectedOnStartup() const + { + return m_restoreSelectedOnStartup; + } signals: void tabBarSettingsApplied(QTabWidget::TabPosition pos, bool movable); @@ -98,6 +102,7 @@ private: int m_numberOfWorkspaces; int m_tabBarPlacementIndex; bool m_allowTabBarMovement; + bool m_restoreSelectedOnStartup; static const int MAX_WORKSPACES; }; } // namespace Internal diff --git a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui index 206f7acdd..4be345c22 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui +++ b/ground/openpilotgcs/src/plugins/coreplugin/workspacesettings.ui @@ -47,62 +47,20 @@ 0 - - - - - 0 - 0 - - - - Details - - - - - - Icon: - - - - - - - - - - - - - Name: - - - - - - - Workspace panel + General - + Placement: - - - - Allow reordering: - - - - + @@ -125,14 +83,7 @@ - - - - - - - - + Qt::Horizontal @@ -145,6 +96,37 @@ + + + + Allow reordering: + + + + + + + + + + + + + + Restore last selected workspace on startup + + + Remember last used workspace on restart + + + + + + + + + + @@ -216,6 +198,41 @@ + + + + + 0 + 0 + + + + Details + + + + + + Icon: + + + + + + + + + + + + + Name: + + + + + +