1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge branch 'filnet/OP-996_add_option_to_remember_last_selected_workspace' into next

This commit is contained in:
Philippe Renon 2013-09-07 15:23:17 +02:00
commit 6dfd7c1c88
7 changed files with 110 additions and 73 deletions

View File

@ -40,7 +40,7 @@
#include <QEventLoop>
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)));

View File

@ -29,11 +29,11 @@
#ifndef CONNECTIONMANAGER_H
#define CONNECTIONMANAGER_H
#include <QWidget>
#include "mainwindow.h"
#include "generalsettings.h"
#include "telemetrymonitorwidget.h"
#include <coreplugin/iconnection.h>
#include <QWidget>
#include <QtCore/QVector>
#include <QtCore/QIODevice>
#include <QtCore/QLinkedList>
@ -43,20 +43,14 @@
#include "core_global.h"
#include <QTimer>
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();

View File

@ -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<QString, int> 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);

View File

@ -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());

View File

@ -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);
}

View File

@ -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

View File

@ -47,62 +47,20 @@
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Details</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Icon:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Utils::PathChooser" name="iconPathChooser" native="true"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nameEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Workspace panel</string>
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Allow reordering:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxTabBarPlacement">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -125,14 +83,7 @@
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxAllowTabMovement">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="1" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -145,6 +96,37 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Allow reordering:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxAllowTabMovement">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<property name="toolTip">
<string>Restore last selected workspace on startup</string>
</property>
<property name="text">
<string>Remember last used workspace on restart</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxRestoreSelectedOnStartup">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -216,6 +198,41 @@
</property>
</spacer>
</item>
<item row="3" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Details</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Icon:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Utils::PathChooser" name="iconPathChooser" native="true"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nameEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>