forked from qt-creator/qt-creator
Revert "QmlDesigner: Using QQuickWidget in the Property Editor"
This reverts commit eb5edae8eb.
Because we get crashes with QQuickWidget
Change-Id: I63546f4c59e382019cb8524e32071dc9ad8fd171
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
This commit is contained in:
@@ -34,12 +34,73 @@
|
|||||||
#include "gradientmodel.h"
|
#include "gradientmodel.h"
|
||||||
#include "qmlanchorbindingproxy.h"
|
#include "qmlanchorbindingproxy.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
Quick2PropertyEditorView::Quick2PropertyEditorView(QWidget *parent) :
|
void Quick2PropertyEditorView::execute()
|
||||||
QQuickWidget(parent)
|
|
||||||
{
|
{
|
||||||
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
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)
|
||||||
|
{
|
||||||
|
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()
|
void Quick2PropertyEditorView::registerQmlTypes()
|
||||||
|
|||||||
@@ -30,19 +30,54 @@
|
|||||||
#ifndef QUICK2PROERTYEDITORVIEW_H
|
#ifndef QUICK2PROERTYEDITORVIEW_H
|
||||||
#define 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 {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class Quick2PropertyEditorView : public QQuickWidget
|
class Quick2PropertyEditorView : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
|
||||||
public:
|
public:
|
||||||
explicit Quick2PropertyEditorView(QWidget *parent = 0);
|
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();
|
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
|
} //QmlDesigner
|
||||||
|
|||||||
Reference in New Issue
Block a user