mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Added a QML viewer plugin.
UAV objects used in PFD are available in the QMl context.
This commit is contained in:
parent
aead288304
commit
861b21a18d
@ -127,6 +127,13 @@ plugin_pfd.depends = plugin_coreplugin
|
||||
plugin_pfd.depends += plugin_uavobjects
|
||||
SUBDIRS += plugin_pfd
|
||||
|
||||
# Primary Flight Display (PFD) gadget
|
||||
plugin_qmlview.subdir = qmlview
|
||||
plugin_qmlview.depends = plugin_coreplugin
|
||||
plugin_qmlview.depends += plugin_uavobjects
|
||||
SUBDIRS += plugin_qmlview
|
||||
|
||||
|
||||
#IP connection plugin
|
||||
plugin_ipconnection.subdir = ipconnection
|
||||
plugin_ipconnection.depends = plugin_coreplugin
|
||||
|
12
ground/openpilotgcs/src/plugins/qmlview/QMLView.pluginspec
Normal file
12
ground/openpilotgcs/src/plugins/qmlview/QMLView.pluginspec
Normal file
@ -0,0 +1,12 @@
|
||||
<plugin name="QMLView" version="1.0.0" compatVersion="1.0.0">
|
||||
<vendor>The OpenPilot Project</vendor>
|
||||
<copyright>(C) 2010 Edouard Lafargue</copyright>
|
||||
<copyright>(C) 2012 Dmytro Poplavskiy</copyright>
|
||||
<license>The GNU Public License (GPL) Version 3</license>
|
||||
<description>QML viewer</description>
|
||||
<url>http://www.openpilot.org</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.0.0"/>
|
||||
<dependency name="UAVObjects" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
32
ground/openpilotgcs/src/plugins/qmlview/qmlview.pro
Normal file
32
ground/openpilotgcs/src/plugins/qmlview/qmlview.pro
Normal file
@ -0,0 +1,32 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = QMLView
|
||||
QT += svg
|
||||
QT += opengl
|
||||
QT += declarative
|
||||
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(qmlview_dependencies.pri)
|
||||
|
||||
HEADERS += \
|
||||
qmlviewplugin.h \
|
||||
qmlviewgadget.h \
|
||||
qmlviewgadgetwidget.h \
|
||||
qmlviewgadgetfactory.h \
|
||||
qmlviewgadgetconfiguration.h \
|
||||
qmlviewgadgetoptionspage.h \
|
||||
svgimageprovider.h
|
||||
|
||||
SOURCES += \
|
||||
qmlviewplugin.cpp \
|
||||
qmlviewgadget.cpp \
|
||||
qmlviewgadgetfactory.cpp \
|
||||
qmlviewgadgetwidget.cpp \
|
||||
qmlviewgadgetconfiguration.cpp \
|
||||
qmlviewgadgetoptionspage.cpp \
|
||||
svgimageprovider.cpp
|
||||
|
||||
OTHER_FILES += QMLView.pluginspec
|
||||
|
||||
FORMS += qmlviewgadgetoptionspage.ui
|
||||
|
@ -0,0 +1 @@
|
||||
include(../../plugins/uavobjects/uavobjects.pri)
|
55
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp
Normal file
55
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadget.cpp
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @author Dmytro Poplavskiy Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewgadget.h"
|
||||
#include "qmlviewgadgetwidget.h"
|
||||
#include "qmlviewgadgetconfiguration.h"
|
||||
|
||||
QmlViewGadget::QmlViewGadget(QString classId, QmlViewGadgetWidget *widget, QWidget *parent) :
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget)
|
||||
{
|
||||
}
|
||||
|
||||
QmlViewGadget::~QmlViewGadget()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
/*
|
||||
This is called when a configuration is loaded, and updates the plugin's settings.
|
||||
Careful: the plugin is already drawn before the loadConfiguration method is called the
|
||||
first time, so you have to be careful not to assume all the plugin values are initialized
|
||||
the first time you use them
|
||||
*/
|
||||
void QmlViewGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
{
|
||||
QmlViewGadgetConfiguration *m = qobject_cast<QmlViewGadgetConfiguration*>(config);
|
||||
m_widget->setQmlFile(m->dialFile());
|
||||
m_widget->enableOpenGL(m->useOpenGL());
|
||||
}
|
56
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h
Normal file
56
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadget.h
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadget.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWGADGET_H_
|
||||
#define QMLVIEWQMLGADGET_H_
|
||||
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
#include "qmlviewgadgetwidget.h"
|
||||
|
||||
class IUAVGadget;
|
||||
class QWidget;
|
||||
class QString;
|
||||
class QmlViewGadgetWidget;
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class QmlViewGadget : public Core::IUAVGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlViewGadget(QString classId, QmlViewGadgetWidget *widget, QWidget *parent = 0);
|
||||
~QmlViewGadget();
|
||||
|
||||
QWidget *widget() { return m_widget; }
|
||||
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||
|
||||
private:
|
||||
QmlViewGadgetWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
#endif // QMLVIEWQMLGADGET_H_
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetconfiguration.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewgadgetconfiguration.h"
|
||||
#include "utils/pathutils.h"
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
QmlViewGadgetConfiguration::QmlViewGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultDial("Unknown")
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString dialFile = qSettings->value("dialFile").toString();
|
||||
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
|
||||
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
*/
|
||||
IUAVGadgetConfiguration *QmlViewGadgetConfiguration::clone()
|
||||
{
|
||||
QmlViewGadgetConfiguration *m = new QmlViewGadgetConfiguration(this->classId());
|
||||
m->m_defaultDial=m_defaultDial;
|
||||
m->useOpenGLFlag = useOpenGLFlag;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void QmlViewGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
|
||||
qSettings->setValue("dialFile", dialFile);
|
||||
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetconfiguration.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWGADGETCONFIGURATION_H
|
||||
#define QMLVIEWGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class QmlViewGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlViewGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set dial configuration functions
|
||||
void setDialFile(QString dialFile){m_defaultDial=dialFile;}
|
||||
void setUseOpenGL(bool flag) { useOpenGLFlag = flag; }
|
||||
|
||||
//get dial configuration functions
|
||||
QString dialFile() {return m_defaultDial;}
|
||||
bool useOpenGL() { return useOpenGLFlag; }
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
QString m_defaultDial; // The name of the dial's SVG source file
|
||||
bool useOpenGLFlag;
|
||||
};
|
||||
|
||||
#endif // QmlViewGADGETCONFIGURATION_H
|
@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetfactory.cpp
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewgadgetfactory.h"
|
||||
#include "qmlviewgadgetwidget.h"
|
||||
#include "qmlviewgadget.h"
|
||||
#include "qmlviewgadgetconfiguration.h"
|
||||
#include "qmlviewgadgetoptionspage.h"
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
|
||||
QmlViewGadgetFactory::QmlViewGadgetFactory(QObject *parent) :
|
||||
IUAVGadgetFactory(QString("QmlViewGadget"),
|
||||
tr("QML Viewer, QML"),
|
||||
parent)
|
||||
{
|
||||
}
|
||||
|
||||
QmlViewGadgetFactory::~QmlViewGadgetFactory()
|
||||
{
|
||||
}
|
||||
|
||||
Core::IUAVGadget* QmlViewGadgetFactory::createGadget(QWidget *parent)
|
||||
{
|
||||
QmlViewGadgetWidget* gadgetWidget = new QmlViewGadgetWidget(parent);
|
||||
return new QmlViewGadget(QString("QmlViewGadget"), gadgetWidget, parent);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *QmlViewGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new QmlViewGadgetConfiguration(QString("QmlViewGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *QmlViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new QmlViewGadgetOptionsPage(qobject_cast<QmlViewGadgetConfiguration*>(config));
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetfactory.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWGADGETFACTORY_H_
|
||||
#define QMLVIEWGADGETFACTORY_H_
|
||||
|
||||
#include <coreplugin/iuavgadgetfactory.h>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadget;
|
||||
class IUAVGadgetFactory;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class QmlViewGadgetFactory : public IUAVGadgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QmlViewGadgetFactory(QObject *parent = 0);
|
||||
~QmlViewGadgetFactory();
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
#endif // QmlViewGADGETFACTORY_H_
|
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetoptionspage.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewgadgetoptionspage.h"
|
||||
#include "qmlviewgadgetconfiguration.h"
|
||||
#include "ui_qmlviewgadgetoptionspage.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavdataobject.h"
|
||||
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QtAlgorithms>
|
||||
#include <QStringList>
|
||||
|
||||
QmlViewGadgetOptionsPage::QmlViewGadgetOptionsPage(QmlViewGadgetConfiguration *config, QObject *parent) :
|
||||
IOptionsPage(parent),
|
||||
m_config(config)
|
||||
{
|
||||
}
|
||||
|
||||
//creates options page widget (uses the UI file)
|
||||
QWidget *QmlViewGadgetOptionsPage::createPage(QWidget *parent)
|
||||
{
|
||||
|
||||
options_page = new Ui::QmlViewGadgetOptionsPage();
|
||||
//main widget
|
||||
QWidget *optionsPageWidget = new QWidget;
|
||||
//main layout
|
||||
options_page->setupUi(optionsPageWidget);
|
||||
|
||||
|
||||
|
||||
// Restore the contents from the settings:
|
||||
options_page->svgSourceFile->setExpectedKind(Utils::PathChooser::File);
|
||||
options_page->svgSourceFile->setPromptDialogFilter(tr("QML file (*.qml)"));
|
||||
options_page->svgSourceFile->setPromptDialogTitle(tr("Choose QML file"));
|
||||
options_page->svgSourceFile->setPath(m_config->dialFile());
|
||||
options_page->useOpenGL->setChecked(m_config->useOpenGL());
|
||||
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user presses apply or OK.
|
||||
*
|
||||
* Saves the current values
|
||||
*
|
||||
*/
|
||||
void QmlViewGadgetOptionsPage::apply()
|
||||
{
|
||||
m_config->setDialFile(options_page->svgSourceFile->path());
|
||||
m_config->setUseOpenGL(options_page->useOpenGL->checkState());
|
||||
}
|
||||
|
||||
void QmlViewGadgetOptionsPage::finish()
|
||||
{
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetoptionspage.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWGADGETOPTIONSPAGE_H
|
||||
#define QMLVIEWGADGETOPTIONSPAGE_H
|
||||
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
#include "QString"
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Core {
|
||||
class IUAVGadgetConfiguration;
|
||||
}
|
||||
|
||||
class QmlViewGadgetConfiguration;
|
||||
|
||||
namespace Ui {
|
||||
class QmlViewGadgetOptionsPage;
|
||||
}
|
||||
|
||||
using namespace Core;
|
||||
|
||||
class QmlViewGadgetOptionsPage : public IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlViewGadgetOptionsPage(QmlViewGadgetConfiguration *config, QObject *parent = 0);
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
private:
|
||||
Ui::QmlViewGadgetOptionsPage *options_page;
|
||||
QmlViewGadgetConfiguration *m_config;
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
#endif // QmlViewGADGETOPTIONSPAGE_H
|
@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QmlViewGadgetOptionsPage</class>
|
||||
<widget class="QWidget" name="QmlViewGadgetOptionsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>529</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>QML file: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="svgSourceFile" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="useOpenGL">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use OpenGL for rendering</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
103
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp
Normal file
103
ground/openpilotgcs/src/plugins/qmlview/qmlviewgadgetwidget.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetwidget.cpp
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @author Dmytro Poplavskiy Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewgadgetwidget.h"
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/cachedsvgitem.h>
|
||||
#include <iostream>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QtOpenGL/QGLWidget>
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <QtDeclarative/qdeclarativeengine.h>
|
||||
#include <QtDeclarative/qdeclarativecontext.h>
|
||||
|
||||
QmlViewGadgetWidget::QmlViewGadgetWidget(QWidget *parent) :
|
||||
QDeclarativeView(parent)
|
||||
{
|
||||
setMinimumSize(64,64);
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
setResizeMode(SizeRootObjectToView);
|
||||
|
||||
QStringList objectsToExport;
|
||||
objectsToExport << "VelocityActual" <<
|
||||
"PositionActual" <<
|
||||
"AttitudeActual" <<
|
||||
"GPSPosition" <<
|
||||
"GCSTelemetryStats" <<
|
||||
"FlightBatteryState";
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
foreach (const QString &objectName, objectsToExport) {
|
||||
UAVObject* object = objManager->getObject(objectName);
|
||||
if (object)
|
||||
engine()->rootContext()->setContextProperty(objectName, object);
|
||||
else
|
||||
qWarning() << "Failed to load object" << objectName;
|
||||
}
|
||||
}
|
||||
|
||||
QmlViewGadgetWidget::~QmlViewGadgetWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void QmlViewGadgetWidget::setQmlFile(QString fn)
|
||||
{
|
||||
m_fn = fn;
|
||||
|
||||
engine()->removeImageProvider("svg");
|
||||
engine()->addImageProvider("svg",
|
||||
new SvgImageProvider(fn));
|
||||
|
||||
qDebug() << Q_FUNC_INFO << fn;
|
||||
setSource(QUrl::fromLocalFile(fn));
|
||||
|
||||
foreach(const QDeclarativeError &error, errors()) {
|
||||
qDebug() << error.description();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Enables/Disables OpenGL
|
||||
*/
|
||||
void QmlViewGadgetWidget::enableOpenGL(bool flag) {
|
||||
if (flag) {
|
||||
setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
|
||||
} else {
|
||||
setViewport(new QWidget);
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewgadgetwidget.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWGADGETWIDGET_H_
|
||||
#define QMLVIEWGADGETWIDGET_H_
|
||||
|
||||
#include "qmlviewgadgetconfiguration.h"
|
||||
#include "svgimageprovider.h"
|
||||
|
||||
#include <QtDeclarative/qdeclarativeview.h>
|
||||
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
class UAVObject;
|
||||
|
||||
class QmlViewGadgetWidget : public QDeclarativeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlViewGadgetWidget(QWidget *parent = 0);
|
||||
~QmlViewGadgetWidget();
|
||||
void setQmlFile(QString fn);
|
||||
|
||||
void enableOpenGL(bool flag);
|
||||
void enableSmoothUpdates(bool flag) { beSmooth = flag; }
|
||||
|
||||
private:
|
||||
// Flag to enable better rendering of fonts in OpenGL
|
||||
bool beSmooth;
|
||||
QString m_fn;
|
||||
};
|
||||
#endif /* QmlViewGADGETWIDGET_H_ */
|
66
ground/openpilotgcs/src/plugins/qmlview/qmlviewplugin.cpp
Normal file
66
ground/openpilotgcs/src/plugins/qmlview/qmlviewplugin.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewplugin.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "qmlviewplugin.h"
|
||||
#include "qmlviewgadgetfactory.h"
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
|
||||
QmlViewPlugin::QmlViewPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
QmlViewPlugin::~QmlViewPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool QmlViewPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
{
|
||||
Q_UNUSED(args);
|
||||
Q_UNUSED(errMsg);
|
||||
mf = new QmlViewGadgetFactory(this);
|
||||
addAutoReleasedObject(mf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QmlViewPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
void QmlViewPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
Q_EXPORT_PLUGIN(QmlViewPlugin)
|
||||
|
47
ground/openpilotgcs/src/plugins/qmlview/qmlviewplugin.h
Normal file
47
ground/openpilotgcs/src/plugins/qmlview/qmlviewplugin.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file qmlviewplugin.h
|
||||
* @author Edouard Lafargue Copyright (C) 2010.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief The QML Viewer Gadget
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 QMLVIEWPLUGIN_H_
|
||||
#define QMLVIEWPLUGIN_H_
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
class QmlViewGadgetFactory;
|
||||
|
||||
class QmlViewPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
public:
|
||||
QmlViewPlugin();
|
||||
~QmlViewPlugin();
|
||||
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
private:
|
||||
QmlViewGadgetFactory *mf;
|
||||
};
|
||||
#endif /* QMLVIEWPLUGIN_H_ */
|
130
ground/openpilotgcs/src/plugins/qmlview/svgimageprovider.cpp
Normal file
130
ground/openpilotgcs/src/plugins/qmlview/svgimageprovider.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file svgimageprovider.cpp
|
||||
* @author Dmytro Poplavskiy Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief Svg declarative image provider
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "svgimageprovider.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QUrl>
|
||||
|
||||
SvgImageProvider::SvgImageProvider(const QString &basePath):
|
||||
QDeclarativeImageProvider(QDeclarativeImageProvider::Image),
|
||||
m_basePath(basePath)
|
||||
{
|
||||
}
|
||||
|
||||
SvgImageProvider::~SvgImageProvider()
|
||||
{
|
||||
qDeleteAll(m_renderers);
|
||||
}
|
||||
|
||||
/**
|
||||
requestedSize is realted to the whole svg file, not to specific element
|
||||
*/
|
||||
QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{
|
||||
QString svgFile = id;
|
||||
QString element;
|
||||
|
||||
int separatorPos = id.indexOf('!');
|
||||
if (separatorPos != -1) {
|
||||
svgFile = id.left(separatorPos);
|
||||
element = id.mid(separatorPos+1);
|
||||
}
|
||||
|
||||
if (size)
|
||||
*size = QSize();
|
||||
|
||||
QSvgRenderer *renderer = m_renderers.value(svgFile);
|
||||
if (!renderer) {
|
||||
renderer = new QSvgRenderer(svgFile);
|
||||
|
||||
QString fn = QUrl::fromLocalFile(m_basePath).resolved(svgFile).toLocalFile();
|
||||
|
||||
//convert path to be relative to base
|
||||
if (!renderer->isValid())
|
||||
renderer->load(fn);
|
||||
|
||||
if (!renderer->isValid()) {
|
||||
qWarning() << "Failed to load svg file:" << svgFile << fn;
|
||||
return QImage();
|
||||
}
|
||||
|
||||
m_renderers.insert(svgFile, renderer);
|
||||
}
|
||||
|
||||
qreal xScale = 1.0;
|
||||
qreal yScale = 1.0;
|
||||
|
||||
QSize docSize = renderer->defaultSize();
|
||||
|
||||
if (!requestedSize.isEmpty() && !docSize.isEmpty()) {
|
||||
xScale = qreal(requestedSize.width())/docSize.width();
|
||||
yScale = qreal(requestedSize.height())/docSize.height();
|
||||
}
|
||||
|
||||
//keep the aspect ratio
|
||||
//TODO: how to configure it? as a part of image path?
|
||||
xScale = yScale = qMin(xScale, yScale);
|
||||
|
||||
if (!element.isEmpty()) {
|
||||
if (!renderer->elementExists(element)) {
|
||||
qWarning() << "invalid element:" << element << "of" << svgFile;
|
||||
return QImage();
|
||||
}
|
||||
|
||||
QRectF elementBounds = renderer->boundsOnElement(element);
|
||||
int w = qRound(elementBounds.width() * xScale);
|
||||
int h = qRound(elementBounds.height() * yScale);
|
||||
|
||||
QImage img(w, h, QImage::Format_ARGB32_Premultiplied);
|
||||
img.fill(0);
|
||||
QPainter p(&img);
|
||||
renderer->render(&p, element);
|
||||
|
||||
if (size)
|
||||
*size = QSize(w, h);
|
||||
return img;
|
||||
} else {
|
||||
//render the whole svg file
|
||||
int w = qRound(docSize.width() * xScale);
|
||||
int h = qRound(docSize.height() * yScale);
|
||||
|
||||
QImage img(w, h, QImage::Format_ARGB32_Premultiplied);
|
||||
img.fill(0);
|
||||
QPainter p(&img);
|
||||
renderer->render(&p);
|
||||
|
||||
if (size)
|
||||
*size = QSize(w, h);
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap SvgImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
{
|
||||
return QPixmap::fromImage(requestImage(id, size, requestedSize));
|
||||
}
|
49
ground/openpilotgcs/src/plugins/qmlview/svgimageprovider.h
Normal file
49
ground/openpilotgcs/src/plugins/qmlview/svgimageprovider.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file svgimageprovider.h
|
||||
* @author Dmytro Poplavskiy Copyright (C) 2012.
|
||||
* @addtogroup GCSPlugins GCS Plugins
|
||||
* @{
|
||||
* @addtogroup OPMapPlugin QML Viewer Plugin
|
||||
* @{
|
||||
* @brief Svg declarative image provider
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 SVGIMAGEPROVIDER_H_
|
||||
#define SVGIMAGEPROVIDER_H_
|
||||
|
||||
#include <QtDeclarative/qdeclarativeimageprovider.h>
|
||||
#include <QSvgRenderer>
|
||||
#include <QMap>
|
||||
|
||||
class SvgImageProvider : public QDeclarativeImageProvider
|
||||
{
|
||||
public:
|
||||
SvgImageProvider(const QString &basePath);
|
||||
~SvgImageProvider();
|
||||
|
||||
QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
|
||||
QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize);
|
||||
|
||||
private:
|
||||
QMap<QString, QSvgRenderer*> m_renderers;
|
||||
QString m_basePath;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user