mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
GCS/coreplugin: Partially implemented support for uavgadget settings.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@379 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6ae983b453
commit
0516034897
@ -92,10 +92,10 @@ ConnectionManager *CoreImpl::connectionManager() const
|
||||
return m_mainwindow->connectionManager();
|
||||
}
|
||||
|
||||
//UAVGadgetManager *CoreImpl::uavGadgetManager() const
|
||||
//{
|
||||
// return m_mainwindow->uavGadgetManager();
|
||||
//}
|
||||
UAVGadgetInstanceManager *CoreImpl::uavGadgetInstanceManager() const
|
||||
{
|
||||
return m_mainwindow->uavGadgetInstanceManager();
|
||||
}
|
||||
|
||||
VariableManager *CoreImpl::variableManager() const
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
UniqueIDManager *uniqueIDManager() const;
|
||||
MessageManager *messageManager() const;
|
||||
ConnectionManager *connectionManager() const;
|
||||
// UAVGadgetManager *uavGadgetManager() const;
|
||||
UAVGadgetInstanceManager *uavGadgetInstanceManager() const;
|
||||
VariableManager *variableManager() const;
|
||||
ModeManager *modeManager() const;
|
||||
MimeDatabase *mimeDatabase() const;
|
||||
|
@ -29,9 +29,6 @@
|
||||
#include "coreplugin.h"
|
||||
#include "coreimpl.h"
|
||||
#include "mainwindow.h"
|
||||
#include "modemanager.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@ -46,13 +43,6 @@ CorePlugin::CorePlugin() :
|
||||
|
||||
CorePlugin::~CorePlugin()
|
||||
{
|
||||
if (m_uavGadgetModes.count() > 0) {
|
||||
foreach (UAVGadgetMode *mode, m_uavGadgetModes)
|
||||
{
|
||||
removeObject(mode);
|
||||
delete mode;
|
||||
}
|
||||
}
|
||||
delete m_mainWindow;
|
||||
}
|
||||
|
||||
@ -68,28 +58,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
|
||||
void CorePlugin::extensionsInitialized()
|
||||
{
|
||||
// Workspace 1
|
||||
UAVGadgetMode *uavGadgetMode;
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
m_uavGadgetManager = new UAVGadgetManager(CoreImpl::instance(), m_mainWindow);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString(tr("Workspace 1")),
|
||||
QIcon(":/core/images/openpilot_logo_64.png"), 90, QString("Mode1"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
addObject(uavGadgetMode);
|
||||
m_mainWindow->addUAVGadgetManager(m_uavGadgetManager);
|
||||
|
||||
// Workspace 2
|
||||
m_uavGadgetManager = new UAVGadgetManager(CoreImpl::instance(), m_mainWindow);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString(tr("Workspace 2")),
|
||||
QIcon(":/core/images/plus.png"), 60, QString("Mode2"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
addObject(uavGadgetMode);
|
||||
m_mainWindow->addUAVGadgetManager(m_uavGadgetManager);
|
||||
|
||||
m_mainWindow->extensionsInitialized();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
class UAVGadgetMode;
|
||||
class MainWindow;
|
||||
|
||||
class CorePlugin : public ExtensionSystem::IPlugin
|
||||
@ -54,7 +53,6 @@ public slots:
|
||||
|
||||
private:
|
||||
MainWindow *m_mainWindow;
|
||||
QList<UAVGadgetMode*> m_uavGadgetModes;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@ -1,122 +1,129 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = Core
|
||||
DEFINES += CORE_LIBRARY
|
||||
QT += xml \
|
||||
network \
|
||||
script \
|
||||
svg \
|
||||
sql
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
include(coreplugin_dependencies.pri)
|
||||
INCLUDEPATH += dialogs \
|
||||
uavgadgetmanager \
|
||||
actionmanager
|
||||
DEPENDPATH += dialogs \
|
||||
uavgadgetmanager \
|
||||
actionmanager
|
||||
SOURCES += mainwindow.cpp \
|
||||
tabpositionindicator.cpp \
|
||||
fancyactionbar.cpp \
|
||||
fancytabwidget.cpp \
|
||||
generalsettings.cpp \
|
||||
uniqueidmanager.cpp \
|
||||
messagemanager.cpp \
|
||||
messageoutputwindow.cpp \
|
||||
viewmanager.cpp \
|
||||
versiondialog.cpp \
|
||||
iuavgadget.cpp \
|
||||
uavgadgetmode.cpp \
|
||||
uavgadgetmanager/uavgadgetmanager.cpp \
|
||||
uavgadgetmanager/uavgadgetview.cpp \
|
||||
actionmanager/actionmanager.cpp \
|
||||
actionmanager/command.cpp \
|
||||
actionmanager/actioncontainer.cpp \
|
||||
actionmanager/commandsfile.cpp \
|
||||
dialogs/settingsdialog.cpp \
|
||||
dialogs/shortcutsettings.cpp \
|
||||
basemode.cpp \
|
||||
baseview.cpp \
|
||||
coreplugin.cpp \
|
||||
variablemanager.cpp \
|
||||
modemanager.cpp \
|
||||
coreimpl.cpp \
|
||||
plugindialog.cpp \
|
||||
manhattanstyle.cpp \
|
||||
minisplitter.cpp \
|
||||
styleanimator.cpp \
|
||||
rightpane.cpp \
|
||||
sidebar.cpp \
|
||||
mimedatabase.cpp \
|
||||
icore.cpp \
|
||||
dialogs/ioptionspage.cpp \
|
||||
dialogs/iwizard.cpp \
|
||||
settingsdatabase.cpp \
|
||||
eventfilteringmainwindow.cpp \
|
||||
connectionmanager.cpp \
|
||||
iconnection.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
tabpositionindicator.h \
|
||||
fancyactionbar.h \
|
||||
fancytabwidget.h \
|
||||
generalsettings.h \
|
||||
uniqueidmanager.h \
|
||||
messagemanager.h \
|
||||
messageoutputwindow.h \
|
||||
viewmanager.h \
|
||||
iuavgadget.h \
|
||||
uavgadgetmode.h \
|
||||
iuavgadgetfactory.h \
|
||||
uavgadgetmanager/uavgadgetmanager.h \
|
||||
uavgadgetmanager/uavgadgetview.h \
|
||||
actionmanager/actioncontainer.h \
|
||||
actionmanager/actionmanager.h \
|
||||
actionmanager/command.h \
|
||||
actionmanager/actionmanager_p.h \
|
||||
actionmanager/command_p.h \
|
||||
actionmanager/actioncontainer_p.h \
|
||||
actionmanager/commandsfile.h \
|
||||
dialogs/settingsdialog.h \
|
||||
dialogs/shortcutsettings.h \
|
||||
dialogs/iwizard.h \
|
||||
dialogs/ioptionspage.h \
|
||||
icontext.h \
|
||||
icore.h \
|
||||
imode.h \
|
||||
ioutputpane.h \
|
||||
coreconstants.h \
|
||||
iversioncontrol.h \
|
||||
iview.h \
|
||||
icorelistener.h \
|
||||
versiondialog.h \
|
||||
core_global.h \
|
||||
basemode.h \
|
||||
baseview.h \
|
||||
coreplugin.h \
|
||||
variablemanager.h \
|
||||
modemanager.h \
|
||||
coreimpl.h \
|
||||
plugindialog.h \
|
||||
manhattanstyle.h \
|
||||
minisplitter.h \
|
||||
styleanimator.h \
|
||||
rightpane.h \
|
||||
sidebar.h \
|
||||
mimedatabase.h \
|
||||
settingsdatabase.h \
|
||||
eventfilteringmainwindow.h \
|
||||
connectionmanager.h \
|
||||
iconnection.h
|
||||
FORMS += dialogs/settingsdialog.ui \
|
||||
dialogs/shortcutsettings.ui \
|
||||
generalsettings.ui
|
||||
RESOURCES += core.qrc \
|
||||
fancyactionbar.qrc
|
||||
unix:!macx {
|
||||
images.files = images/openpilot_logo_*.png
|
||||
images.files = images/qtcreator_logo_*.png
|
||||
images.path = /share/pixmaps
|
||||
INSTALLS += images
|
||||
}
|
||||
OTHER_FILES += Core.pluginspec
|
||||
TEMPLATE = lib
|
||||
TARGET = Core
|
||||
DEFINES += CORE_LIBRARY
|
||||
QT += xml \
|
||||
network \
|
||||
script \
|
||||
svg \
|
||||
sql
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
include(coreplugin_dependencies.pri)
|
||||
INCLUDEPATH += dialogs \
|
||||
uavgadgetmanager \
|
||||
actionmanager
|
||||
DEPENDPATH += dialogs \
|
||||
uavgadgetmanager \
|
||||
actionmanager
|
||||
SOURCES += mainwindow.cpp \
|
||||
tabpositionindicator.cpp \
|
||||
fancyactionbar.cpp \
|
||||
fancytabwidget.cpp \
|
||||
generalsettings.cpp \
|
||||
uniqueidmanager.cpp \
|
||||
messagemanager.cpp \
|
||||
messageoutputwindow.cpp \
|
||||
viewmanager.cpp \
|
||||
versiondialog.cpp \
|
||||
iuavgadget.cpp \
|
||||
uavgadgetmode.cpp \
|
||||
uavgadgetmanager/uavgadgetmanager.cpp \
|
||||
uavgadgetmanager/uavgadgetview.cpp \
|
||||
actionmanager/actionmanager.cpp \
|
||||
actionmanager/command.cpp \
|
||||
actionmanager/actioncontainer.cpp \
|
||||
actionmanager/commandsfile.cpp \
|
||||
dialogs/settingsdialog.cpp \
|
||||
dialogs/shortcutsettings.cpp \
|
||||
basemode.cpp \
|
||||
baseview.cpp \
|
||||
coreplugin.cpp \
|
||||
variablemanager.cpp \
|
||||
modemanager.cpp \
|
||||
coreimpl.cpp \
|
||||
plugindialog.cpp \
|
||||
manhattanstyle.cpp \
|
||||
minisplitter.cpp \
|
||||
styleanimator.cpp \
|
||||
rightpane.cpp \
|
||||
sidebar.cpp \
|
||||
mimedatabase.cpp \
|
||||
icore.cpp \
|
||||
dialogs/ioptionspage.cpp \
|
||||
dialogs/iwizard.cpp \
|
||||
settingsdatabase.cpp \
|
||||
eventfilteringmainwindow.cpp \
|
||||
connectionmanager.cpp \
|
||||
iconnection.cpp \
|
||||
uavgadgetoptionspage.cpp \
|
||||
iuavgadgetconfiguration.cpp \
|
||||
uavgadgetinstancemanager.cpp
|
||||
HEADERS += mainwindow.h \
|
||||
tabpositionindicator.h \
|
||||
fancyactionbar.h \
|
||||
fancytabwidget.h \
|
||||
generalsettings.h \
|
||||
uniqueidmanager.h \
|
||||
messagemanager.h \
|
||||
messageoutputwindow.h \
|
||||
viewmanager.h \
|
||||
iuavgadget.h \
|
||||
uavgadgetmode.h \
|
||||
iuavgadgetfactory.h \
|
||||
uavgadgetmanager/uavgadgetmanager.h \
|
||||
uavgadgetmanager/uavgadgetview.h \
|
||||
actionmanager/actioncontainer.h \
|
||||
actionmanager/actionmanager.h \
|
||||
actionmanager/command.h \
|
||||
actionmanager/actionmanager_p.h \
|
||||
actionmanager/command_p.h \
|
||||
actionmanager/actioncontainer_p.h \
|
||||
actionmanager/commandsfile.h \
|
||||
dialogs/settingsdialog.h \
|
||||
dialogs/shortcutsettings.h \
|
||||
dialogs/iwizard.h \
|
||||
dialogs/ioptionspage.h \
|
||||
icontext.h \
|
||||
icore.h \
|
||||
imode.h \
|
||||
ioutputpane.h \
|
||||
coreconstants.h \
|
||||
iversioncontrol.h \
|
||||
iview.h \
|
||||
icorelistener.h \
|
||||
versiondialog.h \
|
||||
core_global.h \
|
||||
basemode.h \
|
||||
baseview.h \
|
||||
coreplugin.h \
|
||||
variablemanager.h \
|
||||
modemanager.h \
|
||||
coreimpl.h \
|
||||
plugindialog.h \
|
||||
manhattanstyle.h \
|
||||
minisplitter.h \
|
||||
styleanimator.h \
|
||||
rightpane.h \
|
||||
sidebar.h \
|
||||
mimedatabase.h \
|
||||
settingsdatabase.h \
|
||||
eventfilteringmainwindow.h \
|
||||
connectionmanager.h \
|
||||
iconnection.h \
|
||||
uavgadgetoptionspage.h \
|
||||
iuavgadgetconfiguration.h \
|
||||
uavgadgetinstancemanager.h
|
||||
FORMS += dialogs/settingsdialog.ui \
|
||||
dialogs/shortcutsettings.ui \
|
||||
generalsettings.ui \
|
||||
uavgadgetoptionspage.ui
|
||||
RESOURCES += core.qrc \
|
||||
fancyactionbar.qrc
|
||||
unix:!macx {
|
||||
images.files = images/openpilot_logo_*.png
|
||||
images.files = images/qtcreator_logo_*.png
|
||||
images.path = /share/pixmaps
|
||||
INSTALLS += images
|
||||
}
|
||||
OTHER_FILES += Core.pluginspec
|
||||
|
@ -51,6 +51,7 @@ class SettingsDatabase;
|
||||
class UniqueIDManager;
|
||||
class VariableManager;
|
||||
class UAVGadgetManager;
|
||||
class UAVGadgetInstanceManager;
|
||||
|
||||
class CORE_EXPORT ICore : public QObject
|
||||
{
|
||||
@ -78,7 +79,7 @@ public:
|
||||
virtual VariableManager *variableManager() const = 0;
|
||||
virtual ModeManager *modeManager() const = 0;
|
||||
virtual ConnectionManager *connectionManager() const = 0;
|
||||
// virtual UAVGadgetManager *uavGadgetManager() const = 0;
|
||||
virtual UAVGadgetInstanceManager *uavGadgetInstanceManager() const = 0;
|
||||
virtual MimeDatabase *mimeDatabase() const = 0;
|
||||
|
||||
virtual QSettings *settings() const = 0;
|
||||
|
@ -27,18 +27,57 @@
|
||||
*/
|
||||
|
||||
#include "iuavgadget.h"
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
|
||||
/*!
|
||||
\class Core::IUAVGadget
|
||||
\brief The IUAVGadget is an interface for uav gadgets.
|
||||
using namespace Core;
|
||||
|
||||
Classes that implement this interface are for example .
|
||||
IUAVGadget::IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, QObject *parent) :
|
||||
IContext(parent),
|
||||
m_classId(classId),
|
||||
m_toolbar(new QComboBox),
|
||||
m_configurations(configurations)
|
||||
{
|
||||
foreach (IUAVGadgetConfiguration *config, *configurations)
|
||||
m_toolbar->addItem(config->name());
|
||||
connect(m_toolbar, SIGNAL(activated(int)), this, SLOT(loadConfiguration(int)));
|
||||
}
|
||||
|
||||
Guidelines for implementing:
|
||||
\list
|
||||
\o to be filled in...
|
||||
\endlist
|
||||
void IUAVGadget::loadConfiguration(int index) {
|
||||
IUAVGadgetConfiguration* config = m_configurations->at(index);
|
||||
loadConfiguration(config);
|
||||
}
|
||||
|
||||
\sa Core::IUAVGadgetFactory Core::IContext
|
||||
|
||||
*/
|
||||
void IUAVGadget::configurationChanged(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
if (config == m_activeConfiguration)
|
||||
loadConfiguration(config);
|
||||
}
|
||||
|
||||
void IUAVGadget::configurationNameChanged(QString oldName, QString newName)
|
||||
{
|
||||
for (int i = 0; i < m_toolbar->count(); ++i) {
|
||||
if (m_toolbar->itemText(i) == oldName)
|
||||
m_toolbar->setItemText(i, newName);
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray IUAVGadget::saveState()
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
// if (m_activeConfiguration)
|
||||
// stream << m_activeConfiguration->name().toLatin1();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void IUAVGadget::restoreState(QByteArray state)
|
||||
{
|
||||
QDataStream stream(state);
|
||||
QByteArray configName;
|
||||
stream >> configName;
|
||||
foreach (IUAVGadgetConfiguration *config, *m_configurations) {
|
||||
if (config->name() == configName)
|
||||
loadConfiguration(config);
|
||||
}
|
||||
}
|
||||
|
@ -31,33 +31,44 @@
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <QtGui/QComboBox>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
class QComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IUAVGadgetConfiguration;
|
||||
|
||||
class CORE_EXPORT IUAVGadget : public IContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IUAVGadget(QObject *parent = 0) : IContext(parent) {}
|
||||
IUAVGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, QObject *parent = 0);
|
||||
virtual ~IUAVGadget() {}
|
||||
|
||||
virtual QList<int> context() const = 0;
|
||||
virtual QWidget *widget() = 0;
|
||||
virtual QString contextHelpId() const { return QString(); }
|
||||
virtual QString gadgetKind() { return m_gadgetKind; }
|
||||
QString classId() const { return m_classId; }
|
||||
|
||||
// virtual void saveConfiguration() = 0;
|
||||
// virtual void loadConfiguration(QString ) = 0;
|
||||
// virtual QStringList getConfigurationNames() = 0;
|
||||
virtual QWidget *toolBar() = 0;
|
||||
virtual QByteArray saveState() { return 0; }
|
||||
virtual void restoreState(QByteArray state) { }
|
||||
protected:
|
||||
QString m_gadgetKind;
|
||||
virtual void loadConfiguration(IUAVGadgetConfiguration* /*config*/) {}
|
||||
QComboBox *toolBar() { return m_toolbar; }
|
||||
virtual QByteArray saveState();
|
||||
virtual void restoreState(QByteArray state);
|
||||
public slots:
|
||||
void configurationChanged(IUAVGadgetConfiguration* config);
|
||||
void configurationNameChanged(QString oldName, QString newName);
|
||||
private slots:
|
||||
void loadConfiguration(int index);
|
||||
private:
|
||||
QString m_classId;
|
||||
QComboBox *m_toolbar;
|
||||
|
||||
IUAVGadgetConfiguration *m_activeConfiguration;
|
||||
QList<IUAVGadgetConfiguration*> *m_configurations;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
38
ground/src/plugins/coreplugin/iuavgadgetconfiguration.cpp
Normal file
38
ground/src/plugins/coreplugin/iuavgadgetconfiguration.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file iuavgadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
|
||||
using namespace Core;
|
||||
|
||||
IUAVGadgetConfiguration::IUAVGadgetConfiguration(bool locked, QString classId, QString name, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_locked(locked),
|
||||
m_classId(classId),
|
||||
m_name(name)
|
||||
{
|
||||
}
|
60
ground/src/plugins/coreplugin/iuavgadgetconfiguration.h
Normal file
60
ground/src/plugins/coreplugin/iuavgadgetconfiguration.h
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file iuavgadgetconfiguration.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef IUAVGADGETCONFIGURATION_H
|
||||
#define IUAVGADGETCONFIGURATION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IUAVGadgetConfiguration : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit IUAVGadgetConfiguration(bool locked, QString classId, QString name, QObject *parent = 0);
|
||||
virtual QByteArray saveState() const = 0;
|
||||
QString classId() { return m_classId; }
|
||||
QString name() { return m_name; }
|
||||
void setName(QString name) { m_name = name; }
|
||||
bool locked() const { return m_locked; }
|
||||
virtual IUAVGadgetConfiguration *clone() = 0;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
bool m_locked;
|
||||
QString m_classId;
|
||||
QString m_name;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IUAVGADGETCONFIGURATION_H
|
@ -39,20 +39,29 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetConfiguration;
|
||||
class UAVGadgetOptionsPage;
|
||||
|
||||
class CORE_EXPORT IUAVGadgetFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
IUAVGadgetFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
IUAVGadgetFactory(QString classId, QString name, QObject *parent = 0) :
|
||||
QObject(parent),
|
||||
m_classId(classId),
|
||||
m_name(name) {}
|
||||
virtual ~IUAVGadgetFactory() {}
|
||||
|
||||
virtual IUAVGadget *createUAVGadget(QWidget *parent) = 0;
|
||||
virtual QString gadgetKind() const { return m_gadgetKind; }
|
||||
virtual QString name() const { return m_name; }
|
||||
protected:
|
||||
virtual IUAVGadget *createUAVGadget(QList<IUAVGadgetConfiguration*> *configurations, QWidget *parent) = 0;
|
||||
virtual IUAVGadgetConfiguration *createUAVGadgetConfiguration(bool /*locked*/,
|
||||
const QString /*configName*/,
|
||||
const QByteArray &/*state*/) { return 0; }
|
||||
virtual UAVGadgetOptionsPage *createUAVGadgetOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; }
|
||||
QString classId() const { return m_classId; }
|
||||
QString name() const { return m_name; }
|
||||
private:
|
||||
QString m_classId;
|
||||
QString m_name;
|
||||
QString m_gadgetKind;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
@ -40,7 +40,10 @@
|
||||
#include "outputpane.h"
|
||||
#include "plugindialog.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "modemanager.h"
|
||||
#include "uavgadgetmode.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "connectionmanager.h"
|
||||
|
||||
#include "settingsdialog.h"
|
||||
@ -187,6 +190,13 @@ MainWindow::~MainWindow()
|
||||
{
|
||||
hide();
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (m_uavGadgetModes.count() > 0) {
|
||||
foreach (UAVGadgetMode *mode, m_uavGadgetModes)
|
||||
{
|
||||
pm->removeObject(mode);
|
||||
delete mode;
|
||||
}
|
||||
}
|
||||
pm->removeObject(m_shortcutSettings);
|
||||
pm->removeObject(m_generalSettings);
|
||||
delete m_messageManager;
|
||||
@ -239,6 +249,33 @@ void MainWindow::modeChanged(Core::IMode */*mode*/)
|
||||
|
||||
void MainWindow::extensionsInitialized()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
||||
m_uavGadgetInstanceManager->readUAVGadgetConfigurations();
|
||||
|
||||
// Workspace 1
|
||||
UAVGadgetMode *uavGadgetMode;
|
||||
Core::UAVGadgetManager *m_uavGadgetManager;
|
||||
m_uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), this);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString(tr("Workspace 1")),
|
||||
QIcon(":/core/images/openpilot_logo_64.png"), 90, QString("Mode1"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
pm->addObject(uavGadgetMode);
|
||||
addUAVGadgetManager(m_uavGadgetManager);
|
||||
|
||||
// Workspace 2
|
||||
m_uavGadgetManager = new Core::UAVGadgetManager(CoreImpl::instance(), this);
|
||||
m_uavGadgetManager->hide();
|
||||
uavGadgetMode = new UAVGadgetMode(m_uavGadgetManager, QString(tr("Workspace 2")),
|
||||
QIcon(":/core/images/plus.png"), 60, QString("Mode2"));
|
||||
m_uavGadgetManager->setUAVGadgetMode(uavGadgetMode);
|
||||
m_uavGadgetModes.append(uavGadgetMode);
|
||||
pm->addObject(uavGadgetMode);
|
||||
addUAVGadgetManager(m_uavGadgetManager);
|
||||
|
||||
m_viewManager->extensionsInitalized();
|
||||
|
||||
m_messageManager->init();
|
||||
@ -739,6 +776,12 @@ QList<UAVGadgetManager*> MainWindow::uavGadgetManagers() const
|
||||
return m_uavGadgetManagers;
|
||||
}
|
||||
|
||||
UAVGadgetInstanceManager *MainWindow::uavGadgetInstanceManager() const
|
||||
{
|
||||
return m_uavGadgetInstanceManager;
|
||||
}
|
||||
|
||||
|
||||
ModeManager *MainWindow::modeManager() const
|
||||
{
|
||||
return m_modeManager;
|
||||
@ -903,6 +946,9 @@ void MainWindow::writeSettings()
|
||||
|
||||
m_viewManager->saveSettings(m_settings);
|
||||
m_actionManager->saveSettings(m_settings);
|
||||
|
||||
m_uavGadgetInstanceManager->writeUAVGadgetConfigurations();
|
||||
|
||||
foreach (UAVGadgetManager *manager, m_uavGadgetManagers) {
|
||||
manager->saveSettings();
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ class UniqueIDManager;
|
||||
class VariableManager;
|
||||
class ViewManagerInterface;
|
||||
class UAVGadgetManager;
|
||||
class UAVGadgetInstanceManager;
|
||||
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@ -69,6 +71,7 @@ class GeneralSettings;
|
||||
class ShortcutSettings;
|
||||
class ViewManager;
|
||||
class VersionDialog;
|
||||
class UAVGadgetMode;
|
||||
|
||||
class CORE_EXPORT MainWindow : public EventFilteringMainWindow
|
||||
{
|
||||
@ -92,8 +95,8 @@ public:
|
||||
Core::ActionManager *actionManager() const;
|
||||
Core::UniqueIDManager *uniqueIDManager() const;
|
||||
Core::MessageManager *messageManager() const;
|
||||
void addUAVGadgetManager(Core::UAVGadgetManager *manager);
|
||||
QList<Core::UAVGadgetManager*> uavGadgetManagers() const;
|
||||
QList<UAVGadgetManager*> uavGadgetManagers() const;
|
||||
UAVGadgetInstanceManager *uavGadgetInstanceManager() const;
|
||||
Core::ConnectionManager *connectionManager() const;
|
||||
Core::VariableManager *variableManager() const;
|
||||
Core::ModeManager *modeManager() const;
|
||||
@ -149,6 +152,7 @@ private slots:
|
||||
void modeChanged(Core::IMode *mode);
|
||||
|
||||
private:
|
||||
void addUAVGadgetManager(Core::UAVGadgetManager *manager);
|
||||
void updateContextObject(IContext *context);
|
||||
void registerDefaultContainers();
|
||||
void registerDefaultActions();
|
||||
@ -168,6 +172,8 @@ private:
|
||||
ViewManager *m_viewManager;
|
||||
ModeManager *m_modeManager;
|
||||
QList<UAVGadgetManager*> m_uavGadgetManagers;
|
||||
QList<UAVGadgetMode*> m_uavGadgetModes;
|
||||
UAVGadgetInstanceManager *m_uavGadgetInstanceManager;
|
||||
ConnectionManager *m_connectionManager;
|
||||
MimeDatabase *m_mimeDatabase;
|
||||
FancyTabWidget *m_modeStack;
|
||||
|
175
ground/src/plugins/coreplugin/uavgadgetinstancemanager.cpp
Normal file
175
ground/src/plugins/coreplugin/uavgadgetinstancemanager.cpp
Normal file
@ -0,0 +1,175 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetinstancemanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
#include "uavgadgetoptionspage.h"
|
||||
#include "icore.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
|
||||
using namespace Core;
|
||||
|
||||
UAVGadgetInstanceManager::UAVGadgetInstanceManager(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
QList<IUAVGadgetFactory*> factories = pm->getObjects<IUAVGadgetFactory>();
|
||||
foreach (IUAVGadgetFactory *f, factories) {
|
||||
if (!m_uavGadgetFactories.contains(f)) {
|
||||
m_uavGadgetFactories.append(f);
|
||||
QString classId = f->classId();
|
||||
QString name = f->name();
|
||||
m_uavGadgetClassIds.insert(classId, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UAVGadgetInstanceManager::readUAVGadgetConfigurations()
|
||||
{
|
||||
QSettings *qs = Core::ICore::instance()->settings();
|
||||
qs->beginGroup("UAVGadgetConfigurations");
|
||||
foreach (QString classId, m_uavGadgetClassIds.keys())
|
||||
{
|
||||
IUAVGadgetFactory *f = uavGadgetFactory(classId);
|
||||
qs->beginGroup(classId);
|
||||
QStringList configs = qs->childKeys();
|
||||
|
||||
foreach (QString configName, configs) {
|
||||
QByteArray ba = QByteArray::fromBase64(qs->value(configName).toByteArray());
|
||||
QDataStream stream(ba);
|
||||
bool locked;
|
||||
stream >> locked;
|
||||
QByteArray state;
|
||||
stream >> state;
|
||||
IUAVGadgetConfiguration *config = f->createUAVGadgetConfiguration(locked, configName, state);
|
||||
m_uavGadgetConfigurations.append(config);
|
||||
}
|
||||
|
||||
if (configs.count() == 0) {
|
||||
IUAVGadgetConfiguration *config = f->createUAVGadgetConfiguration(false, tr("default"), 0);
|
||||
// it is not mandatory for uavgadgets to have any configurations (settings)
|
||||
// and therefore we have to check for that
|
||||
if (config)
|
||||
m_uavGadgetConfigurations.append(config);
|
||||
}
|
||||
qs->endGroup();
|
||||
}
|
||||
qs->endGroup();
|
||||
createUAVGadgetOptionPages();
|
||||
}
|
||||
|
||||
void UAVGadgetInstanceManager::writeUAVGadgetConfigurations()
|
||||
{
|
||||
QSettings *qs = Core::ICore::instance()->settings();
|
||||
qs->beginGroup("UAVGadgetConfigurations");
|
||||
qs->allKeys().clear(); // Remove existing configurations
|
||||
foreach (IUAVGadgetConfiguration *config, m_uavGadgetConfigurations)
|
||||
{
|
||||
qs->beginGroup(config->classId());
|
||||
QByteArray ba;
|
||||
QDataStream stream(&ba, QIODevice::WriteOnly);
|
||||
stream << config->locked();
|
||||
stream << config->saveState();
|
||||
qs->setValue(config->name(), ba.toBase64());
|
||||
qs->endGroup();
|
||||
}
|
||||
qs->endGroup();
|
||||
}
|
||||
|
||||
void UAVGadgetInstanceManager::createUAVGadgetOptionPages()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
foreach (IUAVGadgetConfiguration *config, m_uavGadgetConfigurations)
|
||||
{
|
||||
IUAVGadgetFactory *f = uavGadgetFactory(config->classId());
|
||||
UAVGadgetOptionsPage *page = f->createUAVGadgetOptionsPage(config);
|
||||
pm->addObject(page);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IUAVGadget *UAVGadgetInstanceManager::createUAVGadget(QString classId, QWidget *parent)
|
||||
{
|
||||
IUAVGadgetFactory *f = uavGadgetFactory(classId);
|
||||
if (f) {
|
||||
QList<IUAVGadgetConfiguration*> *configs = uavGadgetConfigurations(classId);
|
||||
IUAVGadget *gadget = f->createUAVGadget(configs, parent);
|
||||
m_uavGadgetInstances.append(gadget);
|
||||
return gadget;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//IUAVGadgetConfiguration *UAVGadgetInstanceManager::createUAVGadgetConfiguration(QString classId,
|
||||
// QString configName)
|
||||
//{
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
//UAVGadgetOptionsPage *UAVGadgetInstanceManager::createUAVGadgetOptionsPage(QString classId)
|
||||
//{
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
QStringList UAVGadgetInstanceManager::uavGadgetConfigurationNames(QString classId) const
|
||||
{
|
||||
QStringList names;
|
||||
return names;
|
||||
}
|
||||
|
||||
QString UAVGadgetInstanceManager::uavGadgetName(QString classId) const
|
||||
{
|
||||
return m_uavGadgetClassIds.value(classId);
|
||||
}
|
||||
|
||||
IUAVGadgetFactory *UAVGadgetInstanceManager::uavGadgetFactory(QString classId) const
|
||||
{
|
||||
foreach (IUAVGadgetFactory *f, m_uavGadgetFactories) {
|
||||
if (f->classId() == classId)
|
||||
return f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<IUAVGadgetConfiguration*> *UAVGadgetInstanceManager::uavGadgetConfigurations(QString classId) const
|
||||
{
|
||||
QList<IUAVGadgetConfiguration*> *configs = new QList<IUAVGadgetConfiguration*>;
|
||||
foreach (IUAVGadgetConfiguration *config, m_uavGadgetConfigurations) {
|
||||
if (config->classId() == classId)
|
||||
configs->append(config);
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
|
||||
|
74
ground/src/plugins/coreplugin/uavgadgetinstancemanager.h
Normal file
74
ground/src/plugins/coreplugin/uavgadgetinstancemanager.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetinstancemanager.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef UAVGADGETINSTANCEMANAGER_H
|
||||
#define UAVGADGETINSTANCEMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetConfiguration;
|
||||
class UAVGadgetOptionsPage;
|
||||
class IUAVGadgetFactory;
|
||||
|
||||
class UAVGadgetInstanceManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVGadgetInstanceManager(QObject *parent = 0);
|
||||
void readUAVGadgetConfigurations();
|
||||
void writeUAVGadgetConfigurations();
|
||||
IUAVGadget *createUAVGadget(QString classId, QWidget *parent);
|
||||
bool deleteUAVGadgetConfiguration(QString classId, QString configName);
|
||||
QStringList uavGadgetClassIds() const { return m_uavGadgetClassIds.keys(); }
|
||||
QStringList uavGadgetConfigurationNames(QString classId) const;
|
||||
QString uavGadgetName(QString classId) const;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
IUAVGadgetFactory *uavGadgetFactory(QString classId) const;
|
||||
void createUAVGadgetOptionPages();
|
||||
QList<IUAVGadgetConfiguration*> *uavGadgetConfigurations(QString classId) const;
|
||||
// UAVGadgetOptionsPage *createUAVGadgetOptionsPage(QString classId);
|
||||
QList<IUAVGadget*> m_uavGadgetInstances;
|
||||
QList<IUAVGadgetFactory*> m_uavGadgetFactories;
|
||||
QList<IUAVGadgetConfiguration*> m_uavGadgetConfigurations;
|
||||
QMap<QString, QString> m_uavGadgetClassIds;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // UAVGADGETINSTANCEMANAGER_H
|
@ -419,14 +419,6 @@ void UAVGadgetManager::updateActions()
|
||||
m_d->m_gotoOtherSplitAction->setEnabled(shown && hasSplitter);
|
||||
}
|
||||
|
||||
UAVGadgetFactoryList UAVGadgetManager::uavGadgetFactories() const
|
||||
{
|
||||
UAVGadgetFactoryList rc = pluginManager()->getObjects<Core::IUAVGadgetFactory>();
|
||||
//if (debugUAVGadgetManager)
|
||||
//qDebug() << Q_FUNC_INFO << rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
QByteArray UAVGadgetManager::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
@ -474,10 +466,10 @@ void UAVGadgetManager::saveSettings()
|
||||
|
||||
QSettings *qs = m_d->m_core->settings();
|
||||
// The idea is to have a default setting that is only written once
|
||||
if (!qs->contains(defaultUAVGadgetManagerKey.toLatin1()))
|
||||
qs->setValue(defaultUAVGadgetManagerKey.toLatin1(), saveState().toBase64());
|
||||
if (!qs->contains(defaultUAVGadgetManagerKey))
|
||||
qs->setValue(defaultUAVGadgetManagerKey, saveState().toBase64());
|
||||
else
|
||||
qs->setValue(uavGadgetManagerKey.toLatin1(), saveState().toBase64());
|
||||
qs->setValue(uavGadgetManagerKey, saveState().toBase64());
|
||||
}
|
||||
|
||||
void UAVGadgetManager::readSettings()
|
||||
@ -487,10 +479,10 @@ void UAVGadgetManager::readSettings()
|
||||
|
||||
QSettings *qs = m_d->m_core->settings();
|
||||
QString key("");
|
||||
if (qs->contains(uavGadgetManagerKey.toLatin1()))
|
||||
key = uavGadgetManagerKey.toLatin1();
|
||||
else if (qs->contains(defaultUAVGadgetManagerKey.toLatin1()))
|
||||
key = defaultUAVGadgetManagerKey.toLatin1();
|
||||
if (qs->contains(uavGadgetManagerKey))
|
||||
key = uavGadgetManagerKey;
|
||||
else if (qs->contains(defaultUAVGadgetManagerKey))
|
||||
key = defaultUAVGadgetManagerKey;
|
||||
else
|
||||
return;
|
||||
const QVariant &managerSettings = qs->value(key);
|
||||
|
@ -47,7 +47,6 @@ namespace Core {
|
||||
class IContext;
|
||||
class ICore;
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
class IMode;
|
||||
|
||||
struct UAVGadgetManagerPrivate;
|
||||
@ -78,8 +77,6 @@ private:
|
||||
UAVGadgetManagerPlaceHolder* m_current;
|
||||
};
|
||||
|
||||
typedef QList<IUAVGadgetFactory*> UAVGadgetFactoryList;
|
||||
|
||||
|
||||
class CORE_EXPORT UAVGadgetManager : public QWidget
|
||||
{
|
||||
@ -105,8 +102,6 @@ public:
|
||||
void readSettings();
|
||||
bool toolbarsShown() { return m_showToolbars; }
|
||||
|
||||
UAVGadgetFactoryList uavGadgetFactories() const;
|
||||
|
||||
signals:
|
||||
void currentUAVGadgetChanged(IUAVGadget *gadget);
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "uavgadgetview.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "iuavgadgetfactory.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "iuavgadget.h"
|
||||
#include "coreimpl.h"
|
||||
#include "minisplitter.h"
|
||||
@ -63,12 +63,12 @@ using namespace Core::Internal;
|
||||
|
||||
// ================UAVGadgetView====================
|
||||
|
||||
UAVGadgetView::UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget, QWidget *parent) :
|
||||
UAVGadgetView::UAVGadgetView(Core::UAVGadgetManager *uavGadgetManager, IUAVGadget *uavGadget, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_uavGadget(uavGadget),
|
||||
m_toolBar(new QWidget),
|
||||
m_defaultToolBar(new QWidget(this)),
|
||||
m_defaultToolBar(new QComboBox(this)),
|
||||
m_uavGadgetList(new QComboBox),
|
||||
m_closeButton(new QToolButton),
|
||||
m_defaultIndex(0),
|
||||
@ -80,15 +80,16 @@ UAVGadgetView::UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uav
|
||||
tl->setMargin(0);
|
||||
{
|
||||
m_uavGadgetList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
m_uavGadgetList->setMinimumContentsLength(20);
|
||||
m_uavGadgetList->setMinimumContentsLength(15);
|
||||
m_uavGadgetList->setMaxVisibleItems(40);
|
||||
m_uavGadgetList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
UAVGadgetFactoryList fl = m_uavGadgetManager->uavGadgetFactories();
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
QStringList sl = im->uavGadgetClassIds();
|
||||
int index = 0;
|
||||
foreach(Core::IUAVGadgetFactory *factory, fl)
|
||||
foreach(QString classId, sl)
|
||||
{
|
||||
m_uavGadgetList->addItem(factory->name(), factory->gadgetKind());
|
||||
if (factory->gadgetKind() == QString("EmptyGadget"))
|
||||
m_uavGadgetList->addItem(im->uavGadgetName(classId), classId);
|
||||
if (classId == QString("EmptyGadget"))
|
||||
m_defaultIndex = index;
|
||||
++index;
|
||||
}
|
||||
@ -101,7 +102,10 @@ UAVGadgetView::UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uav
|
||||
toolBarLayout->setSpacing(0);
|
||||
toolBarLayout->addWidget(m_defaultToolBar);
|
||||
m_toolBar->setLayout(toolBarLayout);
|
||||
m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
m_toolBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
|
||||
|
||||
QWidget *spacerWidget = new QWidget;
|
||||
spacerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
m_activeLabel->setTextFormat(Qt::RichText);
|
||||
|
||||
@ -112,7 +116,8 @@ UAVGadgetView::UAVGadgetView(UAVGadgetManager *uavGadgetManager, IUAVGadget *uav
|
||||
toplayout->setSpacing(0);
|
||||
toplayout->setMargin(0);
|
||||
toplayout->addWidget(m_uavGadgetList);
|
||||
toplayout->addWidget(m_toolBar, 1); // Custom toolbar stretches
|
||||
toplayout->addWidget(m_toolBar); // Custom toolbar stretches
|
||||
toplayout->addWidget(spacerWidget);
|
||||
toplayout->addWidget(m_activeLabel);
|
||||
toplayout->addWidget(m_closeButton);
|
||||
|
||||
@ -185,42 +190,45 @@ void UAVGadgetView::setUAVGadget(IUAVGadget *uavGadget)
|
||||
tl->addWidget(m_uavGadget->widget());
|
||||
m_uavGadget->widget()->setParent(this);
|
||||
m_uavGadget->widget()->show();
|
||||
int index = indexOfGadgetKind(m_uavGadget->gadgetKind());
|
||||
int index = indexOfClassId(m_uavGadget->classId());
|
||||
Q_ASSERT(index >= 0);
|
||||
m_uavGadgetList->setCurrentIndex(index);
|
||||
|
||||
// updateToolBar();
|
||||
updateToolBar();
|
||||
}
|
||||
|
||||
void UAVGadgetView::updateToolBar()
|
||||
{
|
||||
if (!m_uavGadget)
|
||||
return;
|
||||
QWidget *toolBar = m_uavGadget->toolBar();
|
||||
QComboBox *toolBar = m_uavGadget->toolBar();
|
||||
if (!toolBar)
|
||||
toolBar = m_defaultToolBar;
|
||||
if (m_activeToolBar == toolBar)
|
||||
return;
|
||||
toolBar->setVisible(true);
|
||||
toolBar->setVisible(toolBar->count() > 0);
|
||||
toolBar->setEnabled(toolBar->count() > 1);
|
||||
m_toolBar->layout()->addWidget(toolBar);
|
||||
m_activeToolBar->setVisible(false);
|
||||
m_activeToolBar = toolBar;
|
||||
}
|
||||
|
||||
void UAVGadgetView::listSelectionActivated(int index)
|
||||
{
|
||||
if (index < 0 || m_uavGadgetManager->uavGadgetFactories().count() == 0)
|
||||
if (index < 0) // this could happen when called from SplitterOrView::restoreState()
|
||||
index = m_defaultIndex;
|
||||
UAVGadgetInstanceManager *fm = ICore::instance()->uavGadgetInstanceManager();
|
||||
QString classId = m_uavGadgetList->itemData(index).toString();
|
||||
if (m_uavGadget && (m_uavGadget->classId() == classId))
|
||||
return;
|
||||
IUAVGadgetFactory *factory = m_uavGadgetManager->uavGadgetFactories().at(index);
|
||||
if (m_uavGadget && m_uavGadget->gadgetKind() == factory->gadgetKind())
|
||||
return;
|
||||
IUAVGadget *gadget = factory->createUAVGadget(this);
|
||||
IUAVGadget *gadget = fm->createUAVGadget(classId, this);
|
||||
setUAVGadget(gadget);
|
||||
m_uavGadgetManager->setCurrentUAVGadget(gadget);
|
||||
}
|
||||
|
||||
int UAVGadgetView::indexOfGadgetKind(QString gadgetKind)
|
||||
int UAVGadgetView::indexOfClassId(QString classId)
|
||||
{
|
||||
return m_uavGadgetList->findData(gadgetKind);
|
||||
return m_uavGadgetList->findData(classId);
|
||||
}
|
||||
|
||||
void UAVGadgetView::currentUAVGadgetChanged(IUAVGadget *gadget)
|
||||
@ -229,7 +237,7 @@ void UAVGadgetView::currentUAVGadgetChanged(IUAVGadget *gadget)
|
||||
|
||||
}
|
||||
|
||||
SplitterOrView::SplitterOrView(UAVGadgetManager *uavGadgetManager, Core::IUAVGadget *uavGadget, bool isRoot) :
|
||||
SplitterOrView::SplitterOrView(Core::UAVGadgetManager *uavGadgetManager, Core::IUAVGadget *uavGadget, bool isRoot) :
|
||||
m_uavGadgetManager(uavGadgetManager),
|
||||
m_isRoot(isRoot)
|
||||
{
|
||||
@ -265,8 +273,8 @@ void SplitterOrView::paintEvent(QPaintEvent *event)
|
||||
if (!m_view)
|
||||
return;
|
||||
|
||||
// if (hasUAVGadget())
|
||||
// return;
|
||||
if (hasUAVGadget())
|
||||
return;
|
||||
|
||||
if (m_uavGadgetManager->toolbarsShown())
|
||||
return;
|
||||
@ -550,7 +558,7 @@ QByteArray SplitterOrView::saveState() const
|
||||
<< static_cast<SplitterOrView*>(m_splitter->widget(1))->saveState();
|
||||
} else {
|
||||
if (uavGadget())
|
||||
stream << QByteArray("uavGadget") << uavGadget()->gadgetKind() << uavGadget()->saveState();
|
||||
stream << QByteArray("uavGadget") << uavGadget()->classId() << uavGadget()->saveState();
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
@ -569,11 +577,11 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
||||
static_cast<SplitterOrView*>(m_splitter->widget(0))->restoreState(first);
|
||||
static_cast<SplitterOrView*>(m_splitter->widget(1))->restoreState(second);
|
||||
} else if (mode == "uavGadget") {
|
||||
QString gadgetKind;
|
||||
QString classId;
|
||||
QByteArray uavGadgetState;
|
||||
stream >> gadgetKind >> uavGadgetState;
|
||||
stream >> classId >> uavGadgetState;
|
||||
m_view = new UAVGadgetView(m_uavGadgetManager, 0);
|
||||
int index = m_view->indexOfGadgetKind(gadgetKind);
|
||||
int index = m_view->indexOfClassId(classId);
|
||||
m_view->listSelectionActivated(index);
|
||||
m_layout->addWidget(m_view);
|
||||
m_layout->setCurrentWidget(m_view);
|
||||
|
@ -58,6 +58,7 @@ class UAVGadgetManager;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
|
||||
class UAVGadgetView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -70,7 +71,7 @@ public:
|
||||
IUAVGadget *uavGadget() const;
|
||||
void setUAVGadget(IUAVGadget *uavGadget);
|
||||
bool hasUAVGadget(IUAVGadget *uavGadget) const;
|
||||
int indexOfGadgetKind(QString gadgetKind);
|
||||
int indexOfClassId(QString classId);
|
||||
void showToolbar(bool show);
|
||||
|
||||
public slots:
|
||||
@ -86,7 +87,7 @@ private:
|
||||
UAVGadgetManager *m_uavGadgetManager;
|
||||
IUAVGadget *m_uavGadget;
|
||||
QWidget *m_toolBar;
|
||||
QWidget *m_defaultToolBar;
|
||||
QComboBox *m_defaultToolBar;
|
||||
QWidget *m_currentToolBar;
|
||||
QWidget *m_activeToolBar;
|
||||
QComboBox *m_uavGadgetList;
|
||||
|
68
ground/src/plugins/coreplugin/uavgadgetoptionspage.cpp
Normal file
68
ground/src/plugins/coreplugin/uavgadgetoptionspage.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetoptionspage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "uavgadgetoptionspage.h"
|
||||
#include "ui_uavgadgetoptionspage.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
#include "coreimpl.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
|
||||
using namespace Core;
|
||||
|
||||
UAVGadgetOptionsPage::UAVGadgetOptionsPage(IUAVGadgetConfiguration *config, QObject *parent) :
|
||||
Core::IOptionsPage(parent),
|
||||
m_config(config),
|
||||
m_id(config->name()),
|
||||
m_category(config->classId())
|
||||
{
|
||||
UAVGadgetInstanceManager *im = ICore::instance()->uavGadgetInstanceManager();
|
||||
m_categoryTr = im->uavGadgetName(m_category);
|
||||
}
|
||||
|
||||
QWidget *UAVGadgetOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_page = new Ui_TopOptionsPage();
|
||||
QWidget *w = new QWidget(parent);
|
||||
m_page->setupUi(w);
|
||||
if (m_config->locked()) {
|
||||
m_page->deleteButton->hide();
|
||||
m_page->lockCheckBox->hide();
|
||||
m_page->nameLineEdit->setDisabled(true);
|
||||
}
|
||||
m_page->lockCheckBox->hide(); //
|
||||
m_page->nameLineEdit->setText(m_id);
|
||||
QWidget *wi = widget();
|
||||
m_page->verticalLayout_4->addWidget(wi);
|
||||
|
||||
w->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
70
ground/src/plugins/coreplugin/uavgadgetoptionspage.h
Normal file
70
ground/src/plugins/coreplugin/uavgadgetoptionspage.h
Normal file
@ -0,0 +1,70 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavgadgetoptionspage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup coreplugin
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef UAVGADGETOPTIONSPAGE_H
|
||||
#define UAVGADGETOPTIONSPAGE_H
|
||||
#include "iuavgadgetconfiguration.h"
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
class Ui_TopOptionsPage;
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IUAVGadgetConfiguration;
|
||||
|
||||
class UAVGadgetOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVGadgetOptionsPage(IUAVGadgetConfiguration *config, QObject *parent = 0);
|
||||
|
||||
QString id() const { return m_id; }
|
||||
QString trName() const { return m_id; }
|
||||
QString category() const { return m_category; }
|
||||
QString trCategory() const { return m_categoryTr; }
|
||||
|
||||
/*final*/ QWidget *createPage(QWidget *parent); // do not override this function in subclasses
|
||||
virtual QWidget *widget() = 0; // implement this instead
|
||||
virtual void apply() = 0;
|
||||
virtual void finish() = 0;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
IUAVGadgetConfiguration *m_config;
|
||||
QString m_id;
|
||||
QString m_category;
|
||||
QString m_categoryTr;
|
||||
|
||||
Ui_TopOptionsPage *m_page;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // UAVGADGETOPTIONSPAGE_H
|
145
ground/src/plugins/coreplugin/uavgadgetoptionspage.ui
Normal file
145
ground/src/plugins/coreplugin/uavgadgetoptionspage.ui
Normal file
@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TopOptionsPage</class>
|
||||
<widget class="QWidget" name="TopOptionsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>555</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="configurationBox">
|
||||
<property name="title">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nameLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="cloneButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deleteButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>9</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="lockCheckBox">
|
||||
<property name="text">
|
||||
<string>Lock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>9</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="settingsBox">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user