1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-99 Import/Export Plugin: Integration to File menu.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1448 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
erhard 2010-08-28 18:40:28 +00:00 committed by erhard
parent fcb7a034cf
commit 331dba4870
12 changed files with 193 additions and 14 deletions

View File

@ -5,17 +5,20 @@ QT += svg
include(../../openpilotgcsplugin.pri)
include(importexport_dependencies.pri)
HEADERS += importexportplugin.h \
importexportgadgetwidget.h
importexportgadgetwidget.h \
importexportdialog.h
HEADERS += importexportgadget.h
HEADERS += importexportgadgetfactory.h
HEADERS += importexportgadgetconfiguration.h
HEADERS += importexportgadgetoptionspage.h
SOURCES += importexportplugin.cpp \
importexportgadgetwidget.cpp
importexportgadgetwidget.cpp \
importexportdialog.cpp
SOURCES += importexportgadget.cpp
SOURCES += importexportgadgetfactory.cpp
SOURCES += importexportgadgetconfiguration.cpp
SOURCES += importexportgadgetoptionspage.cpp
OTHER_FILES += ImportExportGadget.pluginspec
FORMS += importexportgadgetoptionspage.ui \
importexportgadgetwidget.ui
importexportgadgetwidget.ui \
importexportdialog.ui

View File

@ -0,0 +1,30 @@
#include "importexportdialog.h"
#include "ui_importexportdialog.h"
ImportExportDialog::ImportExportDialog( ImportExportGadgetConfiguration *config, QWidget *parent) :
QDialog(parent),
ui(new Ui::ImportExportDialog)
{
ui->setupUi(this);
ui->widget->loadConfiguration(config);
setWindowTitle(tr("Import Export Settings"));
connect( ui->widget, SIGNAL(done()), this, SLOT(close()));
}
ImportExportDialog::~ImportExportDialog()
{
delete ui;
}
void ImportExportDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}

View File

@ -0,0 +1,26 @@
#ifndef IMPORTEXPORTDIALOG_H
#define IMPORTEXPORTDIALOG_H
#include <QDialog>
#include "importexportgadgetconfiguration.h"
namespace Ui {
class ImportExportDialog;
}
class ImportExportDialog : public QDialog
{
Q_OBJECT
public:
explicit ImportExportDialog( ImportExportGadgetConfiguration *config, QWidget *parent = 0);
~ImportExportDialog();
protected:
void changeEvent(QEvent *e);
private:
Ui::ImportExportDialog *ui;
};
#endif // IMPORTEXPORTDIALOG_H

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportExportDialog</class>
<widget class="QDialog" name="ImportExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="ImportExportGadgetWidget" name="widget" native="true"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ImportExportGadgetWidget</class>
<extends>QWidget</extends>
<header>importexportgadgetwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ImportExportDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ImportExportDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -49,8 +49,7 @@ ImportExportGadget::~ImportExportGadget()
*/
void ImportExportGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ImportExportGadgetConfiguration *m = qobject_cast<ImportExportGadgetConfiguration*>(config);
m_widget->setDialFile(m->getDialFile());
m_widget->loadConfiguration(qobject_cast<ImportExportGadgetConfiguration*>(config));
}
/**
* @}

View File

@ -47,7 +47,7 @@ public:
}
//get dial configuration functions
QString getDialFile() {
QString getDialFile() const{
return dialFile;
}

View File

@ -52,7 +52,8 @@ Core::IUAVGadget* ImportExportGadgetFactory::createGadget(QWidget *parent)
IUAVGadgetConfiguration *ImportExportGadgetFactory::createConfiguration(const QByteArray &state)
{
return new ImportExportGadgetConfiguration(QString("ImportExportGadget"), state);
lastConfig = new ImportExportGadgetConfiguration(QString("ImportExportGadget"), state);
return lastConfig;
}
IOptionsPage *ImportExportGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -28,7 +28,7 @@
#define IMPORTEXPORTGADGETFACTORY_H_
#include <coreplugin/iuavgadgetfactory.h>
#include "importexport_global.h"
#include "importexportgadgetconfiguration.h"
namespace Core
{
@ -44,10 +44,14 @@ class IMPORTEXPORT_EXPORT ImportExportGadgetFactory : public IUAVGadgetFactory
public:
ImportExportGadgetFactory(QObject *parent = 0);
~ImportExportGadgetFactory();
ImportExportGadgetConfiguration *getLastConfig(){ return lastConfig;}
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
private:
ImportExportGadgetConfiguration *lastConfig;
};
#endif // IMPORTEXPORTGADGETFACTORY_H_

View File

@ -62,10 +62,12 @@ void ImportExportGadgetWidget::changeEvent(QEvent *e)
break;
}
}
void ImportExportGadgetWidget::setDialFile(const QString& filename)
void ImportExportGadgetWidget::loadConfiguration(const ImportExportGadgetConfiguration* config)
{
ui->configFile->setText(filename);
if ( !config )
return;
ui->configFile->setText(config->getDialFile());
}
void ImportExportGadgetWidget::on_exportButton_clicked()
@ -85,6 +87,7 @@ void ImportExportGadgetWidget::on_exportButton_clicked()
msgBox.setText(tr("The settings have been exported to ") + QFileInfo(file).absoluteFilePath());
msgBox.exec();
emit done();
}
@ -127,6 +130,7 @@ void ImportExportGadgetWidget::on_importButton_clicked()
msgBox.setText(tr("The settings have been imported from ") + QFileInfo(file).absoluteFilePath()
+ tr(". Restart the application."));
msgBox.exec();
emit done();
}
void ImportExportGadgetWidget::importConfiguration(const QString& fileName)
@ -143,12 +147,12 @@ void ImportExportGadgetWidget::importConfiguration(const QString& fileName)
Core::ICore::instance()->readMainSettings(&qs);
}
qDebug() << "Import ended";
}
void ImportExportGadgetWidget::on_helpButton_clicked()
{
qDebug() << "Show Help";
QDesktopServices::openUrl(QUrl("http://wiki.openpilot.org/Import_Export_plugin"));
}
/**

View File

@ -13,7 +13,7 @@
#include <QWidget>
#include <QString>
#include "importexport_global.h"
#include "importexportgadgetconfiguration.h"
namespace Ui
{
@ -27,7 +27,10 @@ public:
ImportExportGadgetWidget(QWidget *parent = 0);
~ImportExportGadgetWidget();
void setDialFile(const QString& filename);
void loadConfiguration(const ImportExportGadgetConfiguration* config);
signals:
void done();
protected:
void changeEvent(QEvent *e);

View File

@ -29,11 +29,17 @@
#include "importexportplugin.h"
#include "importexportgadgetfactory.h"
#include "importexportdialog.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <QKeySequence>
ImportExportPlugin::ImportExportPlugin()
{
@ -52,9 +58,31 @@ bool ImportExportPlugin::initialize(const QStringList& args, QString *errMsg)
mf = new ImportExportGadgetFactory(this);
addAutoReleasedObject(mf);
// Add Menu entry
Core::ActionManager* am = Core::ICore::instance()->actionManager();
Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_FILE);
Core::Command* cmd = am->registerAction(new QAction(this),
"ImportExportPlugin.ImportExport",
QList<int>() <<
Core::Constants::C_GLOBAL_ID);
cmd->setDefaultKeySequence(QKeySequence("Ctrl+I"));
cmd->action()->setText("Import/Export...");
ac->menu()->addSeparator();
ac->appendGroup("ImportExport");
ac->addAction(cmd, "ImportExport");
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(importExport()));
return true;
}
void ImportExportPlugin::importExport()
{
ImportExportDialog(mf->getLastConfig()).exec();
}
void ImportExportPlugin::extensionsInitialized()
{
// Do nothing

View File

@ -34,6 +34,8 @@ class ImportExportGadgetFactory;
class IMPORTEXPORT_EXPORT ImportExportPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
public:
ImportExportPlugin();
~ImportExportPlugin();
@ -43,6 +45,10 @@ public:
void shutdown();
private:
ImportExportGadgetFactory *mf;
private slots:
void importExport();
};
#endif /* IMPORTEXPORTPLUGIN_H_ */
/**