diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 800cf4bd5..18df7808e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml index 45daff990..198b9502c 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import "." Item { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml index e49145fca..c5f7c36f1 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/HorizontCenter.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml index 7759188d6..2697019a6 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: info diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 18fd41c40..0670e1f36 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -1,4 +1,4 @@ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { color: "#666666" diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml index 641bbbb2e..a254f231e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml index 2beebf05f..21355d16f 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdTerrainView.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import org.OpenPilot 1.0 OsgEarth { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml index ef21f0a20..5fa6f764d 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: worldView diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml index d3551046c..66263efd6 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/RollScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 import "." Item { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index 215fca11e..e0b971afa 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml index 2830ac941..6006380f0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Image { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml index fc1d81cb6..cc43a024b 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementPositionItem.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml index 29f846859..c40591424 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: sceneItem diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml index 12af0d24b..0f86755e0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Warnings.qml @@ -1,4 +1,4 @@ -import Qt 4.7 +import QtQuick 2.0 Item { id: warnings diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro b/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro index 55f15b4d2..0d7da9e26 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqml.pro @@ -2,7 +2,7 @@ TEMPLATE = lib TARGET = PfdQml QT += svg QT += opengl -QT += declarative +QT += qml quick OSG { DEFINES += USE_OSG } diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp index 365a323b7..30e803f33 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp @@ -21,7 +21,10 @@ PfdQmlGadget::PfdQmlGadget(QString classId, PfdQmlGadgetWidget *widget, QWidget *parent) : IUAVGadget(classId, parent), m_widget(widget) -{} +{ + m_container = NULL; + m_parent = parent; +} PfdQmlGadget::~PfdQmlGadget() { diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h index b6525007f..131ab9b31 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.h @@ -35,11 +35,18 @@ public: QWidget *widget() { - return m_widget; + if(!m_container){ + m_container = QWidget::createWindowContainer(m_widget, m_parent); + m_container->setMinimumSize(64, 64); + m_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + } + return m_container; } void loadConfiguration(IUAVGadgetConfiguration *config); private: + QWidget *m_container; + QWidget *m_parent; PfdQmlGadgetWidget *m_widget; }; diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp index f7d6b1f66..197f1929d 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetfactory.cpp @@ -31,7 +31,7 @@ PfdQmlGadgetFactory::~PfdQmlGadgetFactory() Core::IUAVGadget *PfdQmlGadgetFactory::createGadget(QWidget *parent) { - PfdQmlGadgetWidget *gadgetWidget = new PfdQmlGadgetWidget(parent); + PfdQmlGadgetWidget *gadgetWidget = new PfdQmlGadgetWidget(); return new PfdQmlGadget(QString("PfdQmlGadget"), gadgetWidget, parent); } diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index d0f599dd8..7f0262ad3 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -29,12 +29,11 @@ #include #include -#include -#include -#include +#include +#include -PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : - QDeclarativeView(parent), +PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWindow *parent) : + QQuickView(parent), m_openGLEnabled(false), m_terrainEnabled(false), m_actualPositionUsed(false), @@ -46,8 +45,6 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : m_altitudeUnit("m"), m_altitudeFactor(1.0) { - setMinimumSize(64, 64); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setResizeMode(SizeRootObjectToView); // setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); @@ -107,7 +104,7 @@ void PfdQmlGadgetWidget::setQmlFile(QString fn) qDebug() << Q_FUNC_INFO << fn; setSource(QUrl::fromLocalFile(fn)); - foreach(const QDeclarativeError &error, errors()) { + foreach(const QQmlError &error, errors()) { qDebug() << error.description(); } } @@ -165,19 +162,7 @@ void PfdQmlGadgetWidget::setAltitudeFactor(double factor) void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg) { - if (m_openGLEnabled != arg) { - m_openGLEnabled = arg; - - qDebug() << Q_FUNC_INFO << "Set OPENGL" << m_openGLEnabled; - if (m_openGLEnabled) { - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); - } else { - setViewport(new QWidget); - } - - // update terrainEnabled status with opengl status chaged setTerrainEnabled(m_terrainEnabled); - } } // Switch between PositionState UAVObject position @@ -197,7 +182,7 @@ void PfdQmlGadgetWidget::mouseReleaseEvent(QMouseEvent *event) setQmlFile(m_qmlFileName); } - QDeclarativeView::mouseReleaseEvent(event); + QQuickView::mouseReleaseEvent(event); } void PfdQmlGadgetWidget::setLatitude(double arg) diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h index 42b21edee..222fb8ce4 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h @@ -18,9 +18,9 @@ #define PFDQMLGADGETWIDGET_H_ #include "pfdqmlgadgetconfiguration.h" -#include +#include -class PfdQmlGadgetWidget : public QDeclarativeView { +class PfdQmlGadgetWidget : public QQuickView { Q_OBJECT Q_PROPERTY(QString earthFile READ earthFile WRITE setEarthFile NOTIFY earthFileChanged) Q_PROPERTY(bool terrainEnabled READ terrainEnabled WRITE setTerrainEnabled NOTIFY terrainEnabledChanged) @@ -37,7 +37,7 @@ class PfdQmlGadgetWidget : public QDeclarativeView { Q_PROPERTY(double altitude READ altitude WRITE setAltitude NOTIFY altitudeChanged) public: - PfdQmlGadgetWidget(QWidget *parent = 0); + PfdQmlGadgetWidget(QWindow *parent = 0); ~PfdQmlGadgetWidget(); void setQmlFile(QString fn);