summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2014-09-11 15:49:10 +0200
committerTim Jenssen <tim.jenssen@digia.com>2014-09-26 16:48:38 +0200
commit14022854d4b89743895078451f84ebd91b846dd3 (patch)
treeac9a24f2807512d6673214dd64aa0fba568243ed
parentd1dd7fe369eb9f5e69af7e420d390971b441af32 (diff)
downloadqt-creator-14022854d4b89743895078451f84ebd91b846dd3.tar.gz
QmlDesigner: Use QQuickWidget again
This is the revert of the reverts ;) Change-Id: I750dfffa6d509e058b97b605be5f2cc0a42c28f3 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp29
-rw-r--r--src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h4
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp62
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h39
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp51
-rw-r--r--src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h6
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.pro1
7 files changed, 46 insertions, 146 deletions
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
index d394cb3e81..c95fd7a30b 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.cpp
@@ -66,7 +66,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_itemIconSize(24, 24),
m_resIconSize(24, 24),
m_iconProvider(m_resIconSize),
- m_itemsView(new QQuickView()),
+ m_itemViewQuickWidget(new QQuickWidget),
m_resourcesView(new ItemLibraryTreeView(this)),
m_filterFlag(QtBasic)
{
@@ -75,16 +75,16 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
setWindowTitle(tr("Library", "Title of library view"));
/* create Items view and its model */
- m_itemsView->setResizeMode(QQuickView::SizeRootObjectToView);
+ m_itemViewQuickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_itemLibraryModel = new ItemLibraryModel(this);
- QQmlContext *rootContext = m_itemsView->rootContext();
+ QQmlContext *rootContext = m_itemViewQuickWidget->rootContext();
rootContext->setContextProperty(QStringLiteral("itemLibraryModel"), m_itemLibraryModel.data());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconWidth"), m_itemIconSize.width());
rootContext->setContextProperty(QStringLiteral("itemLibraryIconHeight"), m_itemIconSize.height());
rootContext->setContextProperty(QStringLiteral("rootView"), this);
- m_itemsView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
+ m_itemViewQuickWidget->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
/* create Resources view and its model */
m_resourcesFileSystemModel = new QFileSystemModel(this);
@@ -93,7 +93,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
m_resourcesView->setIconSize(m_resIconSize);
/* create image provider for loading item icons */
- m_itemsView->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);
+ m_itemViewQuickWidget->engine()->addImageProvider(QStringLiteral("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider);
/* other widgets */
QTabBar *tabBar = new QTabBar(this);
@@ -122,9 +122,9 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2);
connect(m_filterLineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString)));
- QWidget *container = createWindowContainer(m_itemsView.data());
+
m_stackedWidget = new QStackedWidget(this);
- m_stackedWidget->addWidget(container);
+ m_stackedWidget->addWidget(m_itemViewQuickWidget.data());
m_stackedWidget->addWidget(m_resourcesView.data());
QWidget *spacer = new QWidget(this);
@@ -228,7 +228,7 @@ void ItemLibraryWidget::setSearchFilter(const QString &searchFilter)
{
if (m_stackedWidget->currentIndex() == 0) {
m_itemLibraryModel->setSearchText(searchFilter);
- m_itemsView->update();
+ m_itemViewQuickWidget->update();
} else {
QStringList nameFilterList;
if (searchFilter.contains('.')) {
@@ -299,8 +299,8 @@ void ItemLibraryWidget::reloadQmlSource()
{
QString itemLibraryQmlFilePath = qmlSourcesPath() + QStringLiteral("/ItemsView.qml");
QTC_ASSERT(QFileInfo::exists(itemLibraryQmlFilePath), return);
- m_itemsView->engine()->clearComponentCache();
- m_itemsView->setSource(QUrl::fromLocalFile(itemLibraryQmlFilePath));
+ m_itemViewQuickWidget->engine()->clearComponentCache();
+ m_itemViewQuickWidget->setSource(QUrl::fromLocalFile(itemLibraryQmlFilePath));
}
void ItemLibraryWidget::setImportFilter(FilterChangeFlag flag)
@@ -373,10 +373,11 @@ void ItemLibraryWidget::setResourcePath(const QString &resourcePath)
updateSearch();
}
-static void ungrabMouseOnQMLWorldWorkAround(QQuickView *quickView)
+static void ungrabMouseOnQMLWorldWorkAround(QQuickWidget *quickWidget)
{
- if (quickView->mouseGrabberItem())
- quickView->mouseGrabberItem()->ungrabMouse();
+ const QQuickWidgetPrivate *widgetPrivate = QQuickWidgetPrivate::get(quickWidget);
+ if (widgetPrivate && widgetPrivate->offscreenWindow && widgetPrivate->offscreenWindow->mouseGrabberItem())
+ widgetPrivate->offscreenWindow->mouseGrabberItem()->ungrabMouse();
}
void ItemLibraryWidget::startDragAndDrop(QVariant itemLibraryId)
@@ -391,7 +392,7 @@ void ItemLibraryWidget::startDragAndDrop(QVariant itemLibraryId)
drag->exec();
- ungrabMouseOnQMLWorldWorkAround(m_itemsView.data());
+ ungrabMouseOnQMLWorldWorkAround(m_itemViewQuickWidget.data());
}
void ItemLibraryWidget::removeImport(const QString &name)
diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
index 24a585378b..4e96e8ff2a 100644
--- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
+++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarywidget.h
@@ -38,7 +38,7 @@
#include <QFrame>
#include <QToolButton>
#include <QFileIconProvider>
-#include <QQuickView>
+#include <QQuickWidget>
QT_BEGIN_NAMESPACE
class QFileSystemModel;
@@ -132,7 +132,7 @@ private:
QPointer<QStackedWidget> m_stackedWidget;
QPointer<Utils::FancyLineEdit> m_filterLineEdit;
- QScopedPointer<QQuickView> m_itemsView;
+ QScopedPointer<QQuickWidget> m_itemViewQuickWidget;
QScopedPointer<ItemLibraryTreeView> m_resourcesView;
QShortcut *m_qmlSourceUpdateShortcut;
diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
index 2b1251bd72..1d28219b1a 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.cpp
@@ -34,70 +34,12 @@
#include "gradientmodel.h"
#include "qmlanchorbindingproxy.h"
-#include <QVBoxLayout>
-
namespace QmlDesigner {
-void Quick2PropertyEditorView::execute()
-{
- m_view.setSource(m_source);
- if (!m_source.isEmpty())
- 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()
+ QQuickWidget(parent)
{
- 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()
diff --git a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h
index da99157725..0bc541bbf4 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/quick2propertyeditorview.h
@@ -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
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
index 9caa3b6454..0fc88003ef 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp
@@ -45,7 +45,6 @@
#include <QBoxLayout>
#include <QKeySequence>
-#include <QQuickView>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
@@ -58,15 +57,15 @@ namespace QmlDesigner {
int StatesEditorWidget::currentStateInternalId() const
{
- Q_ASSERT(m_quickView->rootObject());
- Q_ASSERT(m_quickView->rootObject()->property("currentStateInternalId").isValid());
+ Q_ASSERT(rootObject());
+ Q_ASSERT(rootObject()->property("currentStateInternalId").isValid());
- return m_quickView->rootObject()->property("currentStateInternalId").toInt();
+ return rootObject()->property("currentStateInternalId").toInt();
}
void StatesEditorWidget::setCurrentStateInternalId(int internalId)
{
- m_quickView->rootObject()->setProperty("currentStateInternalId", internalId);
+ rootObject()->setProperty("currentStateInternalId", internalId);
}
void StatesEditorWidget::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
@@ -76,12 +75,11 @@ void StatesEditorWidget::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
void StatesEditorWidget::showAddNewStatesButton(bool showAddNewStatesButton)
{
- m_quickView->rootContext()->setContextProperty("canAddNewStates", showAddNewStatesButton);
+ rootContext()->setContextProperty("canAddNewStates", showAddNewStatesButton);
}
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel)
- : QWidget(),
- m_quickView(new QQuickView()),
+ : QQuickWidget(),
m_statesEditorView(statesEditorView),
m_imageProvider(0),
m_qmlSourceUpdateShortcut(0)
@@ -89,25 +87,20 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
m_imageProvider = new Internal::StatesEditorImageProvider;
m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView());
- m_quickView->engine()->addImageProvider(QStringLiteral("qmldesigner_stateseditor"), m_imageProvider);
- m_quickView->engine()->addImportPath(qmlSourcesPath());
+ engine()->addImageProvider(QStringLiteral("qmldesigner_stateseditor"), m_imageProvider);
+ engine()->addImportPath(qmlSourcesPath());
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F4), this);
connect(m_qmlSourceUpdateShortcut, SIGNAL(activated()), this, SLOT(reloadQmlSource()));
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(0);
- layout->setSpacing(0);
- QWidget *container = createWindowContainer(m_quickView.data());
- layout->addWidget(container);
- m_quickView->setResizeMode(QQuickView::SizeRootObjectToView);
- container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ setResizeMode(QQuickWidget::SizeRootObjectToView);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- m_quickView->rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
- m_quickView->rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
+ rootContext()->setContextProperty(QStringLiteral("statesEditorModel"), statesEditorModel);
+ rootContext()->setContextProperty(QStringLiteral("highlightColor"), Utils::StyleHelper::notTooBrightHighlightColor());
- m_quickView->rootContext()->setContextProperty("canAddNewStates", true);
+ rootContext()->setContextProperty("canAddNewStates", true);
setWindowTitle(tr("States", "Title of Editor widget"));
@@ -127,21 +120,21 @@ void StatesEditorWidget::reloadQmlSource()
{
QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml");
QTC_ASSERT(QFileInfo::exists(statesListQmlFilePath), return);
- m_quickView->engine()->clearComponentCache();
- m_quickView->setSource(QUrl::fromLocalFile(statesListQmlFilePath));
+ engine()->clearComponentCache();
+ setSource(QUrl::fromLocalFile(statesListQmlFilePath));
- QTC_ASSERT(m_quickView->rootObject(), return);
- connect(m_quickView->rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget()));
- connect(m_quickView->rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
- connect(m_quickView->rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
+ QTC_ASSERT(rootObject(), return);
+ connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget()));
+ connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
+ connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
- setFixedHeight(m_quickView->initialSize().height());
+ setFixedHeight(initialSize().height());
- connect(m_quickView->rootObject(), SIGNAL(expandedChanged()), this, SLOT(changeHeight()));
+ connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(changeHeight()));
}
void StatesEditorWidget::changeHeight()
{
- setFixedHeight(m_quickView->rootObject()->height());
+ setFixedHeight(rootObject()->height());
}
}
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
index 8a7967a784..ea60fa016d 100644
--- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
+++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h
@@ -30,11 +30,10 @@
#ifndef STATESEDITORWIDGET_H
#define STATESEDITORWIDGET_H
-#include <QWidget>
+#include <QQuickWidget>
#include <QPointer>
QT_BEGIN_NAMESPACE
-class QQuickView;
class QShortcut;
QT_END_NAMESPACE
@@ -48,7 +47,7 @@ class NodeInstanceView;
namespace Internal { class StatesEditorImageProvider; }
-class StatesEditorWidget : public QWidget
+class StatesEditorWidget : public QQuickWidget
{
Q_OBJECT
@@ -69,7 +68,6 @@ private slots:
void changeHeight();
private:
- QPointer<QQuickView> m_quickView;
QPointer<StatesEditorView> m_statesEditorView;
Internal::StatesEditorImageProvider *m_imageProvider;
QShortcut *m_qmlSourceUpdateShortcut;
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.pro b/src/plugins/qmldesigner/qmldesignerplugin.pro
index 190a8d6582..2ff32107e5 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.pro
+++ b/src/plugins/qmldesigner/qmldesignerplugin.pro
@@ -1,3 +1,4 @@
+QT += quickwidgets
QT += widgets-private quick-private quickwidgets-private core-private gui-private #mouse ungrabbing workaround on quickitems
CONFIG += exceptions