QmlDesigner: Porting to Qt Quick 2

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

Change-Id: Ie0cfd81e7ebb76d2ed667211ad063feaaff5aa14
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Thomas Hartmann
2013-09-13 17:06:10 +02:00
parent cf56178df1
commit dce623b1bf
44 changed files with 223 additions and 3363 deletions

View File

@@ -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")

View File

@@ -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>

View File

@@ -33,7 +33,7 @@ namespace QmlDesigner {
namespace Internal {
ItemLibraryImageProvider::ItemLibraryImageProvider() :
QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
QQuickImageProvider(QQuickImageProvider::Pixmap)
{
}

View File

@@ -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();

View File

@@ -33,7 +33,7 @@
#include <QMap>
#include <QIcon>
#include <QAbstractListModel>
#include <QtDeclarative>
#include <QtQuick>
QT_FORWARD_DECLARE_CLASS(QMimeData)

View File

@@ -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)

View File

@@ -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;

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
/* The view displaying the item grid.

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// the style used the items view

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// scrollbar for the items view

View File

@@ -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

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// the coloured selector of the items view

View File

@@ -27,8 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
// view displaying an item library grid item
Item {

View File

@@ -1,78 +0,0 @@
/****************************************************************************
**
** 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");
}

View File

@@ -1,177 +0,0 @@
/****************************************************************************
**
** 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

View File

@@ -1,120 +0,0 @@
/****************************************************************************
**
** 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)
QML_DECLARE_TYPE(QScrollBar)
QML_DECLARE_TYPE(QCalendarWidget)
QML_DECLARE_TYPE(QComboBox)
//buttons
QML_DECLARE_TYPE(QPushButton)
QML_DECLARE_TYPE(QToolButton)
QML_DECLARE_TYPE(QCheckBox)
QML_DECLARE_TYPE(QRadioButton)
//containers
QML_DECLARE_TYPE(QGroupBox)
QML_DECLARE_TYPE(QFrame)
QML_DECLARE_TYPE(QScrollArea)
QML_DECLARE_TYPE(QTabWidget)
QML_DECLARE_TYPE(FileWidget)
QML_DECLARE_TYPE(LayoutWidget)
class Action : public QAction {
Q_OBJECT
public:
Action(QObject *parent = 0) : QAction(parent) {}
};
QML_DECLARE_TYPE(QMenu)
QML_DECLARE_TYPE(Action)
//QML_DECLARE_TYPE(QToolBox)
//itemviews
//QML_DECLARE_TYPE(QListView)
//QML_DECLARE_TYPE(QTreeView)
//QML_DECLARE_TYPE(QTableView)
//top-level windows?
class BasicWidgets {
public:
static void registerDeclarativeTypes();
};
#endif // BASICWIDGETS_H

View File

@@ -1,165 +0,0 @@
/****************************************************************************
**
** 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 "behaviordialog.h"
#include <abstractview.h>
#include <nodeproperty.h>
#include <variantproperty.h>
#include <bindingproperty.h>
namespace QmlDesigner {
void BehaviorDialog::registerDeclarativeType()
{
qmlRegisterType<QmlDesigner::BehaviorWidget>("Bauhaus",1,0,"BehaviorWidget");
}
BehaviorWidget::BehaviorWidget(QWidget *parent) : QPushButton(parent), m_BehaviorDialog(new BehaviorDialog)
{
setCheckable(true);
connect(this, SIGNAL(toggled(bool)), this, SLOT(buttonPressed(bool)));
}
PropertyEditorNodeWrapper* BehaviorWidget::complexNode() const
{
return m_complexNode;
}
void BehaviorWidget::setComplexNode(PropertyEditorNodeWrapper* complexNode)
{
m_complexNode = complexNode;
m_propertyName = complexNode->propertyName();
m_modelNode = complexNode->parentModelNode();
if (!modelNode().isValid())
m_BehaviorDialog->hide();
m_BehaviorDialog->setup(modelNode(), propertyName());
}
void BehaviorWidget::buttonPressed(bool show)
{
if (show) {
if (m_BehaviorDialog->isVisible()) {
m_BehaviorDialog->reject();
} else {
m_BehaviorDialog->setup(modelNode(), propertyName());
m_BehaviorDialog->show();
setChecked(false);
}
}
}
BehaviorDialog::BehaviorDialog(QWidget *parent) : QDialog(parent), m_ui(new Internal::Ui::BehaviorDialog)
{
m_ui->setupUi(this);
setModal(true);
}
void BehaviorDialog::setup(const ModelNode &node, const PropertyName propertyName)
{
m_modelNode = node;
m_ui->duration->setValue(100);
m_ui->velocity->setValue(2);
m_ui->spring->setValue(2);
m_ui->damping->setValue(2);
m_ui->stackedWidget->setCurrentIndex(0);
m_ui->curve->setCurrentIndex(0);
if (m_modelNode.isValid()) {
m_propertyName = propertyName;
m_ui->id->setText(m_modelNode.id());
m_ui->type->setText(m_modelNode.simplifiedTypeName());
m_ui->propertyName->setText(propertyName);
if (m_modelNode.hasProperty(m_propertyName) && m_modelNode.property(m_propertyName).isNodeProperty()) {
NodeProperty nodeProperty(m_modelNode.nodeProperty(m_propertyName));
if (nodeProperty.modelNode().type() == "Qt/SpringFollow") {
ModelNode springFollow = nodeProperty.modelNode();
m_ui->curve->setCurrentIndex(1);
m_ui->stackedWidget->setCurrentIndex(1);
if (springFollow.hasProperty("velocity") && springFollow.property("velocity").isVariantProperty())
m_ui->velocity->setValue(springFollow.variantProperty("velocity").value().toDouble());
if (springFollow.hasProperty("spring") && springFollow.property("spring").isVariantProperty())
m_ui->spring->setValue(springFollow.variantProperty("spring").value().toDouble());
if (springFollow.hasProperty("damping") && springFollow.property("damping").isVariantProperty())
m_ui->damping->setValue(springFollow.variantProperty("damping").value().toDouble());
if (springFollow.hasProperty("source") && springFollow.property("source").isVariantProperty())
m_ui->source->setText(springFollow.variantProperty("source").value().toString());
} else if (nodeProperty.modelNode().type() == "Qt/Behavior") {
if (nodeProperty.modelNode().hasProperty("animation") &&
nodeProperty.modelNode().property("animation").isNodeProperty() &&
nodeProperty.modelNode().nodeProperty("animation").modelNode().type() == "Qt/NumberAnimation") {
m_ui->curve->setCurrentIndex(0);
ModelNode animation = nodeProperty.modelNode().nodeProperty("animation").modelNode();
if (animation.hasProperty("duration") && animation.property("duration").isVariantProperty())
m_ui->duration->setValue(animation.variantProperty("duration").value().toInt());
if (animation.hasProperty("easing") && animation.property("easing").isVariantProperty()) {
QStringList easingItems;
for (int i = 0; i < m_ui->curve->count(); i++)
easingItems.append(m_ui->curve->itemText(i));
m_ui->curve->setCurrentIndex(easingItems.indexOf(animation.variantProperty("easing").value().toString()));
}
}
}
}
}
}
void BehaviorDialog::accept()
{
QDialog::accept();
if (m_modelNode.hasProperty(m_propertyName))
m_modelNode.removeProperty(m_propertyName);
if (m_ui->comboBox->currentIndex() == 0) {
RewriterTransaction transaction(m_modelNode.view()->beginRewriterTransaction());
ModelNode Behavior = m_modelNode.view()->createModelNode("Qt/Behavior", 4, 7);
m_modelNode.nodeProperty(m_propertyName).reparentHere(Behavior);
ModelNode animation = m_modelNode.view()->createModelNode("Qt/NumberAnimation", 4, 7);
animation.variantProperty("duration").setValue(m_ui->duration->value());
animation.variantProperty("easing").setValue(m_ui->curve->currentText());
Behavior.nodeProperty("animation").reparentHere(animation);
} else {
RewriterTransaction transaction(m_modelNode.view()->beginRewriterTransaction());
ModelNode springFollow = m_modelNode.view()->createModelNode("Qt/SpringFollow", 4, 7);
m_modelNode.nodeProperty(m_propertyName).reparentHere(springFollow);
springFollow.variantProperty("velocity").setValue(m_ui->velocity->value());
springFollow.variantProperty("spring").setValue(m_ui->spring->value());
springFollow.variantProperty("damping").setValue(m_ui->damping->value());
springFollow.bindingProperty("source").setExpression(m_ui->source->text());
}
}
void BehaviorDialog::reject()
{
QDialog::reject();
}
}

View File

@@ -1,95 +0,0 @@
/****************************************************************************
**
** 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 BEHAVIORDIALOG_H
#define BEHAVIORDIALOG_H
#include <modelnode.h>
#include <propertyeditorvalue.h>
#include <QPushButton>
#include <QDialog>
#include <QScopedPointer>
#include "ui_behaviordialog.h"
namespace QmlDesigner {
class BehaviorDialog;
class BehaviorWidget : public QPushButton
{
Q_PROPERTY(PropertyEditorNodeWrapper* complexNode READ complexNode WRITE setComplexNode)
Q_OBJECT
public:
explicit BehaviorWidget(QWidget *parent = 0);
ModelNode modelNode() const {return m_modelNode; }
PropertyName propertyName() const {return m_propertyName; }
PropertyEditorNodeWrapper* complexNode() const;
void setComplexNode(PropertyEditorNodeWrapper* complexNode);
public slots:
void buttonPressed(bool);
private:
ModelNode m_modelNode;
PropertyName m_propertyName;
PropertyEditorNodeWrapper* m_complexNode;
QScopedPointer<BehaviorDialog> m_BehaviorDialog;
};
class BehaviorDialog : public QDialog
{
Q_OBJECT
public:
explicit BehaviorDialog(QWidget *parent = 0);
void setup(const ModelNode &node, const PropertyName propertyName);
public slots:
virtual void accept();
virtual void reject();
static void registerDeclarativeType();
private:
ModelNode m_modelNode;
PropertyName m_propertyName;
QScopedPointer<Internal::Ui::BehaviorDialog> m_ui;
};
}
QML_DECLARE_TYPE(QmlDesigner::BehaviorWidget)
#endif// BEHAVIORDIALOG_H

View File

@@ -1,472 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QmlDesigner::Internal::BehaviorDialog</class>
<widget class="QDialog" name="QmlDesigner::Internal::BehaviorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>269</width>
<height>354</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">QDialog {
qlineargradient(spread:pad, x1:0.585, y1:0.0284091, x2:0.517, y2:1, stop:0 rgba(85, 85, 85, 255), stop:1 rgba(173, 173, 173, 255))
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="type">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>ID:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="id">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Property name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="propertyName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>Animation</string>
</property>
</item>
<item>
<property name="text">
<string>SpringFollow</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<property name="title">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Duration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="duration">
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Curve:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="curve">
<item>
<property name="text">
<string>easeNone</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInQuad</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutQuad</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutQuad</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInQuad</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInCubic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutCubic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutCubic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInCubic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInBounce</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutBounce</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutBounce</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInBounce</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInBack</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutBack</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutBack</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInBack</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInElastic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutElastic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutElastic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInElastic</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInCirc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutCirc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutCirc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInCirc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInExpo</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutExpo</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutExpo</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInExpo</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutInSine</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInOutSine</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeOutSine</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">easeInSine</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Source:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="source"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Velocity:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="velocity"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Spring:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="spring"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_11">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Damping:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="damping"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QDialogButtonBox" name="ButtonGroup">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>ButtonGroup</sender>
<signal>accepted()</signal>
<receiver>QmlDesigner::Internal::BehaviorDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>ButtonGroup</sender>
<signal>rejected()</signal>
<receiver>QmlDesigner::Internal::BehaviorDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>comboBox</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>106</y>
</hint>
<hint type="destinationlabel">
<x>121</x>
<y>191</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -30,13 +30,13 @@
#ifndef DESIGNERPROPERTYMAP_H
#define DESIGNERPROPERTYMAP_H
#include <QDeclarativePropertyMap>
#include <qdeclarative.h>
#include <QQmlPropertyMap>
#include <QtQml>
namespace QmlDesigner {
template <class DefaultType>
class DesignerPropertyMap : public QDeclarativePropertyMap
class DesignerPropertyMap : public QQmlPropertyMap
{
public:
@@ -50,7 +50,7 @@ private:
};
template <class DefaultType>
DesignerPropertyMap<DefaultType>::DesignerPropertyMap(QObject *parent) : QDeclarativePropertyMap(parent), m_defaultValue(this)
DesignerPropertyMap<DefaultType>::DesignerPropertyMap(QObject *parent) : QQmlPropertyMap(parent), m_defaultValue(this)
{
}
@@ -58,7 +58,7 @@ template <class DefaultType>
QVariant DesignerPropertyMap<DefaultType>::value(const QString &key) const
{
if (contains(key))
return QDeclarativePropertyMap::value(key);
return QQmlPropertyMap::value(key);
return QVariant(&m_defaultValue);
}

View File

@@ -1,106 +0,0 @@
/****************************************************************************
**
** 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 "layoutwidget.h"
#include <QGridLayout>
#include <QFile>
#include <QDebug>
QT_BEGIN_NAMESPACE
LayoutWidget::LayoutWidget(QWidget *parent) : QFrame(parent)
{
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QGridLayout *grid = new QGridLayout(this);
setLayout(grid);
grid->setContentsMargins(0,0,0,0);
grid->setSpacing(4);
m_topButton = new QPushButton(this);
m_topButton->setCheckable(true);
m_topButton->setSizePolicy(policy);
grid->addWidget(m_topButton, 0, 2, 2, 1, Qt::AlignHCenter);
m_bottomButton = new QPushButton(this);
m_bottomButton->setCheckable(true);
m_bottomButton->setSizePolicy(policy);
grid->addWidget(m_bottomButton, 3, 2, 2, 1, Qt::AlignHCenter);
m_leftButton = new QPushButton(this);
m_leftButton->setCheckable(true);
m_leftButton->setSizePolicy(policy);
grid->addWidget(m_leftButton, 2, 0, 1, 2, Qt::AlignVCenter);
m_rightButton = new QPushButton(this);
m_rightButton->setCheckable(true);
m_rightButton->setSizePolicy(policy);
grid->addWidget(m_rightButton, 2, 3, 1, 2, Qt::AlignVCenter);
m_middleButton = new QPushButton(this);
grid->addWidget(m_middleButton, 2, 2, 1, 1, Qt::AlignCenter);
connect(m_topButton, SIGNAL(toggled(bool)), this, SLOT(setTopAnchor(bool)));
connect(m_bottomButton, SIGNAL(toggled(bool)), this, SLOT(setBottomAnchor(bool)));
connect(m_leftButton, SIGNAL(toggled(bool)), this, SLOT(setLeftAnchor(bool)));
connect(m_rightButton, SIGNAL(toggled(bool)), this, SLOT(setRightAnchor(bool)));
connect(m_middleButton, SIGNAL(pressed()), this, SIGNAL(fill()));
}
LayoutWidget::~LayoutWidget()
{
}
void LayoutWidget::setIcon(QPushButton *button, QUrl url)
{
if (url.scheme() == QLatin1String("file")) {
QFile file(url.toLocalFile());
if (file.open(QIODevice::ReadOnly)) {
QPixmap pixmap(url.toLocalFile());
button->setIcon(pixmap);
} else {
qWarning() << QString::fromUtf8("setIconFromFile: %1: %2").arg(
file.fileName(), file.errorString());
}
}
}
QT_END_NAMESPACE

View File

@@ -1,136 +0,0 @@
/****************************************************************************
**
** 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 LAYOUTWIDGET_H
#define LAYOUTWIDGET_H
#include <QFrame>
#include <QPushButton>
#include <QUrl>
QT_BEGIN_NAMESPACE
class LayoutWidget : public QFrame
{
Q_OBJECT
Q_PROPERTY(bool leftAnchor READ leftAnchor WRITE setLeftAnchor NOTIFY leftAnchorChanged)
Q_PROPERTY(bool rightAnchor READ rightAnchor WRITE setRightAnchor NOTIFY rightAnchorChanged)
Q_PROPERTY(bool bottomAnchor READ bottomAnchor WRITE setBottomAnchor NOTIFY bottomAnchorChanged)
Q_PROPERTY(bool topAnchor READ topAnchor WRITE setTopAnchor NOTIFY topAnchorChanged)
Q_PROPERTY(QUrl leftButtonIcon READ icon WRITE setLeftButtonIcon)
Q_PROPERTY(QUrl rightButtonIcon READ icon WRITE setRightButtonIcon)
Q_PROPERTY(QUrl topButtonIcon READ icon WRITE setTopButtonIcon)
Q_PROPERTY(QUrl bottomButtonIcon READ icon WRITE setBottomButtonIcon)
public:
void setLeftButtonIcon(const QUrl &url)
{ setIcon(m_leftButton, url); }
void setRightButtonIcon(const QUrl &url)
{ setIcon(m_rightButton, url); }
void setTopButtonIcon(const QUrl &url)
{ setIcon(m_topButton, url); }
void setBottomButtonIcon(const QUrl &url)
{ setIcon(m_bottomButton, url); }
QUrl icon() const {return QUrl(); }
LayoutWidget(QWidget *parent = 0);
~LayoutWidget();
bool leftAnchor() const { return m_leftAnchor; }
bool rightAnchor() const { return m_rightAnchor; }
bool topAnchor() const { return m_topAnchor; }
bool bottomAnchor() const { return m_bottomAnchor; }
public slots:
void setLeftAnchor(bool anchor)
{
if (anchor == m_leftAnchor)
return;
m_leftAnchor = anchor;
m_leftButton->setChecked(anchor);
emit leftAnchorChanged();
}
void setRightAnchor(bool anchor)
{
if (anchor == m_rightAnchor)
return;
m_rightAnchor = anchor;
m_rightButton->setChecked(anchor);
emit rightAnchorChanged();
}
void setTopAnchor(bool anchor)
{
if (anchor == m_topAnchor)
return;
m_topAnchor = anchor;
m_topButton->setChecked(anchor);
emit topAnchorChanged();
}
void setBottomAnchor(bool anchor)
{
if (anchor == m_bottomAnchor)
return;
m_bottomAnchor = anchor;
m_bottomButton->setChecked(anchor);
emit bottomAnchorChanged();
}
signals:
//void colorChanged(const QColor &color);
void fill();
void topAnchorChanged();
void bottomAnchorChanged();
void leftAnchorChanged();
void rightAnchorChanged();
private:
void setIcon(QPushButton *button, QUrl url);
bool m_leftAnchor, m_rightAnchor, m_topAnchor, m_bottomAnchor;
QPushButton *m_leftButton;
QPushButton *m_rightButton;
QPushButton *m_topButton;
QPushButton *m_bottomButton;
QPushButton *m_middleButton;
};
QT_END_NAMESPACE
#endif

View File

@@ -2,12 +2,6 @@ VPATH += $$PWD
SOURCES += propertyeditorview.cpp \
qmlanchorbindingproxy.cpp \
resetwidget.cpp \
qlayoutobject.cpp \
basiclayouts.cpp \
basicwidgets.cpp \
behaviordialog.cpp \
layoutwidget.cpp \
filewidget.cpp \
propertyeditorvalue.cpp \
fontwidget.cpp \
@@ -15,19 +9,13 @@ SOURCES += propertyeditorview.cpp \
siblingcombobox.cpp \
propertyeditortransaction.cpp \
propertyeditorcontextobject.cpp \
quickpropertyeditorview.cpp \
quick2propertyeditorview.cpp \
gradientlineqmladaptor.cpp \
propertyeditorqmlbackend.cpp \
propertyeditorwidget.cpp
HEADERS += propertyeditorview.h \
qmlanchorbindingproxy.h \
resetwidget.h \
qlayoutobject.h \
basiclayouts.h \
basicwidgets.h \
behaviordialog.h \
layoutwidget.h \
filewidget.h \
propertyeditorvalue.h \
fontwidget.h \
@@ -36,12 +24,11 @@ HEADERS += propertyeditorview.h \
propertyeditortransaction.h \
designerpropertymap.h \
propertyeditorcontextobject.h \
quickpropertyeditorview.h \
quick2propertyeditorview.h \
gradientlineqmladaptor.h \
propertyeditorqmlbackend.h \
propertyeditorwidget.h
QT += declarative
QT += qml quick
RESOURCES += propertyeditor.qrc
FORMS += behaviordialog.ui

View File

@@ -42,7 +42,6 @@ PropertyEditorContextObject::PropertyEditorContextObject(QObject *parent) :
}
int PropertyEditorContextObject::majorVersion() const
{
return m_majorVersion;

View File

@@ -32,7 +32,7 @@
#include <QObject>
#include <QUrl>
#include <QDeclarativePropertyMap>
#include <QQmlPropertyMap>
#include <QColor>
namespace QmlDesigner {
@@ -53,7 +53,7 @@ class PropertyEditorContextObject : public QObject
Q_PROPERTY(int majorVersion READ majorVersion WRITE setMajorVersion NOTIFY majorVersionChanged)
Q_PROPERTY(int minorVersion READ minorVersion WRITE setMinorVersion NOTIFY minorVersionChanged)
Q_PROPERTY(QDeclarativePropertyMap* backendValues READ backendValues WRITE setBackendValues NOTIFY backendValuesChanged)
Q_PROPERTY(QQmlPropertyMap* backendValues READ backendValues WRITE setBackendValues NOTIFY backendValuesChanged)
public:
PropertyEditorContextObject(QObject *parent = 0);
@@ -66,7 +66,7 @@ public:
bool isBaseState() const { return m_isBaseState; }
bool selectionChanged() const { return m_selectionChanged; }
QDeclarativePropertyMap* backendValues() const { return m_backendValues; }
QQmlPropertyMap* backendValues() const { return m_backendValues; }
Q_INVOKABLE QString convertColorToString(const QColor &color) { return color.name(); }
@@ -141,7 +141,7 @@ public slots:
emit selectionChangedChanged();
}
void setBackendValues(QDeclarativePropertyMap* newBackendValues)
void setBackendValues(QQmlPropertyMap* newBackendValues)
{
if (newBackendValues == m_backendValues)
return;
@@ -165,7 +165,7 @@ private:
bool m_isBaseState;
bool m_selectionChanged;
QDeclarativePropertyMap* m_backendValues;
QQmlPropertyMap* m_backendValues;
int m_majorVersion;
int m_minorVersion;

View File

@@ -52,7 +52,8 @@ enum {
debug = false
};
const char resourcePropertyEditorPath[] = ":/propertyeditor";
const char propertyEditorPath[] = "/propertyEditorQmlSources";
const char resourcePropertyEditorPath[] = ":/propertyEditorQmlSources";
static QmlJS::SimpleReaderNode::Ptr s_templateConfiguration = QmlJS::SimpleReaderNode::Ptr();
@@ -118,7 +119,7 @@ static inline QString sharedDirPath()
namespace QmlDesigner {
PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyEditor) :
m_view(new QuickPropertyEditorView), m_propertyEditorTransaction(new PropertyEditorTransaction(propertyEditor)), m_dummyPropertyEditorValue(new PropertyEditorValue()),
m_view(new Quick2PropertyEditorView), m_propertyEditorTransaction(new PropertyEditorTransaction(propertyEditor)), m_dummyPropertyEditorValue(new PropertyEditorValue()),
m_contextObject(new PropertyEditorContextObject())
{
Q_ASSERT(QFileInfo(":/images/button_normal.png").exists());
@@ -203,7 +204,7 @@ void PropertyEditorQmlBackend::setValue(const QmlObjectNode & qmlObjectNode, con
}
QDeclarativeContext *PropertyEditorQmlBackend::context() {
QQmlContext *PropertyEditorQmlBackend::context() {
return m_view->rootContext();
}
@@ -338,7 +339,7 @@ void PropertyEditorQmlBackend::initialSetup(const TypeName &typeName, const QUrl
}
QString PropertyEditorQmlBackend::propertyEditorResourcesPath() {
return sharedDirPath() + QLatin1String("/propertyeditor");
return sharedDirPath() + QLatin1String(propertyEditorPath);
}
QString PropertyEditorQmlBackend::templateGeneration(NodeMetaInfo type,

View File

@@ -34,7 +34,7 @@
#include "designerpropertymap.h"
#include "propertyeditorvalue.h"
#include "propertyeditorcontextobject.h"
#include "quickpropertyeditorview.h"
#include "quick2propertyeditorview.h"
#include <nodemetainfo.h>
@@ -54,7 +54,7 @@ public:
void initialSetup(const TypeName &typeName, const QUrl &qmlSpecificsFile, PropertyEditorView *propertyEditor);
void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value);
QDeclarativeContext *context();
QQmlContext *context();
PropertyEditorContextObject* contextObject();
QWidget *widget();
void setSource(const QUrl& url);
@@ -86,7 +86,7 @@ private:
static QString fixTypeNameForPanes(const QString &typeName);
private:
QuickPropertyEditorView *m_view;
Quick2PropertyEditorView *m_view;
Internal::QmlAnchorBindingProxy m_backendAnchorBinding;
DesignerPropertyMap<PropertyEditorValue> m_backendValuesPropertyMap;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;

View File

@@ -266,7 +266,7 @@ void PropertyEditorValue::registerDeclarativeTypes()
{
qmlRegisterType<PropertyEditorValue>("Bauhaus",1,0,"PropertyEditorValue");
qmlRegisterType<PropertyEditorNodeWrapper>("Bauhaus",1,0,"PropertyEditorNodeWrapper");
qmlRegisterType<QDeclarativePropertyMap>("Bauhaus",1,0,"QDeclarativePropertyMap");
qmlRegisterType<QQmlPropertyMap>("Bauhaus",1,0,"QQmlPropertyMap");
}
PropertyEditorNodeWrapper::PropertyEditorNodeWrapper(PropertyEditorValue* parent) : QObject(parent), m_valuesPropertyMap(this)
@@ -306,7 +306,7 @@ QmlDesigner::PropertyName PropertyEditorNodeWrapper::propertyName() const
return m_editorValue->name();
}
QDeclarativePropertyMap* PropertyEditorNodeWrapper::properties()
QQmlPropertyMap *PropertyEditorNodeWrapper::properties()
{
return &m_valuesPropertyMap;
}

View File

@@ -33,8 +33,8 @@
#include <qmldesignercorelib_global.h>
#include <QObject>
#include <QDeclarativePropertyMap>
#include <qdeclarative.h>
#include <QQmlPropertyMap>
#include <QtQml>
#include <modelnode.h>
class PropertyEditorValue;
@@ -43,7 +43,7 @@ class PropertyEditorNodeWrapper : public QObject {
Q_OBJECT
Q_PROPERTY(bool exists READ exists NOTIFY existsChanged)
Q_PROPERTY(QDeclarativePropertyMap* properties READ properties NOTIFY propertiesChanged)
Q_PROPERTY(QQmlPropertyMap* properties READ properties NOTIFY propertiesChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
public:
@@ -51,7 +51,7 @@ public:
PropertyEditorNodeWrapper(PropertyEditorValue* parent);
bool exists();
QString type();
QDeclarativePropertyMap* properties();
QQmlPropertyMap* properties();
QmlDesigner::ModelNode parentModelNode() const;
QmlDesigner::PropertyName propertyName() const;
@@ -70,7 +70,7 @@ private:
void setup();
QmlDesigner::ModelNode m_modelNode;
QDeclarativePropertyMap m_valuesPropertyMap;
QQmlPropertyMap m_valuesPropertyMap;
PropertyEditorValue* m_editorValue;
};
@@ -152,7 +152,7 @@ private: //variables
QML_DECLARE_TYPE(PropertyEditorValue)
QML_DECLARE_TYPE(PropertyEditorNodeWrapper)
QML_DECLARE_TYPE(QDeclarativePropertyMap)
QML_DECLARE_TYPE(QQmlPropertyMap)
#endif // PROPERTYEDITORVALUE_H

View File

@@ -85,7 +85,7 @@ PropertyEditorView::PropertyEditorView(QWidget *parent) :
m_stackedWidget->insertWidget(0, new QWidget(m_stackedWidget));
QuickPropertyEditorView::registerQmlTypes();
Quick2PropertyEditorView::registerQmlTypes();
setQmlDir(PropertyEditorQmlBackend::propertyEditorResourcesPath());
m_stackedWidget->setWindowTitle(tr("Properties"));
}

View File

@@ -0,0 +1,112 @@
/****************************************************************************
**
** 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 "quick2propertyeditorview.h"
#include "propertyeditorvalue.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)
{
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()
{
static bool declarativeTypesRegistered = false;
if (!declarativeTypesRegistered) {
declarativeTypesRegistered = true;
PropertyEditorValue::registerDeclarativeTypes();
}
}
} //QmlDesigner

View File

@@ -27,37 +27,35 @@
**
****************************************************************************/
#ifndef QUICKPROERTYEDITORVIEW_H
#define QUICKPROERTYEDITORVIEW_H
#ifndef QUICK2PROERTYEDITORVIEW_H
#define QUICK2PROERTYEDITORVIEW_H
#include <QWidget>
#include <QUrl>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QQuickView>
#include <QQmlEngine>
#include <QQmlContext>
QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeError;
class QDeclarativeComponent;
class QQmlError;
class QQmlComponent;
QT_END_NAMESPACE
namespace QmlDesigner {
class QuickPropertyEditorView : public QWidget
class Quick2PropertyEditorView : public QWidget
{
Q_OBJECT
Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true)
public:
explicit QuickPropertyEditorView(QWidget *parent = 0);
explicit Quick2PropertyEditorView(QWidget *parent = 0);
QUrl source() const;
void setSource(const QUrl&);
QDeclarativeEngine* engine();
QDeclarativeContext* rootContext();
QWidget *rootWidget() const;
QQmlEngine* engine();
QQmlContext* rootContext();
enum Status { Null, Ready, Loading, Error };
Status status() const;
@@ -65,23 +63,22 @@ public:
static void registerQmlTypes();
signals:
void statusChanged(QuickPropertyEditorView::Status);
void statusChanged(Quick2PropertyEditorView::Status);
protected:
void setRootWidget(QWidget *);
void execute();
private Q_SLOTS:
void continueExecute();
private:
QScopedPointer<QWidget> m_root;
QWidget *m_containerWidget;
QUrl m_source;
QDeclarativeEngine m_engine;
QWeakPointer<QDeclarativeComponent> m_component;
QQuickView m_view;
QWeakPointer<QQmlComponent> m_component;
};
} //QmlDesigner
#endif // QUICKPROERTYEDITORVIEW_H
#endif // QUICK2PROERTYEDITORVIEW_H

View File

@@ -1,175 +0,0 @@
/****************************************************************************
**
** 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 "quickpropertyeditorview.h"
#include "basiclayouts.h"
#include "basicwidgets.h"
#include "resetwidget.h"
#include "qlayoutobject.h"
#include <qmleditorwidgets/colorwidgets.h>
#include "gradientlineqmladaptor.h"
#include "behaviordialog.h"
#include "fontwidget.h"
#include "siblingcombobox.h"
#include "originwidget.h"
#include <QDeclarativeItem>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
namespace QmlDesigner {
void QuickPropertyEditorView::execute()
{
if (m_root)
delete m_root.data();
if (m_component)
delete m_component.data();
if (!m_source.isEmpty()) {
m_component = new QDeclarativeComponent(&m_engine, m_source, this);
if (!m_component->isLoading())
continueExecute();
else
connect(m_component.data(), SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
}
}
QuickPropertyEditorView::QuickPropertyEditorView(QWidget *parent) :
QWidget(parent)
{
}
QUrl QuickPropertyEditorView::source() const
{
return m_source;
}
void QuickPropertyEditorView::setSource(const QUrl& url)
{
m_source = url;
execute();
}
QDeclarativeEngine* QuickPropertyEditorView::engine()
{
return &m_engine;
}
QWidget *QuickPropertyEditorView::rootWidget() const
{
return m_root.data();
}
QDeclarativeContext* QuickPropertyEditorView::rootContext()
{
return m_engine.rootContext();
}
QuickPropertyEditorView::Status QuickPropertyEditorView::status() const
{
if (!m_component)
return QuickPropertyEditorView::Null;
return QuickPropertyEditorView::Status(m_component->status());
}
void QuickPropertyEditorView::continueExecute()
{
disconnect(m_component.data(), SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
if (m_component->isError()) {
QList<QDeclarativeError> errorList = m_component->errors();
foreach (const QDeclarativeError &error, errorList) {
qWarning() << error;
}
emit statusChanged(status());
return;
}
QObject *obj = m_component->create();
if (m_component->isError()) {
QList<QDeclarativeError> errorList = m_component->errors();
foreach (const QDeclarativeError &error, errorList) {
qWarning() << error;
}
emit statusChanged(status());
return;
}
setRootWidget(qobject_cast<QWidget *>(obj));
emit statusChanged(status());
}
void QuickPropertyEditorView::setRootWidget(QWidget *widget)
{
if (m_root.data() == widget)
return;
window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
window()->setAttribute(Qt::WA_NoSystemBackground, false);
widget->setParent(this);
if (isVisible())
widget->setVisible(true);
resize(widget->size());
m_root.reset(widget);
if (m_root) {
QSize initialSize = m_root->size();
if (initialSize != size())
resize(initialSize);
}
}
void QuickPropertyEditorView::registerQmlTypes()
{
static bool declarativeTypesRegistered = false;
if (!declarativeTypesRegistered) {
declarativeTypesRegistered = true;
BasicWidgets::registerDeclarativeTypes();
BasicLayouts::registerDeclarativeTypes();
ResetWidget::registerDeclarativeType();
QLayoutObject::registerDeclarativeType();
QmlEditorWidgets::ColorWidgets::registerDeclarativeTypes();
BehaviorDialog::registerDeclarativeType();
PropertyEditorValue::registerDeclarativeTypes();
FontWidget::registerDeclarativeTypes();
SiblingComboBox::registerDeclarativeTypes();
OriginWidget::registerDeclarativeType();
GradientLineQmlAdaptor::registerDeclarativeType();
}
}
} //QmlDesigner

View File

@@ -1,130 +0,0 @@
/****************************************************************************
**
** 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 "resetwidget.h"
#include "qdeclarative.h"
#include <QVBoxLayout>
#include <QTableWidget>
#include <QHeaderView>
#include <QPushButton>
#include <QDebug>
#include <QApplication>
QML_DECLARE_TYPE(QmlDesigner::ResetWidget)
namespace QmlDesigner {
ResetWidget::ResetWidget(QWidget *parent) : QGroupBox(parent), m_backendObject(0)
{
m_vlayout = new QVBoxLayout(this);
m_vlayout->setContentsMargins(2,2,2,2);
QPushButton *b = new QPushButton(this);
b->setText(tr("Reset All Properties"));
m_vlayout->addWidget(b);
setLayout(m_vlayout);
}
void ResetWidget::registerDeclarativeType()
{
qmlRegisterType<QmlDesigner::ResetWidget>("Bauhaus", 1, 0, "ResetWidget");
}
void ResetWidget::resetView()
{
m_tableWidget->clear();
delete m_tableWidget;
setupView();
}
void ResetWidget::setupView()
{
m_tableWidget = new QTableWidget(this);
m_vlayout->addWidget(m_tableWidget);
m_tableWidget->setAlternatingRowColors(true);
m_tableWidget->horizontalHeader()->hide();
m_tableWidget->verticalHeader()->hide();
m_tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_tableWidget->setShowGrid(false);
m_tableWidget->setSortingEnabled(true);
m_tableWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
const QMetaObject *metaObject = m_backendObject->metaObject();
int count = metaObject->propertyCount();
m_tableWidget->setColumnCount(3);
m_tableWidget->setRowCount(count);
for (int i=0;i<count;i++) {
QMetaProperty metaProperty = metaObject->property(i);
addPropertyItem(metaProperty.name(), i);
}
m_tableWidget->resizeRowsToContents();
m_tableWidget->resizeColumnsToContents();
m_tableWidget->sortItems(0);
m_tableWidget->setColumnWidth(2, 40);
parentWidget()->resize(parentWidget()->width(), count * 28);
qApp->processEvents();
}
void ResetWidget::addPropertyItem(const QString &name, int row)
{
QTableWidgetItem *newItem = new QTableWidgetItem(name);
m_tableWidget->setItem(row, 0, newItem);
ResetWidgetPushButton *b = new ResetWidgetPushButton(m_tableWidget);
b->setName(name);
b->setText("reset");
connect(b, SIGNAL(pressed(QString)), this, SLOT(buttonPressed(QString)));
b->setMaximumHeight(15);
b->setMinimumHeight(10);
m_tableWidget->setCellWidget(row, 2, b);
}
void ResetWidget::buttonPressed(const QString &)
{
}
ResetWidgetPushButton::ResetWidgetPushButton(QWidget *parent) : QPushButton(parent)
{
connect(this, SIGNAL(pressed()), this, SLOT(myPressed()));
}
void ResetWidgetPushButton::myPressed()
{
emit pressed(m_name);
}
}

View File

@@ -1,106 +0,0 @@
/****************************************************************************
**
** 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 ResetWidget_h
#define ResetWidget_h
#include <QGroupBox>
#include <QPushButton>
QT_BEGIN_NAMESPACE
class QListWidget;
class QVBoxLayout;
class QTableWidget;
QT_END_NAMESPACE
namespace QmlDesigner {
class ResetWidget : public QGroupBox
{
Q_OBJECT
Q_PROPERTY(QObject *backendObject READ backendObject WRITE setBackendObject)
public slots:
void resetView();
public:
ResetWidget(QWidget *parent = 0);
QObject* backendObject()
{
return m_backendObject;
}
void setBackendObject(QObject* backendObject)
{
m_backendObject = backendObject;
setupView();
}
static void registerDeclarativeType();
public slots:
void buttonPressed(const QString &name);
private:
void setupView();
void addPropertyItem(const QString &name, int row);
QObject* m_backendObject;
QVBoxLayout *m_vlayout;
QTableWidget *m_tableWidget;
};
class ResetWidgetPushButton : public QPushButton
{
Q_OBJECT
public slots:
void myPressed();
void setName(const QString &name)
{ m_name = name; }
signals:
void pressed(const QString &name);
public:
ResetWidgetPushButton(QWidget *parent = 0);
private:
QString m_name;
};
}
#endif //ResetWidget_h

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
Item {
property variant flickable: this;

View File

@@ -1,3 +1,5 @@
QT *= qml quick
VPATH += $$PWD
SOURCES += stateseditorwidget.cpp \

View File

@@ -36,7 +36,7 @@ namespace QmlDesigner {
namespace Internal {
StatesEditorImageProvider::StatesEditorImageProvider()
: QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
: QQuickImageProvider(QQuickImageProvider::Image)
{
}

View File

@@ -32,7 +32,7 @@
#include"abstractview.h"
#include <QDeclarativeImageProvider>
#include <QQuickImageProvider>
#include <QWeakPointer>
namespace QmlDesigner {
@@ -40,7 +40,7 @@ namespace Internal {
class StatesEditorView;
class StatesEditorImageProvider : public QDeclarativeImageProvider
class StatesEditorImageProvider : public QQuickImageProvider
{
public:
StatesEditorImageProvider();

View File

@@ -398,6 +398,9 @@ void StatesEditorView::currentStateChanged(const ModelNode &node)
void StatesEditorView::instancesPreviewImageChanged(const QVector<ModelNode> &nodeList)
{
if (!model())
return;
int minimumIndex = 10000;
int maximumIndex = -1;
foreach (const ModelNode &node, nodeList) {

View File

@@ -38,10 +38,10 @@
#include <QBoxLayout>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDeclarativeEngine>
#include <QDeclarativeItem>
#include <QQuickView>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
enum {
debug = false
@@ -51,15 +51,15 @@ namespace QmlDesigner {
int StatesEditorWidget::currentStateInternalId() const
{
Q_ASSERT(m_declarativeView->rootObject());
Q_ASSERT(m_declarativeView->rootObject()->property("currentStateInternalId").isValid());
Q_ASSERT(m_quickView->rootObject());
Q_ASSERT(m_quickView->rootObject()->property("currentStateInternalId").isValid());
return m_declarativeView->rootObject()->property("currentStateInternalId").toInt();
return m_quickView->rootObject()->property("currentStateInternalId").toInt();
}
void StatesEditorWidget::setCurrentStateInternalId(int internalId)
{
m_declarativeView->rootObject()->setProperty("currentStateInternalId", internalId);
m_quickView->rootObject()->setProperty("currentStateInternalId", internalId);
}
void StatesEditorWidget::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
@@ -69,54 +69,56 @@ void StatesEditorWidget::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
void StatesEditorWidget::showAddNewStatesButton(bool showAddNewStatesButton)
{
m_declarativeView->rootContext()->setContextProperty("canAddNewStates", showAddNewStatesButton);
m_quickView->rootContext()->setContextProperty("canAddNewStates", showAddNewStatesButton);
}
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel):
QWidget(),
m_declarativeView(new QDeclarativeView(this)),
m_quickView(new QQuickView()),
m_statesEditorView(statesEditorView),
m_imageProvider(0)
{
m_imageProvider = new Internal::StatesEditorImageProvider;
m_imageProvider->setNodeInstanceView(statesEditorView->nodeInstanceView());
m_declarativeView->engine()->addImageProvider(
m_quickView->engine()->addImageProvider(
QLatin1String("qmldesigner_stateseditor"), m_imageProvider);
m_declarativeView->setAcceptDrops(false);
//m_quickView->setAcceptDrops(false);
QVBoxLayout *layout = new QVBoxLayout(this);
setMinimumHeight(160);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(m_declarativeView.data());
QWidget *container = createWindowContainer(m_quickView.data());
layout->addWidget(container);
m_declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
m_quickView->setResizeMode(QQuickView::SizeRootObjectToView);
m_declarativeView->rootContext()->setContextProperty(QLatin1String("statesEditorModel"), statesEditorModel);
m_quickView->rootContext()->setContextProperty(QLatin1String("statesEditorModel"), statesEditorModel);
QColor highlightColor = palette().highlight().color();
if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0)
highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
m_declarativeView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor);
m_quickView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor);
m_declarativeView->rootContext()->setContextProperty("canAddNewStates", true);
m_quickView->rootContext()->setContextProperty("canAddNewStates", true);
// Work around ASSERT in the internal QGraphicsScene that happens when
// the scene is created + items set dirty in one event loop run (BAUHAUS-459)
//QApplication::processEvents();
m_declarativeView->setSource(QUrl("qrc:/stateseditor/stateslist.qml"));
m_quickView->setSource(QUrl("qrc:/stateseditor/stateslist.qml"));
if (!m_declarativeView->rootObject())
if (!m_quickView->rootObject())
throw InvalidQmlSourceException(__LINE__, __FUNCTION__, __FILE__);
m_declarativeView->setFocusPolicy(Qt::ClickFocus);
QEvent event(QEvent::WindowActivate);
QApplication::sendEvent(m_declarativeView->scene(), &event);
connect(m_declarativeView->rootObject(), SIGNAL(currentStateInternalIdChanged()), statesEditorView, SLOT(synchonizeCurrentStateFromWidget()));
connect(m_declarativeView->rootObject(), SIGNAL(createNewState()), statesEditorView, SLOT(createNewState()));
connect(m_declarativeView->rootObject(), SIGNAL(deleteState(int)), statesEditorView, SLOT(removeState(int)));
QEvent event(QEvent::WindowActivate);
QApplication::sendEvent(m_quickView.data(), &event);
connect(m_quickView->rootObject(), SIGNAL(currentStateInternalIdChanged()), statesEditorView, SLOT(synchonizeCurrentStateFromWidget()));
connect(m_quickView->rootObject(), SIGNAL(createNewState()), statesEditorView, SLOT(createNewState()));
connect(m_quickView->rootObject(), SIGNAL(deleteState(int)), statesEditorView, SLOT(removeState(int)));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));

View File

@@ -33,7 +33,7 @@
#include <QWidget>
QT_BEGIN_NAMESPACE
class QDeclarativeView;
class QQuickView;
QT_END_NAMESPACE
namespace QmlDesigner {
@@ -65,7 +65,7 @@ public:
void showAddNewStatesButton(bool showAddNewStatesButton);
private:
QWeakPointer<QDeclarativeView> m_declarativeView;
QWeakPointer<QQuickView> m_quickView;
QWeakPointer<StatesEditorView> m_statesEditorView;
Internal::StatesEditorImageProvider *m_imageProvider;
};

View File

@@ -27,7 +27,7 @@
**
****************************************************************************/
import QtQuick 1.0
import QtQuick 2.1
Rectangle {
id: root