Commit eb5edae8 authored by Marco Bubke's avatar Marco Bubke Committed by Tim Jenssen
Browse files

QmlDesigner: Using QQuickWidget in the Property Editor



Change-Id: Ib0bd01a2698e6d8483704de1f8a165696f25ec5e
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 7d436649
......@@ -34,73 +34,12 @@
#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) :
QWidget(parent)
QQuickWidget(parent)
{
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());
setResizeMode(QQuickWidget::SizeRootObjectToView);
}
void Quick2PropertyEditorView::registerQmlTypes()
......
......@@ -30,54 +30,19 @@
#ifndef QUICK2PROERTYEDITORVIEW_H
#define QUICK2PROERTYEDITORVIEW_H
#include <QWidget>
#include <QUrl>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
#include <QPointer>
#include <QQuickWidget>
QT_BEGIN_NAMESPACE
class QQmlError;
class QQmlComponent;
QT_END_NAMESPACE
namespace QmlDesigner {
class Quick2PropertyEditorView : public QWidget
class Quick2PropertyEditorView : public QQuickWidget
{
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment