diff options
author | Marco Bubke <marco.bubke@digia.com> | 2014-07-07 15:55:44 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@digia.com> | 2014-07-07 16:10:48 +0200 |
commit | 2e907e44f17b2393c09765fc3d305ff5e8b0e35c (patch) | |
tree | 6a4e025212b9081e76d2b14b28c3f84727a8d930 | |
parent | 2b96e1b96a20d959df65f5a5dc4cbbb3d1643f20 (diff) |
Revert "QmlDesigner: Using QQuickWidget in the Property Editor"
This reverts commit eb5edae8ebee02ce896aab47f44f53721e793c3e.
Because we get crashes with QQuickWidget
Change-Id: I63546f4c59e382019cb8524e32071dc9ad8fd171
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp | 65 | ||||
-rw-r--r-- | src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h | 39 |
2 files changed, 100 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp index 1d28219b1a..4aa9efbf5a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp @@ -34,12 +34,73 @@ #include "gradientmodel.h" #include "qmlanchorbindingproxy.h" +#include <QVBoxLayout> + namespace QmlDesigner { +void Quick2PropertyEditorView::execute() +{ + m_view.setSource(m_source); + + if (!m_source.isEmpty()) { + m_view.setSource(m_source); + connect(&m_view, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(continueExecute())); + } +} + Quick2PropertyEditorView::Quick2PropertyEditorView(QWidget *parent) : - QQuickWidget(parent) + QWidget(parent) { - setResizeMode(QQuickWidget::SizeRootObjectToView); + m_containerWidget = createWindowContainer(&m_view); + + QVBoxLayout *layout = new QVBoxLayout(this); + setLayout(layout); + layout->addWidget(m_containerWidget); + layout->setMargin(0); + m_view.setResizeMode(QQuickView::SizeRootObjectToView); +} + +QUrl Quick2PropertyEditorView::source() const +{ + return m_source; +} + +void Quick2PropertyEditorView::setSource(const QUrl& url) +{ + m_source = url; + execute(); +} + +QQmlEngine* Quick2PropertyEditorView::engine() +{ + return m_view.engine(); +} + +QQmlContext* Quick2PropertyEditorView::rootContext() +{ + return engine()->rootContext(); +} + +Quick2PropertyEditorView::Status Quick2PropertyEditorView::status() const +{ + return Quick2PropertyEditorView::Status(m_view.status()); +} + + +void Quick2PropertyEditorView::continueExecute() +{ + disconnect(&m_view, SIGNAL(statusChanged(QQuickView::Status)), this, SLOT(continueExecute())); + + if (!m_view.errors().isEmpty()) { + QList<QQmlError> errorList = m_view.errors(); + foreach (const QQmlError &error, errorList) { + qWarning() << error; + } + emit statusChanged(status()); + return; + } + + emit statusChanged(status()); } void Quick2PropertyEditorView::registerQmlTypes() diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h index 0bc541bbf4..da99157725 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h +++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h @@ -30,19 +30,54 @@ #ifndef QUICK2PROERTYEDITORVIEW_H #define QUICK2PROERTYEDITORVIEW_H -#include <QQuickWidget> +#include <QWidget> +#include <QUrl> +#include <QQuickView> +#include <QQmlEngine> +#include <QQmlContext> +#include <QPointer> +QT_BEGIN_NAMESPACE +class QQmlError; +class QQmlComponent; +QT_END_NAMESPACE namespace QmlDesigner { -class Quick2PropertyEditorView : public QQuickWidget +class Quick2PropertyEditorView : public QWidget { Q_OBJECT + Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) public: explicit Quick2PropertyEditorView(QWidget *parent = 0); + QUrl source() const; + void setSource(const QUrl&); + + QQmlEngine* engine(); + QQmlContext* rootContext(); + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + static void registerQmlTypes(); + +signals: + void statusChanged(Quick2PropertyEditorView::Status); + +protected: + void execute(); + +private Q_SLOTS: + void continueExecute(); + +private: + QWidget *m_containerWidget; + QUrl m_source; + QQuickView m_view; + QPointer<QQmlComponent> m_component; + }; } //QmlDesigner |