Commit dce623b1 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: Porting to Qt Quick 2



This patch ports our Qt Quick views to Qt Quick 2.

Change-Id: Ie0cfd81e7ebb76d2ed667211ad063feaaff5aa14
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent cf56178d
......@@ -67,20 +67,13 @@ contains(QT_CONFIG, declarative)|!isEmpty(QT.declarative.name) {
qmlprojectmanager \
qmlprofiler
greaterThan(QT_MAJOR_VERSION, 4) {
greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 0) {
SUBDIRS += \
qmldesigner \
welcome
} else {
include(../private_headers.pri)
exists($${QT_PRIVATE_HEADERS}/QtDeclarative/private/qdeclarativecontext_p.h) {
SUBDIRS += \
qmldesigner
} else {
warning("QmlDesigner plugin has been disabled.")
warning("The plugin depends on private headers from QtDeclarative module.")
warning("To enable it, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.")
}
warning("QmlDesigner plugin has been disabled.")
warning("The plugin needs at least Qt 5.1.")
}
} else {
warning("QmlProjectManager, QmlProfiler and QmlDesigner plugins have been disabled: The plugins require QtDeclarative")
......
......@@ -3,7 +3,7 @@
<file>qml/ItemsView.qml</file>
<file>qml/ItemsViewStyle.qml</file>
<file>qml/SectionView.qml</file>
<file>qml/ItemView.qml</file>
<file>qml/SingleItemView.qml</file>
<file>qml/Scrollbar.qml</file>
<file>qml/Selector.qml</file>
......
......@@ -33,7 +33,7 @@ namespace QmlDesigner {
namespace Internal {
ItemLibraryImageProvider::ItemLibraryImageProvider() :
QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
QQuickImageProvider(QQuickImageProvider::Pixmap)
{
}
......
......@@ -30,13 +30,13 @@
#ifndef ITEMLIBRARYIMAGEPROVIDER_H
#define ITEMLIBRARYIMAGEPROVIDER_H
#include <QDeclarativeImageProvider>
#include <QQuickImageProvider>
namespace QmlDesigner {
namespace Internal {
class ItemLibraryImageProvider : public QDeclarativeImageProvider
class ItemLibraryImageProvider : public QQuickImageProvider
{
public:
ItemLibraryImageProvider();
......
......@@ -33,7 +33,7 @@
#include <QMap>
#include <QIcon>
#include <QAbstractListModel>
#include <QtDeclarative>
#include <QtQuick>
QT_FORWARD_DECLARE_CLASS(QMimeData)
......
......@@ -49,20 +49,16 @@
#include <QMenu>
#include <QApplication>
#include <QDeclarativeItem>
#include <QQuickItem>
namespace QmlDesigner {
ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
QFrame(parent),
m_iconProvider(m_resIconSize),
m_itemIconSize(24, 24),
m_resIconSize(24, 24),
m_itemsView(new QDeclarativeView(this)),
m_itemsView(new QQuickView()),
m_resourcesView(new Internal::ItemLibraryTreeView(this)),
m_filterFlag(QtBasic)
{
......@@ -71,15 +67,11 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
setWindowTitle(tr("Library", "Title of library view"));
/* create Items view and its model */
m_itemsView->setAttribute(Qt::WA_OpaquePaintEvent);
m_itemsView->setAttribute(Qt::WA_NoSystemBackground);
m_itemsView->setAcceptDrops(false);
m_itemsView->setFocusPolicy(Qt::ClickFocus);
m_itemsView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_itemsView->setResizeMode(QQuickView::SizeRootObjectToView);
m_itemLibraryModel = new Internal::ItemLibraryModel(this);
m_itemLibraryModel->setItemIconSize(m_itemIconSize);
QDeclarativeContext *rootContext = m_itemsView->rootContext();
QQmlContext *rootContext = m_itemsView->rootContext();
rootContext->setContextProperty(QLatin1String("itemLibraryModel"), m_itemLibraryModel.data());
rootContext->setContextProperty(QLatin1String("itemLibraryIconWidth"), m_itemIconSize.width());
rootContext->setContextProperty(QLatin1String("itemLibraryIconHeight"), m_itemIconSize.height());
......@@ -92,7 +84,7 @@ ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
// loading the qml has to come after all needed context properties are set
m_itemsView->setSource(QUrl("qrc:/ItemLibrary/qml/ItemsView.qml"));
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_itemsView->rootObject());
QQuickItem *rootItem = qobject_cast<QQuickItem*>(m_itemsView->rootObject());
connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int)));
connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int)));
connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant)));
......@@ -133,8 +125,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(m_itemsView.data());
m_stackedWidget->addWidget(container);
m_stackedWidget->addWidget(m_resourcesView.data());
QWidget *spacer = new QWidget(this);
......@@ -375,7 +368,7 @@ void ItemLibraryWidget::startDragAndDrop(int itemLibId)
drag->setPreview(QPixmap::fromImage(image));
drag->setMimeData(mimeData);
QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_itemsView->rootObject());
QQuickItem *rootItem = qobject_cast<QQuickItem*>(m_itemsView->rootObject());
connect(rootItem, SIGNAL(stopDragAndDrop()), drag, SLOT(stopDrag()));
drag->exec();
......@@ -386,16 +379,6 @@ void ItemLibraryWidget::showItemInfo(int /*itemLibId*/)
// qDebug() << "showing item info about id" << itemLibId;
}
void ItemLibraryWidget::wheelEvent(QWheelEvent *event)
{
if (m_stackedWidget->currentIndex() == 0 &&
m_itemsView->rect().contains(event->pos())) {
emit scrollItemsView(event->delta());
event->accept();
} else
QFrame::wheelEvent(event);
}
void ItemLibraryWidget::removeImport(const QString &name)
{
if (!m_model)
......
......@@ -38,7 +38,7 @@
#include <QFrame>
#include <QToolButton>
#include <QFileIconProvider>
#include <QDeclarativeView>
#include <QQuickView>
QT_BEGIN_NAMESPACE
class QFileSystemModel;
......@@ -105,7 +105,6 @@ public slots:
void onMeegoChecked(bool b);
protected:
void wheelEvent(QWheelEvent *event);
void removeImport(const QString &name);
void addImport(const QString &name, const QString &version);
void emitImportChecked();
......@@ -131,8 +130,9 @@ private:
QWeakPointer<QFileSystemModel> m_resourcesFileSystemModel;
QWeakPointer<QStackedWidget> m_stackedWidget;
QWeakPointer<Utils::FilterLineEdit> m_filterLineEdit;
QScopedPointer<QDeclarativeView> m_itemsView;
QScopedPointer<QQuickView> m_itemsView;
QScopedPointer<Internal::ItemLibraryTreeView> m_resourcesView;
QWeakPointer<Model> m_model;
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
/* The view displaying the item grid.
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// the style used the items view
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// scrollbar for the items view
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// view displaying one item library section including its grid
......@@ -98,7 +98,7 @@ Column {
Component {
id: itemDelegate
ItemView {
SingleItemView {
id: item
width: cellWidth
......
......@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// the coloured selector of the items view
......
......@@ -27,8 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// view displaying an item library grid item
Item {
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "basiclayouts.h"
QT_BEGIN_NAMESPACE
QBoxLayoutObject::QBoxLayoutObject(QObject *parent)
: QLayoutObject(parent), _layout(0)
{
}
QBoxLayoutObject::QBoxLayoutObject(QBoxLayout *layout, QObject *parent)
: QLayoutObject(parent), _layout(layout)
{
}
QLayout *QBoxLayoutObject::layout() const
{
return _layout;
}
void QBoxLayoutObject::addWidget(QWidget *wid)
{
_layout->addWidget(wid);
}
void QBoxLayoutObject::clearWidget()
{
}
QHBoxLayoutObject::QHBoxLayoutObject(QObject *parent)
: QBoxLayoutObject(new QHBoxLayout, parent)
{
}
QVBoxLayoutObject::QVBoxLayoutObject(QObject *parent)
: QBoxLayoutObject(new QVBoxLayout, parent)
{
}
QT_END_NAMESPACE
void BasicLayouts::registerDeclarativeTypes()
{
qmlRegisterType<QBoxLayoutObject>("Bauhaus",1,0,"QBoxLayout");
qmlRegisterType<QHBoxLayoutObject>("Bauhaus",1,0,"QHBoxLayout");
qmlRegisterType<QVBoxLayoutObject>("Bauhaus",1,0,"QVBoxLayout");
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BASICLAYOUTS_H
#define BASICLAYOUTS_H
#include <qlayoutobject.h>
QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QBoxLayoutObject : public QLayoutObject
{
Q_OBJECT
Q_PROPERTY(QDeclarativeListProperty<QWidget> children READ children)
Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin)
Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
Q_CLASSINFO("DefaultProperty", "children")
public:
QBoxLayoutObject(QObject *parent=0);
explicit QBoxLayoutObject(QBoxLayout *, QObject *parent=0);
virtual QLayout *layout() const;
QDeclarativeListProperty<QWidget> children() {
return QDeclarativeListProperty<QWidget>(this, 0, children_append, 0, 0, children_clear);
}
private:
friend class WidgetList;
void addWidget(QWidget *);
void clearWidget();
static void children_append(QDeclarativeListProperty<QWidget> *property, QWidget *widget) {
static_cast<QBoxLayoutObject*>(property->object)->addWidget(widget);
}
static void children_clear(QDeclarativeListProperty<QWidget> *property) {
static_cast<QBoxLayoutObject*>(property->object)->clearWidget();
}
void getMargins()
{
_layout->getContentsMargins(&mLeft, &mTop, &mRight, &mBottom);
}
void setMargins()
{
_layout->setContentsMargins(mLeft, mTop, mRight, mBottom);
}
int topMargin()
{
getMargins();
return mTop;
}
void setTopMargin(int margin)
{
getMargins();
mTop = margin;
setMargins();
}
int bottomMargin()
{
getMargins();
return mBottom;
}
void setBottomMargin(int margin)
{
getMargins();
mBottom = margin;
setMargins();
}
int leftMargin()
{
getMargins();
return mLeft;
}
void setLeftMargin(int margin)
{
getMargins();
mLeft = margin;
setMargins();
}
int rightMargin()
{
getMargins();
return mRight;
}
void setRightMargin(int margin)
{
getMargins();
mRight = margin;
setMargins();
}
int spacing() const
{
return _layout->spacing();
}
void setSpacing(int spacing)
{
_layout->setSpacing(spacing);
}
QBoxLayout *_layout;
int mTop, mLeft, mBottom, mRight;
};
class QHBoxLayoutObject : public QBoxLayoutObject
{
Q_OBJECT
public:
QHBoxLayoutObject(QObject *parent=0);
};
class QVBoxLayoutObject : public QBoxLayoutObject
{
Q_OBJECT
public:
QVBoxLayoutObject(QObject *parent=0);
};
QT_END_NAMESPACE
QML_DECLARE_TYPE(QBoxLayoutObject)
QML_DECLARE_TYPE(QHBoxLayoutObject)
QML_DECLARE_TYPE(QVBoxLayoutObject)
class BasicLayouts {
public:
static void registerDeclarativeTypes();
};
#endif // BASICLAYOUTS_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BASICWIDGETS_H
#define BASICWIDGETS_H
#include <qdeclarative.h>
#include <QGraphicsView>
#include <QLabel>
#include <QPushButton>
#include <QToolButton>
#include <QCheckBox>
#include <QRadioButton>
#include <QLineEdit>
#include <QTextEdit>
#include <QPlainTextEdit>
#include <QDoubleSpinBox>
#include <QSlider>
#include <QDateEdit>
#include <QTimeEdit>
#include <QProgressBar>
#include <QGroupBox>
#include <QDial>
#include <QLCDNumber>
#include <QFontComboBox>
#include <QScrollBar>
#include <QCalendarWidget>
#include <QTabWidget>
#include <QMenu>
#include <QAction>
#include "filewidget.h"
#include "layoutwidget.h"
QML_DECLARE_TYPE(QWidget)
//display
QML_DECLARE_TYPE(QLabel)
QML_DECLARE_TYPE(QProgressBar)
QML_DECLARE_TYPE(QLCDNumber)
//input
QML_DECLARE_TYPE(QLineEdit)
QML_DECLARE_TYPE(QTextEdit)
QML_DECLARE_TYPE(QPlainTextEdit)
QML_DECLARE_TYPE(QSpinBox)
QML_DECLARE_TYPE(QDoubleSpinBox)
QML_DECLARE_TYPE(QSlider)
QML_DECLARE_TYPE(QDateTimeEdit)
QML_DECLARE_TYPE(QDateEdit)
QML_DECLARE_TYPE(QTimeEdit)
QML_DECLARE_TYPE(QFontComboBox)
QML_DECLARE_TYPE(QDial)