mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-99 gcs Import/Export Plugin: Support configurable plugins
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2732 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
9a5d099a79
commit
eab8421e5f
@ -12,6 +12,7 @@ namespace Core {
|
|||||||
|
|
||||||
class CORE_EXPORT IConfigurablePlugin : public ExtensionSystem::IPlugin
|
class CORE_EXPORT IConfigurablePlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// IConfigurablePlugin(QObject *parent = 0){}
|
// IConfigurablePlugin(QObject *parent = 0){}
|
||||||
virtual ~IConfigurablePlugin() {}
|
virtual ~IConfigurablePlugin() {}
|
||||||
|
@ -285,7 +285,7 @@ void MainWindow::extensionsInitialized()
|
|||||||
// qDebug() << "Number of keys in config: " << qs->allKeys().count();
|
// qDebug() << "Number of keys in config: " << qs->allKeys().count();
|
||||||
|
|
||||||
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
m_uavGadgetInstanceManager = new UAVGadgetInstanceManager(this);
|
||||||
m_uavGadgetInstanceManager->readConfigurations(qs);
|
m_uavGadgetInstanceManager->readSettings(qs);
|
||||||
|
|
||||||
m_messageManager->init();
|
m_messageManager->init();
|
||||||
readSettings(qs);
|
readSettings(qs);
|
||||||
@ -313,7 +313,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
emit m_coreImpl->coreAboutToClose();
|
emit m_coreImpl->coreAboutToClose();
|
||||||
saveSettings(m_settings);
|
saveSettings(m_settings);
|
||||||
|
|
||||||
m_uavGadgetInstanceManager->writeConfigurations(m_settings);
|
m_uavGadgetInstanceManager->saveSettings(m_settings);
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ UAVGadgetInstanceManager::~UAVGadgetInstanceManager()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::readConfigurations(QSettings *qs)
|
void UAVGadgetInstanceManager::readSettings(QSettings *qs)
|
||||||
{
|
{
|
||||||
while ( !m_configurations.isEmpty() ){
|
while ( !m_configurations.isEmpty() ){
|
||||||
emit configurationToBeDeleted(m_configurations.takeLast());
|
emit configurationToBeDeleted(m_configurations.takeLast());
|
||||||
@ -204,7 +204,7 @@ void UAVGadgetInstanceManager::readConfigs_1_1_0(QSettings *qs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAVGadgetInstanceManager::writeConfigurations(QSettings *qs)
|
void UAVGadgetInstanceManager::saveSettings(QSettings *qs)
|
||||||
{
|
{
|
||||||
UAVConfigInfo *configInfo;
|
UAVConfigInfo *configInfo;
|
||||||
qs->beginGroup("UAVGadgetConfigurations");
|
qs->beginGroup("UAVGadgetConfigurations");
|
||||||
|
@ -58,8 +58,8 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit UAVGadgetInstanceManager(QObject *parent = 0);
|
explicit UAVGadgetInstanceManager(QObject *parent = 0);
|
||||||
~UAVGadgetInstanceManager();
|
~UAVGadgetInstanceManager();
|
||||||
void readConfigurations(QSettings *qs);
|
void readSettings(QSettings *qs);
|
||||||
void writeConfigurations(QSettings *qs);
|
void saveSettings(QSettings *qs);
|
||||||
IUAVGadget *createGadget(QString classId, QWidget *parent);
|
IUAVGadget *createGadget(QString classId, QWidget *parent);
|
||||||
void removeGadget(IUAVGadget *gadget);
|
void removeGadget(IUAVGadget *gadget);
|
||||||
void removeAllGadgets();
|
void removeAllGadgets();
|
||||||
|
@ -47,8 +47,7 @@ ImportExportGadgetConfiguration::ImportExportGadgetConfiguration(QString classId
|
|||||||
if ( !configInfo->standardVersionHandlingOK(VERSION))
|
if ( !configInfo->standardVersionHandlingOK(VERSION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iniFile = qSettings->value("dialFile", "gcs.ini").toString(); // TODO Delete with next minor version.
|
iniFile = qSettings->value("iniFile", "gcs.xml").toString();
|
||||||
iniFile = qSettings->value("iniFile", iniFile).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +67,6 @@ IUAVGadgetConfiguration *ImportExportGadgetConfiguration::clone()
|
|||||||
*/
|
*/
|
||||||
void ImportExportGadgetConfiguration::saveConfig(QSettings* qSettings, Core::UAVConfigInfo *configInfo) const {
|
void ImportExportGadgetConfiguration::saveConfig(QSettings* qSettings, Core::UAVConfigInfo *configInfo) const {
|
||||||
configInfo->setVersion(VERSION);
|
configInfo->setVersion(VERSION);
|
||||||
qSettings->setValue("dialFile", iniFile);
|
|
||||||
qSettings->setValue("iniFile", iniFile);
|
qSettings->setValue("iniFile", iniFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ QWidget *ImportExportGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
|
|
||||||
// Restore the contents from the settings:
|
// Restore the contents from the settings:
|
||||||
options_page->iniFile->setExpectedKind(Utils::PathChooser::File);
|
options_page->iniFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
options_page->iniFile->setPromptDialogFilter(tr("INI file (*.ini)"));
|
options_page->iniFile->setPromptDialogFilter(tr("INI file (*.ini);; XML file (*.xml)"));
|
||||||
options_page->iniFile->setPromptDialogTitle(tr("Choose configuration file"));
|
options_page->iniFile->setPromptDialogTitle(tr("Choose configuration file"));
|
||||||
options_page->iniFile->setPath(m_config->getIniFile());
|
options_page->iniFile->setPath(m_config->getIniFile());
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include "xmlconfig.h"
|
#include "xmlconfig.h"
|
||||||
#include "coreplugin/uavgadgetinstancemanager.h"
|
#include "coreplugin/uavgadgetinstancemanager.h"
|
||||||
#include "coreplugin/icore.h"
|
#include "coreplugin/icore.h"
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -47,7 +49,7 @@ ImportExportGadgetWidget::ImportExportGadgetWidget(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->configFile->setExpectedKind(Utils::PathChooser::File);
|
ui->configFile->setExpectedKind(Utils::PathChooser::File);
|
||||||
ui->configFile->setPromptDialogFilter(tr("INI file (*.ini);; XML file (*.xml)"));
|
ui->configFile->setPromptDialogFilter(tr("INI file (*.ini);; XML file (*.xml)"));
|
||||||
ui->configFile->setPromptDialogTitle(tr("Choose filename"));
|
ui->configFile->setPromptDialogTitle(tr("Choose configuration file"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -111,11 +113,26 @@ void ImportExportGadgetWidget::on_exportButton_clicked()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Core::IConfigurablePlugin*> ImportExportGadgetWidget::getConfigurables()
|
||||||
|
{
|
||||||
|
QList<Core::IConfigurablePlugin*> configurables;
|
||||||
|
|
||||||
|
QList<ExtensionSystem::PluginSpec *> specs = ExtensionSystem::PluginManager::instance()->plugins();
|
||||||
|
foreach ( ExtensionSystem::PluginSpec* spec, specs ){
|
||||||
|
if ( Core::IConfigurablePlugin* plugin = dynamic_cast<Core::IConfigurablePlugin*>(spec->plugin()) ){
|
||||||
|
qDebug()<< "Configurable: " << plugin->metaObject()->className();
|
||||||
|
configurables.append(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return configurables;
|
||||||
|
}
|
||||||
|
|
||||||
void ImportExportGadgetWidget::exportConfiguration(const QString& fileName)
|
void ImportExportGadgetWidget::exportConfiguration(const QString& fileName)
|
||||||
{
|
{
|
||||||
bool general = ui->checkBoxGeneral->isChecked();
|
bool doGeneral = ui->checkBoxGeneral->isChecked();
|
||||||
bool allGadgets = ui->checkBoxAllGadgets->isChecked();
|
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
||||||
|
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
||||||
|
|
||||||
QSettings::Format format;
|
QSettings::Format format;
|
||||||
if ( ui->radioButtonIniFormat->isChecked() ){
|
if ( ui->radioButtonIniFormat->isChecked() ){
|
||||||
format = QSettings::IniFormat;
|
format = QSettings::IniFormat;
|
||||||
@ -130,12 +147,18 @@ void ImportExportGadgetWidget::exportConfiguration(const QString& fileName)
|
|||||||
|
|
||||||
QSettings qs(fileName, format);
|
QSettings qs(fileName, format);
|
||||||
|
|
||||||
if (general) {
|
if (doGeneral) {
|
||||||
Core::ICore::instance()->saveMainSettings(&qs);
|
Core::ICore::instance()->saveMainSettings(&qs);
|
||||||
}
|
}
|
||||||
if (allGadgets) {
|
if (doAllGadgets) {
|
||||||
Core::ICore::instance()->uavGadgetInstanceManager()->writeConfigurations(&qs);
|
Core::ICore::instance()->uavGadgetInstanceManager()->saveSettings(&qs);
|
||||||
}
|
}
|
||||||
|
if ( doPlugins ){
|
||||||
|
foreach ( Core::IConfigurablePlugin *plugin, getConfigurables()){
|
||||||
|
Core::ICore::instance()->saveSettings(plugin,&qs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Export ended";
|
qDebug() << "Export ended";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +189,10 @@ void ImportExportGadgetWidget::on_importButton_clicked()
|
|||||||
|
|
||||||
void ImportExportGadgetWidget::importConfiguration(const QString& fileName)
|
void ImportExportGadgetWidget::importConfiguration(const QString& fileName)
|
||||||
{
|
{
|
||||||
bool general = ui->checkBoxGeneral->isChecked();
|
bool doGeneral = ui->checkBoxGeneral->isChecked();
|
||||||
bool allGadgets = ui->checkBoxAllGadgets->isChecked();
|
bool doAllGadgets = ui->checkBoxAllGadgets->isChecked();
|
||||||
|
bool doPlugins = ui->checkBoxPlugins->isChecked();
|
||||||
|
|
||||||
QSettings::Format format;
|
QSettings::Format format;
|
||||||
if ( ui->radioButtonIniFormat->isChecked() ){
|
if ( ui->radioButtonIniFormat->isChecked() ){
|
||||||
format = QSettings::IniFormat;
|
format = QSettings::IniFormat;
|
||||||
@ -182,12 +207,17 @@ void ImportExportGadgetWidget::importConfiguration(const QString& fileName)
|
|||||||
|
|
||||||
QSettings qs(fileName, format);
|
QSettings qs(fileName, format);
|
||||||
|
|
||||||
if (allGadgets) {
|
if ( doAllGadgets ) {
|
||||||
Core::ICore::instance()->uavGadgetInstanceManager()->readConfigurations(&qs);
|
Core::ICore::instance()->uavGadgetInstanceManager()->readSettings(&qs);
|
||||||
}
|
}
|
||||||
if (general) {
|
if ( doGeneral ) {
|
||||||
Core::ICore::instance()->readMainSettings(&qs);
|
Core::ICore::instance()->readMainSettings(&qs);
|
||||||
}
|
}
|
||||||
|
if ( doPlugins ){
|
||||||
|
foreach ( Core::IConfigurablePlugin *plugin, getConfigurables()){
|
||||||
|
Core::ICore::instance()->readSettings(plugin,&qs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Import ended";
|
qDebug() << "Import ended";
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <coreplugin/iconfigurableplugin.h>
|
||||||
#include "importexportgadgetconfiguration.h"
|
#include "importexportgadgetconfiguration.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -40,6 +41,7 @@ private:
|
|||||||
void writeError(const QString&) const;
|
void writeError(const QString&) const;
|
||||||
void exportConfiguration(const QString& fileName);
|
void exportConfiguration(const QString& fileName);
|
||||||
void importConfiguration(const QString& fileName);
|
void importConfiguration(const QString& fileName);
|
||||||
|
QList<Core::IConfigurablePlugin*> getConfigurables();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_helpButton_clicked();
|
void on_helpButton_clicked();
|
||||||
|
@ -67,6 +67,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxPlugins">
|
||||||
|
<property name="text">
|
||||||
|
<string>Plugins</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user