diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-04-23 11:13:25 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-04-23 11:13:25 +0200 |
commit | 38b61177f608afce72d4988c9241a888c56d1e95 (patch) | |
tree | d30caf5c616fc3a8511dccac524c6f52c1cbbea2 | |
parent | 48687fd8a1e64e4071777ce69e2ee23cc11f582f (diff) | |
parent | c4be740bd6200582fe2a761533ffcf9ecbe37cd1 (diff) | |
download | qt-creator-38b61177f608afce72d4988c9241a888c56d1e95.tar.gz |
Merge remote-tracking branch 'origin/2.7'
Conflicts:
share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp
share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h
tests/auto/treeviewfind/treeviewfind.pro
Change-Id: I1ec788373656c947b50d72df6c26c91312469692
48 files changed, 1270 insertions, 1209 deletions
@@ -37,27 +37,28 @@ Installation ("make install") is not needed. It is however possible, using make install INSTALL_ROOT=$INSTALL_DIRECTORY -Compiling Qt Quick Designer +Private Header Dependencies --------------------------- -Qt Quick Designer (QmlDesigner plugin) depends on "private" headers from Qt -4.8.0, specifically from the QtDeclarative module. These private headers always -end with an "_p.h". Digia does not promise to keep these files or APIs binary -or source compatible between releases. This means that when compiled, the -plugin has a dependency to the exact Qt version it was compiled with. Running -Qt Creator with the plugin against updated Qt libraries (also for patch -releases) might lead to link time failures, or even crashes. +The Qt Quick Designer and the QNX plugin, and on Windows the Utils library,use +private headers of Qt. These private headers always end with an "_p.h". Digia +and the Qt Project do not promise to keep these files or APIs binary or source +compatible between releases. This means that when compiled, Qt Creator has a +dependency to the exact Qt version it was compiled with. Running Qt Creator +against updated Qt libraries (also for patch releases) might lead to link time +failures, or even crashes. -If you want to disable the plugin, you can pass "QT_PRIVATE_HEADERS=" to qmake: +If you want to disable the plugins on Linux and Mac OS X, you can pass +"QT_PRIVATE_HEADERS=" to qmake: qmake "QT_PRIVATE_HEADERS=" $SOURCE_DIRECTORY/qtcreator.pro -The plugin is not compiled if the private header files are not found. This -might be the case when you use a Qt version from your distribution, or -installed a self-compiled Qt to a separate directory via 'make install'. You -can fix this by either re-building your Qt with the "-developer-build" -configure option, or by passing the include directory in the source directory -to qmake. For example: +The plugins are also automatically omitted if the private header files are +not found. This might be the case when you use a Qt version from your +distribution, or installed a self-compiled Qt to a separate directory via +'make install'. You can fix this by either re-building your Qt with the +"-developer-build" configure option, or by passing the include directory in +the source directory to qmake. For example: qmake "QT_PRIVATE_HEADERS=$$QT_BUILD_TREE/include" $SOURCE_DIRECTORY/qtcreator.pro diff --git a/doc/src/howto/creator-ui.qdoc b/doc/src/howto/creator-ui.qdoc index 984f796c77..6afd0ff1d7 100644 --- a/doc/src/howto/creator-ui.qdoc +++ b/doc/src/howto/creator-ui.qdoc @@ -26,7 +26,7 @@ \contentspage index.html \previouspage creator-overview.html \page creator-quick-tour.html - \nextpage creator-build-example-application.html + \nextpage creator-configuring.html \title User Interface diff --git a/doc/src/overview/creator-configuring.qdoc b/doc/src/overview/creator-configuring.qdoc new file mode 100644 index 0000000000..4dad8b6666 --- /dev/null +++ b/doc/src/overview/creator-configuring.qdoc @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator +** +** +** GNU Free Documentation License +** +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** +****************************************************************************/ + +// ********************************************************************** +// NOTE: the sections are not ordered by their logical order to avoid +// reshuffling the file each time the index order changes (i.e., often). +// Run the fixnavi.pl script to adjust the links to the index order. +// ********************************************************************** + +/*! + \contentspage index.html + \previouspage creator-quick-tour.html + \page creator-configuring.html + \nextpage creator-build-example-application.html + + \title Configuring Qt Creator + + If you install \QC as part of a Qt installation, you should be able to use + it out-of-the-box, with the default settings and configuration options. + + However, if you install the stand-alone \QC package, build \QC from sources, + or install several Qt versions, you may need to tell \QC where to find the + Qt versions and compilers by adding the paths to them and by creating + \l{glossary-buildandrun-kit}{kits} that use them. + + To make \QC behave more like your favorite code editor or IDE, you can + change the settings for keyboard shortcuts, color schemes, generic + highlighting, code snippets, and version control systems. In addition, you + can enable experimental plugins and disable plugins that you do not need. + + The following sections summarize the options that you have and point you to + detailed information to help you specify any required settings and to make + using \QC a better experience for you. + + \section1 Checking Build and Run Settings + + \QC is an integrated development environment (IDE) that you can use to + develop Qt applications. While Qt installers typically install \QC, + stand-alone \QC installers never install Qt or any Qt tools, such as qmake. + To use \QC for Qt development, you also need to have a Qt version and a + compiler installed. + + Qt installers, such as SDKs, often attempt to auto-detect the installed + compilers and Qt versions. If they succeed, the relevant kits will + automatically become available in \QC. If they do not, you must add the kits + yourself to tell \QC where everything is. + + To add kits, select \gui Tools > \gui Options > \gui {Build & Run} > + \gui Kits > \gui Add. + + For more information, see \l{Adding Kits}. + + Each kit consists of a set of values that define one environment, such as a + device, compiler, and Qt version. If you know you have installed a Qt + version, but it is not listed in \gui Tools > \gui Options > + \gui {Build & Run} > \gui {Qt Versions}, you must add it. + + For more information, see \l{Adding Qt Versions}. + + Also check that your compiler is listed in \gui Tools > \gui Options > + \gui {Build & Run} > \gui {Compilers}. + + For more information, see \l{Adding Compilers}. + + You can connect mobile devices to the development PC to run, debug, + and analyze applications on them from \QC. You can connect the device to the + development PC via USB. Additionally, you can connect Linux-based devices + over a WLAN. You must also configure a connection between \QC and the + development PC and specify the device in a kit. + + To add devices, select \gui Tools > \gui Options > \gui Devices > \gui Add. + + For more information, see \l{Connecting Mobile Devices}. + + \section1 Changing Keyboard Shortcuts + + You can use \QC with your favorite keyboard shortcuts. + + To view and edit all keyboard shortcuts defined in \QC, select + \gui Tools > \gui Options > \gui Environment > \gui Keyboard. + + For more information, see \l{Keyboard Shortcuts}. + + \section1 Changing Color Schemes + + You can use \QC with your favorite color scheme that defines how code + elements are highlighted and which background color is used. You can select + one of the predefined color schemes or create custom ones. + The color schemes apply to highlighting C++ files, QML files, and generic + files. + + To change the color scheme, select \gui Tools > \gui Options > + \gui {Text Editor} > \gui {Fonts & Color}. + + For more information, see \l{Defining Color Schemes}. + + Generic highlighting is based on highlight definition files that are + provided by the + \l{http://kate-editor.org/2005/03/24/writing-a-syntax-highlighting-file/} + {Kate Editor}. You can download highlight definition files for use with \QC. + + To download and use highlight definition files, select \gui Tools > + \gui Options > \gui {Text Editor} > \gui {Generic Highlighter}. + + For more information, see \l{Generic Highlighting}. + + \section1 Adding Your Own Code Snippets + + As you write code, \QC suggests properties, IDs, and code snippets to + complete the code. It provides a list of context-sensitive suggestions to + the statement currently under your cursor. You can add, modify, + and remove snippets in the snippet editor. + + To open the snippet editor, select \gui Tools > \gui Options > + \gui {Text Editor} > \gui Snippets. + + For more information, see \l{Editing Code Snippets}. + + \section1 Configuring Version Control Systems + + \QC supports several version control systems. In most cases, you do not need + to configure the version control in any special way to make it work with + \QC. Once it is set up correctly on the development PC, it should just work. + + However, some configuration options are available and you can set them in + \gui Tools > \gui Options > \gui{Version Control} > \gui Common. + + For more information about the supported functions, see + \l{Using Version Control Systems}. + + \section1 Enabling and Disabling Plugins + + New \QC plugins are often introduced as \e {experimental plugins} to let + you try them out before they are fully supported. Experimental plugins + are disabled by default and you must enable them for them to become visible + after you restart \QC. + + You can also disable plugins that you do not use, to streamline \QC. + However, this might cause problems when using another plugin later if the + dependencies between plugins are changed between \QC versions. Once you + manually disable a plugin, it stays disabled even when you upgrade to a + new \QC version, and you must manually enable it to be able to use it. + + To enable and disable plugins, select \gui Help > \gui {About Plugins}. + +*/ diff --git a/doc/src/projects/creator-projects-build-run-tutorial.qdoc b/doc/src/projects/creator-projects-build-run-tutorial.qdoc index dc32f2cd0f..a01ef7335a 100644 --- a/doc/src/projects/creator-projects-build-run-tutorial.qdoc +++ b/doc/src/projects/creator-projects-build-run-tutorial.qdoc @@ -24,7 +24,7 @@ /*! \contentspage index.html - \previouspage creator-quick-tour.html + \previouspage creator-configuring.html \page creator-build-example-application.html \nextpage creator-tutorials.html diff --git a/doc/src/qtcreator.qdoc b/doc/src/qtcreator.qdoc index dae5b27b97..5ab92d38e9 100644 --- a/doc/src/qtcreator.qdoc +++ b/doc/src/qtcreator.qdoc @@ -46,6 +46,7 @@ \list \li \l{IDE Overview} \li \l{User Interface} + \li \l{Configuring Qt Creator} \li \l{Building and Running an Example} \li \l{Tutorials} \endlist @@ -147,6 +148,7 @@ \list \li \l{IDE Overview} \li \l{User Interface} + \li \l{Configuring Qt Creator} \li \l{Building and Running an Example} \li \l{Tutorials} \list diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp index 8ed1f0ca70..d4d54b8a63 100644 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp @@ -81,8 +81,8 @@ QString InformationContainer::nameAsString() const return QLatin1String("PenWidth"); case Position: return QLatin1String("Position"); - case IsInPositioner: - return QLatin1String("IsInPositioner"); + case IsInLayoutable: + return QLatin1String("IsInLayoutable"); case SceneTransform: return QLatin1String("SceneTransform"); case IsResizable: diff --git a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp index efb173e817..359529fa4c 100644 --- a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp +++ b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp @@ -33,16 +33,25 @@ namespace QmlDesigner { +static TypeName properDelemitingOfType(const TypeName &typeName) +{ + TypeName convertedTypeName = typeName; + int lastIndex = typeName.lastIndexOf('.'); + if (lastIndex > 0) + convertedTypeName[lastIndex] = '/'; + + return convertedTypeName; +} + InstanceContainer::InstanceContainer() : m_instanceId(-1), m_majorNumber(-1), m_minorNumber(-1) { } InstanceContainer::InstanceContainer(qint32 instanceId, const TypeName &type, int majorNumber, int minorNumber, const QString &componentPath, const QString &nodeSource, NodeSourceType nodeSourceType, NodeMetaType metaType) - : m_instanceId(instanceId), m_type(type), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath), + : m_instanceId(instanceId), m_type(properDelemitingOfType(type)), m_majorNumber(majorNumber), m_minorNumber(minorNumber), m_componentPath(componentPath), m_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType) { - m_type.replace('.', '/'); } qint32 InstanceContainer::instanceId() const diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h index bf0e36025e..4d39c6abdf 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h @@ -47,7 +47,7 @@ enum InformationName InstanceTypeForProperty, PenWidth, Position, - IsInPositioner, + IsInLayoutable, SceneTransform, IsResizable, IsMovable, diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp new file mode 100644 index 0000000000..7f5dc9301d --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.cpp @@ -0,0 +1,558 @@ +#include "graphicalnodeinstance.h" + +#include "qt5nodeinstanceserver.h" + +#include <QQmlExpression> + +#include <cmath> + +#include <QQuickView> + +#include <private/qquickitem_p.h> +#include <private/qquicktextinput_p.h> +#include <private/qquicktextedit_p.h> + +namespace QmlDesigner { +namespace Internal { + +bool GraphicalNodeInstance::s_createEffectItem = false; + +GraphicalNodeInstance::GraphicalNodeInstance(QObject *object) + : ObjectNodeInstance(object), + m_hasHeight(false), + m_hasWidth(false), + m_hasContent(true), + m_x(0.0), + m_y(0.0), + m_width(0.0), + m_height(0.0) +{ +} + +void GraphicalNodeInstance::setHasContent(bool hasContent) +{ + m_hasContent = hasContent; +} + +DesignerSupport *GraphicalNodeInstance::designerSupport() const +{ + return qt5NodeInstanceServer()->designerSupport(); +} + +Qt5NodeInstanceServer *GraphicalNodeInstance::qt5NodeInstanceServer() const +{ + return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer()); +} + + +bool GraphicalNodeInstance::isGraphical() const +{ + return true; +} + +bool GraphicalNodeInstance::anyItemHasContent(QQuickItem *quickItem) +{ + if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) + return true; + + foreach (QQuickItem *childItem, quickItem->childItems()) { + if (anyItemHasContent(childItem)) + return true; + } + + return false; +} + +double GraphicalNodeInstance::x() const +{ + return m_x; +} + +double GraphicalNodeInstance::y() const +{ + return m_y; +} + +QQuickItem *GraphicalNodeInstance::quickItem() const +{ + return 0; +} + +bool GraphicalNodeInstance::childItemsHaveContent(QQuickItem *quickItem) +{ + foreach (QQuickItem *childItem, quickItem->childItems()) { + if (anyItemHasContent(childItem)) + return true; + } + + return false; +} + +bool GraphicalNodeInstance::hasContent() const +{ + if (m_hasContent) + return true; + + return childItemsHaveContent(quickItem()); +} + +void GraphicalNodeInstance::createEffectItem(bool createEffectItem) +{ + s_createEffectItem = createEffectItem; +} + +void GraphicalNodeInstance::updateDirtyNodeRecursive() +{ + foreach (QQuickItem *childItem, quickItem()->childItems()) + updateDirtyNodeRecursive(childItem); + + DesignerSupport::updateDirtyNode(quickItem()); +} + +GraphicalNodeInstance::~GraphicalNodeInstance() +{ + if (quickItem()) + designerSupport()->derefFromEffectItem(quickItem()); +} + +void GraphicalNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const +{ + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) + updateDirtyNodeRecursive(childItem); + } + + DesignerSupport::updateDirtyNode(parentItem); +} + +void GraphicalNodeInstance::updateAllDirtyNodeRecursive(QQuickItem *parentItem) const +{ + foreach (QQuickItem *childItem, parentItem->childItems()) + updateDirtyNodeRecursive(childItem); + + DesignerSupport::updateDirtyNode(parentItem); +} + +QImage GraphicalNodeInstance::renderImage() const +{ + updateDirtyNodeRecursive(quickItem()); + + QRectF boundingRect = boundingRectWithStepChilds(quickItem()); + + QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); + + renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + return renderImage; +} + +QImage GraphicalNodeInstance::renderPreviewImage(const QSize &previewImageSize) const +{ + QRectF previewItemBoundingRect = boundingRect(); + + if (previewItemBoundingRect.isValid() && quickItem()) + return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); + + return QImage(); +} + +void GraphicalNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) +{ + if (instanceId() == 0) { + DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); + } else { + quickItem()->setParentItem(qobject_cast<QQuickItem*>(nodeInstanceServer()->quickView()->rootObject())); + } + + if (s_createEffectItem || instanceId() == 0) + designerSupport()->refFromEffectItem(quickItem()); + + ObjectNodeInstance::initialize(objectNodeInstance); + quickItem()->update(); +} + +QPointF GraphicalNodeInstance::position() const +{ + return quickItem()->position(); +} + +QTransform GraphicalNodeInstance::customTransform() const +{ + return QTransform(); +} + +QTransform GraphicalNodeInstance::sceneTransform() const +{ + return DesignerSupport::windowTransform(quickItem()); +} + +double GraphicalNodeInstance::rotation() const +{ + return quickItem()->rotation(); +} + +double GraphicalNodeInstance::scale() const +{ + return quickItem()->scale(); +} + +QPointF GraphicalNodeInstance::transformOriginPoint() const +{ + return quickItem()->transformOriginPoint(); +} + +double GraphicalNodeInstance::zValue() const +{ + return quickItem()->z(); +} + +double GraphicalNodeInstance::opacity() const +{ + return quickItem()->opacity(); +} + +QSizeF GraphicalNodeInstance::size() const +{ + double width; + + if (DesignerSupport::isValidWidth(quickItem())) { + width = quickItem()->width(); + } else { + width = quickItem()->implicitWidth(); + } + + double height; + + if (DesignerSupport::isValidHeight(quickItem())) { + height = quickItem()->height(); + } else { + height = quickItem()->implicitHeight(); + } + + + return QSizeF(width, height); +} + +static inline bool isRectangleSane(const QRectF &rect) +{ + return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); +} + +QRectF GraphicalNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const +{ + QRectF boundingRect = parentItem->boundingRect(); + + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { + QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); + if (isRectangleSane(transformedRect)) + boundingRect = boundingRect.united(transformedRect); + } + } + + return boundingRect; +} + +void GraphicalNodeInstance::resetHorizontal() + { + setPropertyVariant("x", m_x); + if (m_width > 0.0) { + setPropertyVariant("width", m_width); + } else { + setPropertyVariant("width", quickItem()->implicitWidth()); + } +} + +void GraphicalNodeInstance::resetVertical() + { + setPropertyVariant("y", m_y); + if (m_height > 0.0) { + setPropertyVariant("height", m_height); + } else { + setPropertyVariant("height", quickItem()->implicitWidth()); + } +} + +int GraphicalNodeInstance::penWidth() const +{ + return DesignerSupport::borderWidth(quickItem()); +} + + +QList<ServerNodeInstance> GraphicalNodeInstance::childItemsForChild(QQuickItem *childItem) const +{ + QList<ServerNodeInstance> instanceList; + + if (childItem) { + foreach (QQuickItem *childItem, childItem->childItems()) + { + if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { + instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); + } else { + instanceList.append(childItemsForChild(childItem)); + } + } + } + return instanceList; +} + +QList<ServerNodeInstance> GraphicalNodeInstance::childItems() const +{ + QList<ServerNodeInstance> instanceList; + + foreach (QQuickItem *childItem, quickItem()->childItems()) + { + if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { + instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); + } else { //there might be an item in between the parent instance + //and the child instance. + //Popular example is flickable which has a viewport item between + //the flickable item and the flickable children + instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and + //search for child items with instances. + } + } + + return instanceList; +} + + +void GraphicalNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "state") + return; // states are only set by us + + if (name == "height") { + m_height = value.toDouble(); + if (value.isValid()) + m_hasHeight = true; + else + m_hasHeight = false; + } + + if (name == "width") { + m_width = value.toDouble(); + if (value.isValid()) + m_hasWidth = true; + else + m_hasWidth = false; + } + + if (name == "x") + m_x = value.toDouble(); + + if (name == "y") + m_y = value.toDouble(); + + ObjectNodeInstance::setPropertyVariant(name, value); + + quickItem()->update(); + + refresh(); + + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); +} + +void GraphicalNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "state") + return; // states are only set by us + + ObjectNodeInstance::setPropertyBinding(name, expression); + + quickItem()->update(); + + refresh(); + + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); +} + +QVariant GraphicalNodeInstance::property(const PropertyName &name) const +{ + if (name == "visible") + return quickItem()->isVisible(); + + return ObjectNodeInstance::property(name); +} + +void GraphicalNodeInstance::resetProperty(const PropertyName &name) +{ + if (name == "height") { + m_hasHeight = false; + m_height = 0.0; + } + + if (name == "width") { + m_hasWidth = false; + m_width = 0.0; + } + + if (name == "x") + m_x = 0.0; + + if (name == "y") + m_y = 0.0; + + DesignerSupport::resetAnchor(quickItem(), name); + + if (name == "anchors.fill") { + resetHorizontal(); + resetVertical(); + } else if (name == "anchors.centerIn") { + resetHorizontal(); + resetVertical(); + } else if (name == "anchors.top") { + resetVertical(); + } else if (name == "anchors.left") { + resetHorizontal(); + } else if (name == "anchors.right") { + resetHorizontal(); + } else if (name == "anchors.bottom") { + resetVertical(); + } else if (name == "anchors.horizontalCenter") { + resetHorizontal(); + } else if (name == "anchors.verticalCenter") { + resetVertical(); + } else if (name == "anchors.baseline") { + resetVertical(); + } + + ObjectNodeInstance::resetProperty(name); + + quickItem()->update(); + + if (isInLayoutable()) + parentInstance()->refreshLayoutable(); +} + + +static bool isValidAnchorName(const PropertyName &name) +{ + static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" + << "anchors.left" + << "anchors.right" + << "anchors.bottom" + << "anchors.verticalCenter" + << "anchors.horizontalCenter" + << "anchors.fill" + << "anchors.centerIn" + << "anchors.baseline"); + + return anchorNameList.contains(name); +} + +bool GraphicalNodeInstance::hasAnchor(const PropertyName &name) const +{ + return DesignerSupport::hasAnchor(quickItem(), name); +} + +QPair<PropertyName, ServerNodeInstance> GraphicalNodeInstance::anchor(const PropertyName &name) const +{ + if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) + return ObjectNodeInstance::anchor(name); + + QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); + + QObject *targetObject = nameObjectPair.second; + PropertyName targetName = nameObjectPair.first.toUtf8(); + + if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { + return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); + } else { + return ObjectNodeInstance::anchor(name); + } +} + +static void doComponentCompleteRecursive(QQuickItem *item) +{ + if (item) { + if (DesignerSupport::isComponentComplete(item)) + return; + + foreach (QQuickItem *childItem, item->childItems()) + doComponentCompleteRecursive(childItem); + + static_cast<QQmlParserStatus*>(item)->componentComplete(); + } +} + + +static void disableTextCursor(QQuickItem *item) +{ + foreach (QQuickItem *childItem, item->childItems()) + disableTextCursor(childItem); + + QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(item); + if (textInput) + textInput->setCursorVisible(false); + + QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(item); + if (textEdit) + textEdit->setCursorVisible(false); +} + +void GraphicalNodeInstance::doComponentComplete() +{ + doComponentCompleteRecursive(quickItem()); + + disableTextCursor(quickItem()); + + quickItem()->update(); +} + +bool GraphicalNodeInstance::isAnchoredByChildren() const +{ + if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item + return true; + + return false; +} + +QRectF GraphicalNodeInstance::boundingRect() const +{ + if (quickItem()) { + if (quickItem()->clip()) { + return quickItem()->boundingRect(); + } else { + return boundingRectWithStepChilds(quickItem()); + } + } + + return QRectF(); +} + +static void repositioning(QQuickItem *item) +{ + if (!item) + return; + +// QQmlBasePositioner *positioner = qobject_cast<QQmlBasePositioner*>(item); +// if (positioner) +// positioner->rePositioning(); + + if (item->parentItem()) + repositioning(item->parentItem()); +} + +void GraphicalNodeInstance::refresh() +{ + repositioning(quickItem()); +} + +QList<ServerNodeInstance> GraphicalNodeInstance::stateInstances() const +{ + QList<ServerNodeInstance> instanceList; + QList<QObject*> stateList = DesignerSupport::statesForItem(quickItem()); + foreach (QObject *state, stateList) + { + if (state && nodeInstanceServer()->hasInstanceForObject(state)) + instanceList.append(nodeInstanceServer()->instanceForObject(state)); + } + + return instanceList; +} + +} +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h new file mode 100644 index 0000000000..4aaa414d8f --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/graphicalnodeinstance.h @@ -0,0 +1,95 @@ +#ifndef QMLDESIGNER_GRAPHICALNODEINSTANCE_H +#define QMLDESIGNER_GRAPHICALNODEINSTANCE_H + +#include "objectnodeinstance.h" + +#include <designersupport.h> + +namespace QmlDesigner { +namespace Internal { + +class GraphicalNodeInstance : public ObjectNodeInstance +{ +public: + typedef QSharedPointer<GraphicalNodeInstance> Pointer; + typedef QWeakPointer<GraphicalNodeInstance> WeakPointer; + + ~GraphicalNodeInstance(); + + void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance); + + bool isGraphical() const; + bool hasContent() const; + + QRectF boundingRect() const; + QTransform customTransform() const; + QTransform sceneTransform() const; + double opacity() const; + double rotation() const; + double scale() const; + QPointF transformOriginPoint() const; + double zValue() const; + QPointF position() const; + QSizeF size() const; + + QImage renderImage() const; + QImage renderPreviewImage(const QSize &previewImageSize) const; + + QList<ServerNodeInstance> childItems() const; + + void updateDirtyNodeRecursive(); + static void createEffectItem(bool createEffectItem); + + int penWidth() const; + + void setPropertyVariant(const PropertyName &name, const QVariant &value); + void setPropertyBinding(const PropertyName &name, const QString &expression); + + QVariant property(const PropertyName &name) const; + void resetProperty(const PropertyName &name) ; + + QList<ServerNodeInstance> stateInstances() const; + + bool isAnchoredByChildren() const; + bool hasAnchor(const PropertyName &name) const; + QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const; + + void doComponentComplete(); + +protected: + explicit GraphicalNodeInstance(QObject *object); + void setHasContent(bool hasContent); + DesignerSupport *designerSupport() const; + Qt5NodeInstanceServer *qt5NodeInstanceServer() const; + void updateDirtyNodeRecursive(QQuickItem *parentItem) const; + void updateAllDirtyNodeRecursive(QQuickItem *parentItem) const; + QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; + void resetHorizontal(); + void resetVertical(); + QList<ServerNodeInstance> childItemsForChild(QQuickItem *childItem) const; + void refresh(); + static bool anyItemHasContent(QQuickItem *quickItem); + static bool childItemsHaveContent(QQuickItem *quickItem); + + double x() const; + double y() const; + + virtual QQuickItem *quickItem() const; + +private: // functions + +private: // variables + bool m_hasHeight; + bool m_hasWidth; + bool m_hasContent; + double m_x; + double m_y; + double m_width; + double m_height; + static bool s_createEffectItem; +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // QMLDESIGNER_GRAPHICALNODEINSTANCE_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index b86d8deed3..7a2a5189b0 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD/ HEADERS += $$PWD/qt5nodeinstanceserver.h +HEADERS += $$PWD//graphicalnodeinstance.h HEADERS += $$PWD/qt5informationnodeinstanceserver.h HEADERS += $$PWD/qt5rendernodeinstanceserver.h HEADERS += $$PWD/qt5previewnodeinstanceserver.h @@ -21,8 +22,10 @@ HEADERS += $$PWD/servernodeinstance.h HEADERS += $$PWD/anchorchangesnodeinstance.h HEADERS += $$PWD/positionernodeinstance.h HEADERS += $$PWD/quickwindownodeinstance.h +HEADERS += $$PWD/layoutnodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp +SOURCES += $$PWD/graphicalnodeinstance.cpp SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp @@ -43,3 +46,4 @@ SOURCES += $$PWD/servernodeinstance.cpp SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp SOURCES += $$PWD/quickwindownodeinstance.cpp +SOURCES += $$PWD/layoutnodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp new file mode 100644 index 0000000000..ca7071f692 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** 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 "layoutnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +LayoutNodeInstance::LayoutNodeInstance(QQuickItem *item) + : QuickItemNodeInstance(item) +{ +} + +bool LayoutNodeInstance::isLayoutable() const +{ + return true; +} + +bool LayoutNodeInstance::isResizable() const +{ + return true; +} + +void LayoutNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyVariant(name, value); +} + +void LayoutNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "move" || name == "add" || name == "populate") + return; + + QuickItemNodeInstance::setPropertyBinding(name, expression); +} + +LayoutNodeInstance::Pointer LayoutNodeInstance::create(QObject *object) +{ + qDebug() << "layout" << object; + QQuickItem *item = qobject_cast<QQuickItem*>(object); + + Q_ASSERT(item); + + Pointer instance(new LayoutNodeInstance(item)); + + instance->setHasContent(anyItemHasContent(item)); + item->setFlag(QQuickItem::ItemHasContents, true); + + static_cast<QQmlParserStatus*>(item)->classBegin(); + + instance->populateResetHashes(); + + return instance; +} + +void LayoutNodeInstance::refreshLayoutable() +{ + qDebug() << "before"; + if (quickItem()->parent()) + QCoreApplication::postEvent(quickItem(), new QEvent(QEvent::LayoutRequest)); + qDebug() << "refresh"; + +} + +} +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h new file mode 100644 index 0000000000..7a92f83b04 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 LAYOUTNODEINSTANCE_H +#define LAYOUTNODEINSTANCE_H + +#include "quickitemnodeinstance.h" + +namespace QmlDesigner { +namespace Internal { + +class LayoutNodeInstance : public QuickItemNodeInstance +{ + +public: + typedef QSharedPointer<LayoutNodeInstance> Pointer; + typedef QWeakPointer<LayoutNodeInstance> WeakPointer; + + static Pointer create(QObject *objectToBeWrapped); + + void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; + void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; + + bool isLayoutable() const Q_DECL_OVERRIDE; + + bool isResizable() const Q_DECL_OVERRIDE; + + void refreshLayoutable() Q_DECL_OVERRIDE; + +protected: + LayoutNodeInstance(QQuickItem *item); +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // LAYOUTNODEINSTANCE_H diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index c9789f0110..9b01c0c2d9 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -891,7 +891,7 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent())); informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable())); informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable())); - informationVector.append(InformationContainer(instance.instanceId(), IsInPositioner, instance.isInPositioner())); + informationVector.append(InformationContainer(instance.instanceId(), IsInLayoutable, instance.isInLayoutable())); informationVector.append(InformationContainer(instance.instanceId(), PenWidth, instance.penWidth())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling())); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index 67374d375e..b89231bfbf 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -53,6 +53,32 @@ #include <private/qquickanimation_p.h> #include <private/qqmltimer_p.h> #include <private/qqmlengine_p.h> +#include <designersupport.h> + + +namespace { +class ComponentCompleteDisabler +{ +public: +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) + ComponentCompleteDisabler() + { + DesignerSupport::disableComponentComplete(); + } + + ~ComponentCompleteDisabler() + { + DesignerSupport::enableComponentComplete(); + } +#else + ComponentCompleteDisabler() + { + //nothing not available yet + } +#endif +}; + +} //namespace static bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName) { @@ -73,7 +99,7 @@ ObjectNodeInstance::ObjectNodeInstance(QObject *object) m_metaObject(0), m_instanceId(-1), m_deleteHeldInstance(true), - m_isInPositioner(false) + m_isInLayoutable(false) { } @@ -192,6 +218,21 @@ bool ObjectNodeInstance::isQuickItem() const return false; } +bool ObjectNodeInstance::isQuickWindow() const +{ + return false; +} + +bool ObjectNodeInstance::isGraphical() const +{ + return false; +} + +bool ObjectNodeInstance::isLayoutable() const +{ + return true; +} + bool ObjectNodeInstance::equalGraphicsItem(QGraphicsItem * /*item*/) const { return false; @@ -877,6 +918,10 @@ void tweakObjects(QObject *object) QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent *component = new QQmlComponent(context->engine()); QByteArray importArray; @@ -932,6 +977,10 @@ static inline QString fixComponentPathForIncompatibleQt(const QString &component QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath)); QObject *object = component.beginCreate(context); @@ -951,6 +1000,10 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, const QStringList &imports, QQmlContext *context) { + ComponentCompleteDisabler disableComponentComplete; + + Q_UNUSED(disableComponentComplete) + QQmlComponent component(context->engine()); QByteArray importArray; @@ -1021,17 +1074,17 @@ bool ObjectNodeInstance::isMovable() const return false; } -bool ObjectNodeInstance::isInPositioner() const +bool ObjectNodeInstance::isInLayoutable() const { - return m_isInPositioner; + return m_isInLayoutable; } -void ObjectNodeInstance::setInPositioner(bool isInPositioner) +void ObjectNodeInstance::setInLayoutable(bool isInLayoutable) { - m_isInPositioner = isInPositioner; + m_isInLayoutable = isInLayoutable; } -void ObjectNodeInstance::refreshPositioner() +void ObjectNodeInstance::refreshLayoutable() { } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h index 567fca9fcb..34a4c87839 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h @@ -63,7 +63,6 @@ class ObjectNodeInstance public: typedef QSharedPointer<ObjectNodeInstance> Pointer; typedef QWeakPointer<ObjectNodeInstance> WeakPointer; - explicit ObjectNodeInstance(QObject *object); virtual ~ObjectNodeInstance(); void destroy(); @@ -97,6 +96,9 @@ public: virtual bool isTransition() const; virtual bool isPositioner() const; virtual bool isQuickItem() const; + virtual bool isQuickWindow() const; + virtual bool isGraphical() const; + virtual bool isLayoutable() const; virtual bool equalGraphicsItem(QGraphicsItem *item) const; @@ -153,9 +155,9 @@ public: virtual bool hasContent() const; virtual bool isResizable() const; virtual bool isMovable() const; - bool isInPositioner() const; - void setInPositioner(bool isInPositioner); - virtual void refreshPositioner(); + bool isInLayoutable() const; + void setInLayoutable(bool isInLayoutable); + virtual void refreshLayoutable(); bool hasBindingForProperty(const PropertyName &name, bool *hasChanged = 0) const; @@ -181,6 +183,7 @@ public: virtual void updateDirtyNodeRecursive(); protected: + explicit ObjectNodeInstance(QObject *object); void doResetProperty(const PropertyName &propertyName); void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty); void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty); @@ -201,7 +204,7 @@ private: NodeInstanceMetaObject *m_metaObject; qint32 m_instanceId; bool m_deleteHeldInstance; - bool m_isInPositioner; + bool m_isInLayoutable; }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp index 83f20fb7e4..6bb6ad2ad3 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp @@ -42,6 +42,11 @@ bool PositionerNodeInstance::isPositioner() const return true; } +bool PositionerNodeInstance::isLayoutable() const +{ + return true; +} + bool PositionerNodeInstance::isResizable() const { return true; @@ -87,7 +92,7 @@ QQuickBasePositioner *PositionerNodeInstance::positioner() const return static_cast<QQuickBasePositioner*>(object()); } -void PositionerNodeInstance::refreshPositioner() +void PositionerNodeInstance::refreshLayoutable() { bool success = QMetaObject::invokeMethod(positioner(), "prePositioning"); Q_ASSERT(success); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h index f81e22e717..8ab8333f1f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h @@ -51,10 +51,11 @@ public: void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; bool isPositioner() const Q_DECL_OVERRIDE; + bool isLayoutable() const Q_DECL_OVERRIDE; bool isResizable() const Q_DECL_OVERRIDE; - void refreshPositioner() Q_DECL_OVERRIDE; + void refreshLayoutable() Q_DECL_OVERRIDE; protected: PositionerNodeInstance(QQuickBasePositioner *item); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp index 63451eb01b..df8770c68f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp @@ -65,7 +65,7 @@ void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands() { static bool inFunction = false; - if (!rootNodeInstance().holdsQuickItem()) + if (!rootNodeInstance().holdsGraphical()) return; if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) { @@ -96,14 +96,6 @@ void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*comma } -static void updateDirtyNodeRecursive(QQuickItem *parentItem) -{ - foreach (QQuickItem *childItem, parentItem->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(parentItem); -} - QImage Qt5PreviewNodeInstanceServer::renderPreviewImage() { rootNodeInstance().updateDirtyNodeRecursive(); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 39281d1ac2..12d6f39b86 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -45,105 +45,15 @@ namespace QmlDesigner { namespace Internal { -bool QuickItemNodeInstance::s_createEffectItem = false; - QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item) - : ObjectNodeInstance(item), - m_hasHeight(false), - m_hasWidth(false), + : GraphicalNodeInstance(item), m_isResizable(true), - m_hasContent(true), - m_isMovable(true), - m_x(0.0), - m_y(0.0), - m_width(0.0), - m_height(0.0) + m_isMovable(true) { } QuickItemNodeInstance::~QuickItemNodeInstance() { - if (quickItem()) - designerSupport()->derefFromEffectItem(quickItem()); -} - -bool QuickItemNodeInstance::hasContent() const -{ - if (m_hasContent) - return true; - - return childItemsHaveContent(quickItem()); -} - -QList<ServerNodeInstance> QuickItemNodeInstance::childItems() const -{ - QList<ServerNodeInstance> instanceList; - - foreach (QQuickItem *childItem, quickItem()->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { //there might be an item in between the parent instance - //and the child instance. - //Popular example is flickable which has a viewport item between - //the flickable item and the flickable children - instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and - //search for child items with instances. - } - } - - return instanceList; -} - -QList<ServerNodeInstance> QuickItemNodeInstance::childItemsForChild(QQuickItem *childItem) const -{ - QList<ServerNodeInstance> instanceList; - - if (childItem) { - foreach (QQuickItem *childItem, childItem->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { - instanceList.append(childItemsForChild(childItem)); - } - } - } - return instanceList; -} - -void QuickItemNodeInstance::setHasContent(bool hasContent) -{ - m_hasContent = hasContent; -} - - -bool QuickItemNodeInstance::anyItemHasContent(QQuickItem *quickItem) -{ - if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) - return true; - - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -bool QuickItemNodeInstance::childItemsHaveContent(QQuickItem *quickItem) -{ - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -QPointF QuickItemNodeInstance::position() const -{ - return quickItem()->position(); } static QTransform transformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) @@ -160,40 +70,6 @@ QTransform QuickItemNodeInstance::transform() const return transformForItem(quickItem(), nodeInstanceServer()); } -QTransform QuickItemNodeInstance::customTransform() const -{ - return QTransform(); -} - -QTransform QuickItemNodeInstance::sceneTransform() const -{ - return DesignerSupport::windowTransform(quickItem()); -} - -double QuickItemNodeInstance::rotation() const -{ - return quickItem()->rotation(); -} - -double QuickItemNodeInstance::scale() const -{ - return quickItem()->scale(); -} - -QPointF QuickItemNodeInstance::transformOriginPoint() const -{ - return quickItem()->transformOriginPoint(); -} - -double QuickItemNodeInstance::zValue() const -{ - return quickItem()->z(); -} - -double QuickItemNodeInstance::opacity() const -{ - return quickItem()->opacity(); -} QObject *QuickItemNodeInstance::parent() const { @@ -202,53 +78,6 @@ QObject *QuickItemNodeInstance::parent() const return quickItem()->parentItem(); } - -bool QuickItemNodeInstance::equalQuickItem(QQuickItem *item) const -{ - return item == quickItem(); -} - -void QuickItemNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) - updateDirtyNodeRecursive(childItem); - } - - DesignerSupport::updateDirtyNode(parentItem); -} - -void QuickItemNodeInstance::updateAllDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(parentItem); -} - -QImage QuickItemNodeInstance::renderImage() const -{ - updateDirtyNodeRecursive(quickItem()); - - QRectF boundingRect = boundingRectWithStepChilds(quickItem()); - - QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); - - renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - return renderImage; -} - -QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid() && quickItem()) - return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); - - return QImage(); -} - bool QuickItemNodeInstance::isMovable() const { if (isRootNodeInstance()) @@ -280,212 +109,12 @@ QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object) return instance; } -static void disableTextCursor(QQuickItem *item) -{ - foreach (QQuickItem *childItem, item->childItems()) - disableTextCursor(childItem); - - QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(item); - if (textInput) - textInput->setCursorVisible(false); - - QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(item); - if (textEdit) - textEdit->setCursorVisible(false); -} - -void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) -{ - if (instanceId() == 0) { - DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); - } else { - quickItem()->setParentItem(qobject_cast<QQuickItem*>(nodeInstanceServer()->quickView()->rootObject())); - } - - if (s_createEffectItem || instanceId() == 0) - designerSupport()->refFromEffectItem(quickItem()); - - ObjectNodeInstance::initialize(objectNodeInstance); - quickItem()->update(); -} bool QuickItemNodeInstance::isQuickItem() const { return true; } -QSizeF QuickItemNodeInstance::size() const -{ - double width; - - if (DesignerSupport::isValidWidth(quickItem())) { - width = quickItem()->width(); - } else { - width = quickItem()->implicitWidth(); - } - - double height; - - if (DesignerSupport::isValidHeight(quickItem())) { - height = quickItem()->height(); - } else { - height = quickItem()->implicitHeight(); - } - - - return QSizeF(width, height); -} - -static inline bool isRectangleSane(const QRectF &rect) -{ - return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); -} - -QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const -{ - QRectF boundingRect = parentItem->boundingRect(); - - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); - if (isRectangleSane(transformedRect)) - boundingRect = boundingRect.united(transformedRect); - } - } - - return boundingRect; -} - -QRectF QuickItemNodeInstance::boundingRect() const -{ - if (quickItem()) { - if (quickItem()->clip()) { - return quickItem()->boundingRect(); - } else { - return boundingRectWithStepChilds(quickItem()); - } - } - - return QRectF(); -} - -void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "state") - return; // states are only set by us - - if (name == "height") { - m_height = value.toDouble(); - if (value.isValid()) - m_hasHeight = true; - else - m_hasHeight = false; - } - - if (name == "width") { - m_width = value.toDouble(); - if (value.isValid()) - m_hasWidth = true; - else - m_hasWidth = false; - } - - if (name == "x") - m_x = value.toDouble(); - - if (name == "y") - m_y = value.toDouble(); - - ObjectNodeInstance::setPropertyVariant(name, value); - - quickItem()->update(); - - refresh(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} - -void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (name == "state") - return; // states are only set by us - - ObjectNodeInstance::setPropertyBinding(name, expression); - - quickItem()->update(); - - refresh(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} - -QVariant QuickItemNodeInstance::property(const PropertyName &name) const -{ - return ObjectNodeInstance::property(name); -} - -void QuickItemNodeInstance::resetHorizontal() - { - setPropertyVariant("x", m_x); - if (m_width > 0.0) { - setPropertyVariant("width", m_width); - } else { - setPropertyVariant("width", quickItem()->implicitWidth()); - } -} - -void QuickItemNodeInstance::resetVertical() - { - setPropertyVariant("y", m_y); - if (m_height > 0.0) { - setPropertyVariant("height", m_height); - } else { - setPropertyVariant("height", quickItem()->implicitWidth()); - } -} - -static void repositioning(QQuickItem *item) -{ - if (!item) - return; - -// QQmlBasePositioner *positioner = qobject_cast<QQmlBasePositioner*>(item); -// if (positioner) -// positioner->rePositioning(); - - if (item->parentItem()) - repositioning(item->parentItem()); -} - -void QuickItemNodeInstance::refresh() -{ - repositioning(quickItem()); -} - -static void doComponentCompleteRecursive(QQuickItem *item) -{ - if (item) { - if (DesignerSupport::isComponentComplete(item)) - return; - - foreach (QQuickItem *childItem, item->childItems()) - doComponentCompleteRecursive(childItem); - - static_cast<QQmlParserStatus*>(item)->componentComplete(); - } -} - -void QuickItemNodeInstance::doComponentComplete() -{ - doComponentCompleteRecursive(quickItem()); - - disableTextCursor(quickItem()); - - quickItem()->update(); -} - bool QuickItemNodeInstance::isResizable() const { if (isRootNodeInstance()) @@ -494,143 +123,38 @@ bool QuickItemNodeInstance::isResizable() const return m_isResizable && quickItem() && quickItem()->parentItem(); } -void QuickItemNodeInstance::setResizable(bool resizeable) -{ - m_isResizable = resizeable; -} - -int QuickItemNodeInstance::penWidth() const +void QuickItemNodeInstance::setResizable(bool resizable) { - return DesignerSupport::borderWidth(quickItem()); -} - -void QuickItemNodeInstance::resetProperty(const PropertyName &name) -{ - if (name == "height") { - m_hasHeight = false; - m_height = 0.0; - } - - if (name == "width") { - m_hasWidth = false; - m_width = 0.0; - } - - if (name == "x") - m_x = 0.0; - - if (name == "y") - m_y = 0.0; - - DesignerSupport::resetAnchor(quickItem(), name); - - if (name == "anchors.fill") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.centerIn") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.top") { - resetVertical(); - } else if (name == "anchors.left") { - resetHorizontal(); - } else if (name == "anchors.right") { - resetHorizontal(); - } else if (name == "anchors.bottom") { - resetVertical(); - } else if (name == "anchors.horizontalCenter") { - resetHorizontal(); - } else if (name == "anchors.verticalCenter") { - resetVertical(); - } else if (name == "anchors.baseline") { - resetVertical(); - } - - ObjectNodeInstance::resetProperty(name); - - quickItem()->update(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); + m_isResizable = resizable; } void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) { if (oldParentInstance && oldParentInstance->isPositioner()) { - setInPositioner(false); + setInLayoutable(false); setMovable(true); } ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); if (newParentInstance && newParentInstance->isPositioner()) { - setInPositioner(true); + setInLayoutable(true); setMovable(false); } if (oldParentInstance && oldParentInstance->isPositioner() && !(newParentInstance && newParentInstance->isPositioner())) { if (!hasBindingForProperty("x")) - setPropertyVariant("x", m_x); + setPropertyVariant("x", x()); if (!hasBindingForProperty("y")) - setPropertyVariant("y", m_y); + setPropertyVariant("y", y()); } refresh(); DesignerSupport::updateDirtyNode(quickItem()); - if (parentInstance() && isInPositioner()) - parentInstance()->refreshPositioner(); -} - -static bool isValidAnchorName(const PropertyName &name) -{ - static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" - << "anchors.left" - << "anchors.right" - << "anchors.bottom" - << "anchors.verticalCenter" - << "anchors.horizontalCenter" - << "anchors.fill" - << "anchors.centerIn" - << "anchors.baseline"); - - return anchorNameList.contains(name); -} - -bool QuickItemNodeInstance::hasAnchor(const PropertyName &name) const -{ - return DesignerSupport::hasAnchor(quickItem(), name); -} - -QPair<PropertyName, ServerNodeInstance> QuickItemNodeInstance::anchor(const PropertyName &name) const -{ - if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) - return ObjectNodeInstance::anchor(name); - - QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); - - QObject *targetObject = nameObjectPair.second; - PropertyName targetName = nameObjectPair.first.toUtf8(); - - if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { - return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); - } else { - return ObjectNodeInstance::anchor(name); - } -} - -QList<ServerNodeInstance> QuickItemNodeInstance::stateInstances() const -{ - QList<ServerNodeInstance> instanceList; - QList<QObject*> stateList = DesignerSupport::statesForItem(quickItem()); - foreach (QObject *state, stateList) - { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - - return instanceList; + if (parentInstance() && isInLayoutable()) + parentInstance()->refreshLayoutable(); } bool QuickItemNodeInstance::isAnchoredBySibling() const @@ -647,43 +171,16 @@ bool QuickItemNodeInstance::isAnchoredBySibling() const return false; } -bool QuickItemNodeInstance::isAnchoredByChildren() const -{ - if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item - return true; - return false; -} QQuickItem *QuickItemNodeInstance::quickItem() const { if (object() == 0) return 0; - Q_ASSERT(qobject_cast<QQuickItem*>(object())); return static_cast<QQuickItem*>(object()); } -DesignerSupport *QuickItemNodeInstance::designerSupport() const -{ - return qt5NodeInstanceServer()->designerSupport(); -} - -Qt5NodeInstanceServer *QuickItemNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer()); -} - -void QuickItemNodeInstance::createEffectItem(bool createEffectItem) -{ - s_createEffectItem = createEffectItem; -} - -void QuickItemNodeInstance::updateDirtyNodeRecursive() -{ - updateAllDirtyNodeRecursive(quickItem()); -} - } // namespace Internal } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h index 4015308f8f..f978e769a2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h @@ -32,7 +32,7 @@ #include <QtGlobal> -#include "objectnodeinstance.h" +#include "graphicalnodeinstance.h" #include <QQuickItem> #include <designersupport.h> @@ -40,7 +40,7 @@ namespace QmlDesigner { namespace Internal { -class QuickItemNodeInstance : public ObjectNodeInstance +class QuickItemNodeInstance : public GraphicalNodeInstance { public: typedef QSharedPointer<QuickItemNodeInstance> Pointer; @@ -49,91 +49,27 @@ public: ~QuickItemNodeInstance(); static Pointer create(QObject *objectToBeWrapped); - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) Q_DECL_OVERRIDE; - bool isQuickItem() const Q_DECL_OVERRIDE; - - QRectF boundingRect() const Q_DECL_OVERRIDE; - QPointF position() const Q_DECL_OVERRIDE; - QSizeF size() const Q_DECL_OVERRIDE; QTransform transform() const Q_DECL_OVERRIDE; - QTransform customTransform() const Q_DECL_OVERRIDE; - QTransform sceneTransform() const Q_DECL_OVERRIDE; - double opacity() const Q_DECL_OVERRIDE; QObject *parent() const Q_DECL_OVERRIDE; - double rotation() const Q_DECL_OVERRIDE; - double scale() const Q_DECL_OVERRIDE; - QPointF transformOriginPoint() const Q_DECL_OVERRIDE; - double zValue() const Q_DECL_OVERRIDE; - - bool equalQuickItem(QQuickItem *item) const; - - bool hasContent() const Q_DECL_OVERRIDE; - - QList<ServerNodeInstance> childItems() const Q_DECL_OVERRIDE; - QList<ServerNodeInstance> childItemsForChild(QQuickItem *childItem) const; - - bool isMovable() const Q_DECL_OVERRIDE; - void setMovable(bool movable); - - void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; - void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; - - QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE; - void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE; - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) Q_DECL_OVERRIDE; - int penWidth() const Q_DECL_OVERRIDE; - - bool hasAnchor(const PropertyName &name) const Q_DECL_OVERRIDE; - QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const Q_DECL_OVERRIDE; bool isAnchoredBySibling() const Q_DECL_OVERRIDE; - bool isAnchoredByChildren() const Q_DECL_OVERRIDE; - void doComponentComplete() Q_DECL_OVERRIDE; - bool isResizable() const Q_DECL_OVERRIDE; - void setResizable(bool resizeable); - - void setHasContent(bool hasContent); - - QList<ServerNodeInstance> stateInstances() const Q_DECL_OVERRIDE; - - QImage renderImage() const Q_DECL_OVERRIDE; - QImage renderPreviewImage(const QSize &previewImageSize) const Q_DECL_OVERRIDE; - - DesignerSupport *designerSupport() const; - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - - static void createEffectItem(bool createEffectItem); - - void updateDirtyNodeRecursive() Q_DECL_OVERRIDE; + bool isMovable() const Q_DECL_OVERRIDE; + bool isQuickItem() const Q_DECL_OVERRIDE; protected: QuickItemNodeInstance(QQuickItem*); QQuickItem *quickItem() const; - void resetHorizontal(); - void resetVertical(); - void refresh(); - QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; - void updateDirtyNodeRecursive(QQuickItem *parentItem) const; - void updateAllDirtyNodeRecursive(QQuickItem *parentItem) const; - static bool anyItemHasContent(QQuickItem *graphicsItem); - static bool childItemsHaveContent(QQuickItem *graphicsItem); + void setMovable(bool movable); + void setResizable(bool resizable); private: //variables - bool m_hasHeight; - bool m_hasWidth; bool m_isResizable; - bool m_hasContent; bool m_isMovable; - double m_x; - double m_y; - double m_width; - double m_height; - static bool s_createEffectItem; }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp index f4f86e0b5b..d5a87c7c48 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp @@ -29,160 +29,22 @@ #include "quickwindownodeinstance.h" -#include "qt5nodeinstanceserver.h" -#include <QQmlExpression> -#include <QQuickView> #include <QQuickItem> #include <private/qquickitem_p.h> -#include <cmath> - -#include <QHash> - -#include <QDebug> - namespace QmlDesigner { namespace Internal { -bool QuickWindowNodeInstance::s_createEffectItem = false; - QuickWindowNodeInstance::QuickWindowNodeInstance(QQuickWindow *item) - : ObjectNodeInstance(item), - m_hasHeight(false), - m_hasWidth(false), - m_hasContent(true), - m_x(0.0), - m_y(0.0), - m_width(0.0), - m_height(0.0) + : GraphicalNodeInstance(item) { } QuickWindowNodeInstance::~QuickWindowNodeInstance() { - if (quickItem()) - designerSupport()->derefFromEffectItem(quickItem()); -} - -bool QuickWindowNodeInstance::hasContent() const -{ - if (m_hasContent) - return true; - - return childItemsHaveContent(quickItem()); -} - -QList<ServerNodeInstance> QuickWindowNodeInstance::childItems() const -{ - QList<ServerNodeInstance> instanceList; - - foreach (QQuickItem *childItem, quickItem()->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { //there might be an item in between the parent instance - //and the child instance. - //Popular example is flickable which has a viewport item between - //the flickable item and the flickable children - instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and - //search for child items with instances. - } - } - - return instanceList; -} - -QList<ServerNodeInstance> QuickWindowNodeInstance::childItemsForChild(QQuickItem *childItem) const -{ - QList<ServerNodeInstance> instanceList; - - if (childItem) { - foreach (QQuickItem *childItem, childItem->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { - instanceList.append(childItemsForChild(childItem)); - } - } - } - return instanceList; -} - -void QuickWindowNodeInstance::setHasContent(bool hasContent) -{ - m_hasContent = hasContent; -} - - -bool QuickWindowNodeInstance::anyItemHasContent(QQuickItem *quickItem) -{ - if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) - return true; - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -bool QuickWindowNodeInstance::childItemsHaveContent(QQuickItem *quickItem) -{ - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -QPointF QuickWindowNodeInstance::position() const -{ - return quickItem()->position(); -} - -QTransform QuickWindowNodeInstance::transform() const -{ - return DesignerSupport::parentTransform(quickItem()); -} - -QTransform QuickWindowNodeInstance::customTransform() const -{ - return QTransform(); -} - -QTransform QuickWindowNodeInstance::sceneTransform() const -{ - return DesignerSupport::windowTransform(quickItem()); -} - -double QuickWindowNodeInstance::rotation() const -{ - return quickItem()->rotation(); -} - -double QuickWindowNodeInstance::scale() const -{ - return quickItem()->scale(); -} - -QPointF QuickWindowNodeInstance::transformOriginPoint() const -{ - return quickItem()->transformOriginPoint(); -} - -double QuickWindowNodeInstance::zValue() const -{ - return quickItem()->z(); -} - -double QuickWindowNodeInstance::opacity() const -{ - return quickItem()->opacity(); } QObject *QuickWindowNodeInstance::parent() const @@ -190,49 +52,6 @@ QObject *QuickWindowNodeInstance::parent() const return 0; } -bool QuickWindowNodeInstance::equalQuickItem(QQuickItem *item) const -{ - return item == quickItem(); -} - -void QuickWindowNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) - updateDirtyNodeRecursive(childItem); - } - - DesignerSupport::updateDirtyNode(parentItem); -} - -QImage QuickWindowNodeInstance::renderImage() const -{ - updateDirtyNodeRecursive(quickItem()); - - QRectF boundingRect = boundingRectWithStepChilds(quickItem()); - - QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); - - renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - return renderImage; -} - -QImage QuickWindowNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid() && quickItem()) - return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); - - return QImage(); -} - -bool QuickWindowNodeInstance::isMovable() const -{ - return false; -} - QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object) { QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object); @@ -261,229 +80,13 @@ QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object return instance; } -void QuickWindowNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) -{ - if (instanceId() == 0) { - DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); - } else { - quickItem()->setParentItem(qobject_cast<QQuickItem*>(nodeInstanceServer()->quickView()->rootObject())); - } - - if (s_createEffectItem || instanceId() == 0) - designerSupport()->refFromEffectItem(quickItem()); - ObjectNodeInstance::initialize(objectNodeInstance); - quickItem()->update(); -} -bool QuickWindowNodeInstance::isQuickItem() const +bool QuickWindowNodeInstance::isQuickWindow() const { return true; } -QSizeF QuickWindowNodeInstance::size() const -{ - double width; - - if (DesignerSupport::isValidWidth(quickItem())) { - width = quickItem()->width(); - } else { - width = quickItem()->implicitWidth(); - } - - double height; - - if (DesignerSupport::isValidHeight(quickItem())) { - height = quickItem()->height(); - } else { - height = quickItem()->implicitHeight(); - } - - - return QSizeF(width, height); -} - -static inline bool isRectangleSane(const QRectF &rect) -{ - return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); -} - -QRectF QuickWindowNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const -{ - QRectF boundingRect = parentItem->boundingRect(); - - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); - if (isRectangleSane(transformedRect)) - boundingRect = boundingRect.united(transformedRect); - } - } - - return boundingRect; -} - -QRectF QuickWindowNodeInstance::boundingRect() const -{ - if (quickItem()) { - if (quickItem()->clip()) { - return quickItem()->boundingRect(); - } else { - return boundingRectWithStepChilds(quickItem()); - } - } - - return QRectF(); -} - -void QuickWindowNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "state") - return; // states are only set by us - - if (name == "height") { - m_height = value.toDouble(); - if (value.isValid()) - m_hasHeight = true; - else - m_hasHeight = false; - } - - if (name == "width") { - m_width = value.toDouble(); - if (value.isValid()) - m_hasWidth = true; - else - m_hasWidth = false; - } - - if (name == "x") - m_x = value.toDouble(); - - if (name == "y") - m_y = value.toDouble(); - - ObjectNodeInstance::setPropertyVariant(name, value); - - quickItem()->update(); -} - -void QuickWindowNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (name == "state") - return; // states are only set by us - - ObjectNodeInstance::setPropertyBinding(name, expression); - - quickItem()->update(); -} - -QVariant QuickWindowNodeInstance::property(const PropertyName &name) const -{ - if (name == "visible") - return quickItem()->isVisible(); - return ObjectNodeInstance::property(name); -} - -void QuickWindowNodeInstance::resetHorizontal() - { - setPropertyVariant("x", m_x); - if (m_width > 0.0) { - setPropertyVariant("width", m_width); - } else { - setPropertyVariant("width", quickItem()->implicitWidth()); - } -} - -void QuickWindowNodeInstance::resetVertical() - { - setPropertyVariant("y", m_y); - if (m_height > 0.0) { - setPropertyVariant("height", m_height); - } else { - setPropertyVariant("height", quickItem()->implicitWidth()); - } -} - -static void doComponentCompleteRecursive(QQuickItem *item) -{ - if (item) { - if (DesignerSupport::isComponentComplete(item)) - return; - - foreach (QQuickItem *childItem, item->childItems()) - doComponentCompleteRecursive(childItem); - - static_cast<QQmlParserStatus*>(item)->componentComplete(); - } -} - -void QuickWindowNodeInstance::doComponentComplete() -{ - doComponentCompleteRecursive(quickItem()); - - quickItem()->update(); -} - -bool QuickWindowNodeInstance::isResizable() const -{ - return false; -} - -int QuickWindowNodeInstance::penWidth() const -{ - return DesignerSupport::borderWidth(quickItem()); -} - -void QuickWindowNodeInstance::resetProperty(const PropertyName &name) -{ - if (name == "height") { - m_hasHeight = false; - m_height = 0.0; - } - - if (name == "width") { - m_hasWidth = false; - m_width = 0.0; - } - - if (name == "x") - m_x = 0.0; - - if (name == "y") - m_y = 0.0; - - DesignerSupport::resetAnchor(quickItem(), name); - - if (name == "anchors.fill") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.centerIn") { - resetHorizontal(); - resetVertical(); - } else if (name == "anchors.top") { - resetVertical(); - } else if (name == "anchors.left") { - resetHorizontal(); - } else if (name == "anchors.right") { - resetHorizontal(); - } else if (name == "anchors.bottom") { - resetVertical(); - } else if (name == "anchors.horizontalCenter") { - resetHorizontal(); - } else if (name == "anchors.verticalCenter") { - resetVertical(); - } else if (name == "anchors.baseline") { - resetVertical(); - } - - ObjectNodeInstance::resetProperty(name); - - quickItem()->update(); - - if (isInPositioner()) - parentInstance()->refreshPositioner(); -} void QuickWindowNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) { @@ -492,101 +95,20 @@ void QuickWindowNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldPar DesignerSupport::updateDirtyNode(quickItem()); } -static bool isValidAnchorName(const PropertyName &name) -{ - static PropertyNameList anchorNameList(PropertyNameList() << "anchors.top" - << "anchors.left" - << "anchors.right" - << "anchors.bottom" - << "anchors.verticalCenter" - << "anchors.horizontalCenter" - << "anchors.fill" - << "anchors.centerIn" - << "anchors.baseline"); - - return anchorNameList.contains(name); -} - -bool QuickWindowNodeInstance::hasAnchor(const PropertyName &name) const -{ - return DesignerSupport::hasAnchor(quickItem(), name); -} - -QPair<PropertyName, ServerNodeInstance> QuickWindowNodeInstance::anchor(const PropertyName &name) const -{ - if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) - return ObjectNodeInstance::anchor(name); - - QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context()); - - QObject *targetObject = nameObjectPair.second; - PropertyName targetName = nameObjectPair.first.toUtf8(); - - if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) { - return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject)); - } else { - return ObjectNodeInstance::anchor(name); - } -} - -QList<ServerNodeInstance> QuickWindowNodeInstance::stateInstances() const -{ - QList<ServerNodeInstance> instanceList; - QList<QObject*> stateList = DesignerSupport::statesForItem(quickItem()); - foreach (QObject *state, stateList) - { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - - return instanceList; -} - bool QuickWindowNodeInstance::isAnchoredBySibling() const { return false; } -bool QuickWindowNodeInstance::isAnchoredByChildren() const -{ - if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item - return true; - - return false; -} QQuickItem *QuickWindowNodeInstance::quickItem() const { if (object() == 0) return 0; - Q_ASSERT(qobject_cast<QQuickWindow*>(object())); return static_cast<QQuickWindow*>(object())->contentItem(); } -DesignerSupport *QuickWindowNodeInstance::designerSupport() const -{ - return qt5NodeInstanceServer()->designerSupport(); -} - -Qt5NodeInstanceServer *QuickWindowNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer()); -} - -void QuickWindowNodeInstance::createEffectItem(bool createEffectItem) -{ - s_createEffectItem = createEffectItem; -} - -void QuickWindowNodeInstance::updateDirtyNodeRecursive() -{ - foreach (QQuickItem *childItem, quickItem()->childItems()) - updateDirtyNodeRecursive(childItem); - - DesignerSupport::updateDirtyNode(quickItem()); -} - } // namespace Internal } // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h index 90f5405b97..e9651f9e68 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h @@ -32,7 +32,7 @@ #include <QtGlobal> -#include "objectnodeinstance.h" +#include "graphicalnodeinstance.h" #include <QQuickWindow> #include <designersupport.h> @@ -40,7 +40,7 @@ namespace QmlDesigner { namespace Internal { -class QuickWindowNodeInstance : public ObjectNodeInstance +class QuickWindowNodeInstance : public GraphicalNodeInstance { public: typedef QSharedPointer<QuickWindowNodeInstance> Pointer; @@ -49,88 +49,27 @@ public: ~QuickWindowNodeInstance(); static Pointer create(QObject *objectToBeWrapped); - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance); - bool isQuickItem() const Q_DECL_OVERRIDE; - - QRectF boundingRect() const Q_DECL_OVERRIDE; - QPointF position() const Q_DECL_OVERRIDE; - QSizeF size() const Q_DECL_OVERRIDE; - QTransform transform() const Q_DECL_OVERRIDE; - QTransform customTransform() const Q_DECL_OVERRIDE; - QTransform sceneTransform() const Q_DECL_OVERRIDE; - double opacity() const Q_DECL_OVERRIDE; + bool isQuickWindow() const Q_DECL_OVERRIDE; QObject *parent() const Q_DECL_OVERRIDE; - double rotation() const Q_DECL_OVERRIDE; - double scale() const Q_DECL_OVERRIDE; - QPointF transformOriginPoint() const Q_DECL_OVERRIDE; - double zValue() const Q_DECL_OVERRIDE; - - bool equalQuickItem(QQuickItem *item) const; - - bool hasContent() const Q_DECL_OVERRIDE; - - QList<ServerNodeInstance> childItems() const Q_DECL_OVERRIDE; - QList<ServerNodeInstance> childItemsForChild(QQuickItem *childItem) const; - - bool isMovable() const Q_DECL_OVERRIDE; - - void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; - void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; - - QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE; - void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE; - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty) Q_DECL_OVERRIDE; + const PropertyName &newParentProperty); - int penWidth() const Q_DECL_OVERRIDE; - bool hasAnchor(const PropertyName &name) const Q_DECL_OVERRIDE; - QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const Q_DECL_OVERRIDE; bool isAnchoredBySibling() const Q_DECL_OVERRIDE; - bool isAnchoredByChildren() const Q_DECL_OVERRIDE; - void doComponentComplete() Q_DECL_OVERRIDE; - - bool isResizable() const Q_DECL_OVERRIDE; - - void setHasContent(bool hasContent); - - QList<ServerNodeInstance> stateInstances() const Q_DECL_OVERRIDE; - QImage renderImage() const Q_DECL_OVERRIDE; - QImage renderPreviewImage(const QSize &previewImageSize) const Q_DECL_OVERRIDE; - DesignerSupport *designerSupport() const; - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - - static void createEffectItem(bool createEffectItem); - - void updateDirtyNodeRecursive() Q_DECL_OVERRIDE; protected: QuickWindowNodeInstance(QQuickWindow*); QQuickItem *quickItem() const; void resetHorizontal(); void resetVertical(); - QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; - void updateDirtyNodeRecursive(QQuickItem *parentItem) const; - static bool anyItemHasContent(QQuickItem *graphicsItem); - static bool childItemsHaveContent(QQuickItem *graphicsItem); - -private: //variables - bool m_hasHeight; - bool m_hasWidth; - bool m_hasContent; - double m_x; - double m_y; - double m_width; - double m_height; - static bool s_createEffectItem; + }; } // namespace Internal diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index 4bddcf1a8c..fd9a16b6d2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -37,6 +37,7 @@ #include "qmlstatenodeinstance.h" #include "anchorchangesnodeinstance.h" #include "positionernodeinstance.h" +#include "layoutnodeinstance.h" #include "debugoutputcommand.h" #include "quickitemnodeinstance.h" @@ -150,9 +151,9 @@ void ServerNodeInstance::setNodeSource(const QString &source) m_nodeInstance->setNodeSource(source); } -bool ServerNodeInstance::holdsQuickItem() const +bool ServerNodeInstance::holdsGraphical() const { - return m_nodeInstance->isQuickItem(); + return m_nodeInstance->isGraphical(); } void ServerNodeInstance::updateDirtyNodeRecursive() @@ -181,6 +182,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject instance = Internal::DummyNodeInstance::create(); else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner")) instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); + else if (isSubclassOf(objectToBeWrapped, "QQuickLayout")) + instance = Internal::LayoutNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQuickItem")) instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQmlComponent")) @@ -408,9 +411,9 @@ bool ServerNodeInstance::isMovable() const return m_nodeInstance->isMovable(); } -bool ServerNodeInstance::isInPositioner() const +bool ServerNodeInstance::isInLayoutable() const { - return m_nodeInstance->isInPositioner(); + return m_nodeInstance->isInLayoutable(); } bool ServerNodeInstance::hasAnchor(const PropertyName &name) const diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h index a7cdff1c36..85b27d902e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h @@ -130,7 +130,7 @@ public: bool hasContent() const; bool isResizable() const; bool isMovable() const; - bool isInPositioner() const; + bool isInLayoutable() const; bool isSubclassOf(const QString &superTypeName) const; bool isRootNodeInstance() const; @@ -196,7 +196,7 @@ private: // functions void setNodeSource(const QString &source); - bool holdsQuickItem() const; + bool holdsGraphical() const; void updateDirtyNodeRecursive(); diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp index f6d111173f..d51386ec6a 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/nodeinstanceserver.cpp @@ -885,7 +885,7 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent())); informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable())); informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable())); - informationVector.append(InformationContainer(instance.instanceId(), IsInPositioner, instance.isInPositioner())); + informationVector.append(InformationContainer(instance.instanceId(), IsInLayoutable, instance.isInLayoutable())); informationVector.append(InformationContainer(instance.instanceId(), PenWidth, instance.penWidth())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling())); diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.cpp index 33abe33064..7540cf0d34 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.cpp @@ -379,7 +379,7 @@ bool ServerNodeInstance::isMovable() const return m_nodeInstance->isMovable(); } -bool ServerNodeInstance::isInPositioner() const +bool ServerNodeInstance::isInLayoutable() const { return m_nodeInstance->isInPositioner(); } diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h index 9f49fd76ac..8e2cd67dff 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet/instances/servernodeinstance.h @@ -127,7 +127,7 @@ public: bool hasContent() const; bool isResizable() const; bool isMovable() const; - bool isInPositioner() const; + bool isInLayoutable() const; bool isSubclassOf(const QString &superTypeName) const; bool isRootNodeInstance() const; diff --git a/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp index 3b19047fb2..6d7232e260 100644 --- a/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp +++ b/share/qtcreator/templates/qtquick2app/qtquick2applicationviewer/qtquick2applicationviewer.cpp @@ -29,11 +29,15 @@ QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) #elif defined(Q_OS_QNX) if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("app/native/%1").arg(path); -#elif defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) - const QString pathInInstallDir = +#elif !defined(Q_OS_ANDROID) + QString pathInInstallDir = QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; #endif return path; } diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 29516171e4..c5106c7313 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -45,6 +45,7 @@ #include <qtsupport/baseqtversion.h> #include <qtsupport/qtkitinformation.h> #include <qtsupport/qtversionmanager.h> +#include <utils/environment.h> #include <QDateTime> #include <QSettings> @@ -734,6 +735,15 @@ void AndroidConfigurations::load() QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(SettingsGroup); m_config = AndroidConfig(*settings); + + if (m_config.antLocation.isEmpty()) { + Utils::Environment env = Utils::Environment::systemEnvironment(); + QString location = env.searchInPath(QLatin1String("ant")); + QFileInfo fi(location); + if (fi.exists() && fi.isExecutable() && !fi.isDir()) + m_config.antLocation = Utils::FileName::fromString(location); + } + settings->endGroup(); } diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index 8a0163df7d..2cbbbdc6fa 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished() return; } m_androidConfig.sdkLocation = location; + searchForAnt(location.toString()); saveSettings(true); m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices()); m_ui->AVDManagerFrame->setEnabled(true); @@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished() m_androidConfig.toolchainHost.clear(); // force toolchain host detection if (!checkNDK(location)) return; + searchForAnt(location.toString()); saveSettings(true); } +void AndroidSettingsWidget::searchForAnt(const QString &location) +{ + if (!m_androidConfig.antLocation.isEmpty()) + return; + if (location.isEmpty()) + return; + QDir parentFolder = QFileInfo(location).absoluteDir(); + foreach (const QString &file, parentFolder.entryList()) { + if (file.startsWith(QLatin1String("apache-ant"))) { + QString ant = parentFolder.absolutePath() + QLatin1Char('/') + file + QLatin1String("/bin/ant.bat"); + if (QFileInfo(ant).exists()) { + m_androidConfig.antLocation = Utils::FileName::fromString(ant); + m_ui->AntLocationLineEdit->setText(ant); + } + } + } +} + void AndroidSettingsWidget::antLocationEditingFinished() { Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text()); diff --git a/src/plugins/android/androidsettingswidget.h b/src/plugins/android/androidsettingswidget.h index 957d234173..74e7fe6d43 100644 --- a/src/plugins/android/androidsettingswidget.h +++ b/src/plugins/android/androidsettingswidget.h @@ -75,6 +75,7 @@ public: private slots: void sdkLocationEditingFinished(); void ndkLocationEditingFinished(); + void searchForAnt(const QString &location); void antLocationEditingFinished(); void openJDKLocationEditingFinished(); void browseSDKLocation(); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 0eaaf72a9a..98c963594f 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -739,6 +739,7 @@ void MainWindow::registerDefaultActions() if (supportsFullScreen) { // Full Screen Action m_toggleFullScreenAction = new QAction(fullScreenActionText, this); + m_toggleFullScreenAction->setMenuRole(QAction::NoRole); m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost()); cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp index 14e47b7a5e..a72f8becc3 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu_helper.cpp @@ -144,7 +144,7 @@ static inline bool itemsHaveSameParent(const QList<ModelNode> &siblingList) QmlItemNode currentParent = currentItem.instanceParent().toQmlItemNode(); if (!currentParent.isValid()) return false; - if (currentItem.instanceIsInPositioner()) + if (currentItem.instanceIsInLayoutable()) return false; if (currentParent != parent) return false; diff --git a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp index 5480f18b76..ca6618f81f 100644 --- a/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/abstractformeditortool.cpp @@ -103,7 +103,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem* if (formEditorItem && selectedNodes.contains(formEditorItem->qmlItemNode()) && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && (formEditorItem->qmlItemNode().hasShowContent())) return true; } @@ -113,7 +113,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem* if (formEditorItem && formEditorItem->qmlItemNode().isValid() && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && selectedNodes.contains(formEditorItem->qmlItemNode())) return true; } diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp index a3e3f2ba64..4fdb92baa1 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorview.cpp @@ -634,7 +634,7 @@ bool FormEditorView::isMoveToolAvailable() const { if (selectedQmlItemNodes().count() == 1) return selectedQmlItemNodes().first().instanceIsMovable() && - !selectedQmlItemNodes().first().instanceIsInPositioner(); + !selectedQmlItemNodes().first().instanceIsInLayoutable(); return true; } diff --git a/src/plugins/qmldesigner/components/formeditor/movetool.cpp b/src/plugins/qmldesigner/components/formeditor/movetool.cpp index 59fb681dc4..e284da2eaa 100644 --- a/src/plugins/qmldesigner/components/formeditor/movetool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movetool.cpp @@ -367,7 +367,7 @@ QList<FormEditorItem*> movalbeItems(const QList<FormEditorItem*> &itemList) QMutableListIterator<FormEditorItem*> listIterator(filteredItemList); while (listIterator.hasNext()) { FormEditorItem *item = listIterator.next(); - if (!item->qmlItemNode().isValid() || !item->qmlItemNode().instanceIsMovable() || item->qmlItemNode().instanceIsInPositioner()) + if (!item->qmlItemNode().isValid() || !item->qmlItemNode().instanceIsMovable() || item->qmlItemNode().instanceIsInLayoutable()) listIterator.remove(); } diff --git a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp index 13a35d7cc2..f21ce88bbb 100644 --- a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp @@ -75,7 +75,7 @@ void ResizeIndicator::setItems(const QList<FormEditorItem*> &itemList) && item->qmlItemNode().isValid() && item->qmlItemNode().instanceIsResizable() && !item->qmlItemNode().instanceHasRotationTransform() - && !item->qmlItemNode().instanceIsInPositioner()) { + && !item->qmlItemNode().instanceIsInLayoutable()) { ResizeController controller(m_layerItem, item); m_itemControllerHash.insert(item, controller); } diff --git a/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp index 58d5012654..8d3565acdf 100644 --- a/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/rubberbandselectionmanipulator.cpp @@ -104,7 +104,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType) && formEditorItem->qmlItemNode().isValid() && m_beginFormEditorItem->childItems().contains(formEditorItem) && formEditorItem->qmlItemNode().instanceIsMovable() - && !formEditorItem->qmlItemNode().instanceIsInPositioner()) + && !formEditorItem->qmlItemNode().instanceIsInLayoutable()) { newNodeList.append(formEditorItem->qmlItemNode()); } @@ -113,7 +113,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType) if (newNodeList.isEmpty() && m_beginFormEditorItem->qmlItemNode().isValid() && m_beginFormEditorItem->qmlItemNode().instanceIsMovable() - && !m_beginFormEditorItem->qmlItemNode().instanceIsInPositioner()) + && !m_beginFormEditorItem->qmlItemNode().instanceIsInLayoutable()) newNodeList.append(m_beginFormEditorItem->qmlItemNode()); QList<QmlItemNode> nodeList; diff --git a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp index e7d88725bd..e1673e9ecd 100644 --- a/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp +++ b/src/plugins/qmldesigner/components/formeditor/selectiontool.cpp @@ -152,7 +152,7 @@ void SelectionTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList, if (formEditorItem && formEditorItem->qmlItemNode().isValid() - && !formEditorItem->qmlItemNode().instanceIsInPositioner() + && !formEditorItem->qmlItemNode().instanceIsInLayoutable() && formEditorItem->qmlItemNode().instanceIsMovable() && (formEditorItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems)) { diff --git a/src/plugins/qmldesigner/componentsplugin/components.metainfo b/src/plugins/qmldesigner/componentsplugin/components.metainfo index 206d719a24..6337597aa7 100644 --- a/src/plugins/qmldesigner/componentsplugin/components.metainfo +++ b/src/plugins/qmldesigner/componentsplugin/components.metainfo @@ -236,6 +236,23 @@ MetaInfo { } Type { + name: "QtQuick.Controls.ToolButton" + icon: ":/desktopplugin/images/button16.png" + + ItemLibraryEntry { + name: "Tool Button" + category: "Qt Quick - Controls" + libraryIcon: ":/desktopplugin/images/button.png" + version: "1.0" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 360; } + Property { name: "height"; type: "int"; value: 50; } + } + } + + + Type { name: "QtQuick.Controls.ToolBar" icon: ":/desktopplugin/images/toolbar16.png" @@ -252,6 +269,22 @@ MetaInfo { } Type { + name: "QtQuick.Controls.StatusBar" + icon: ":/desktopplugin/images/toolbar16.png" + + ItemLibraryEntry { + name: "Status Bar" + category: "Qt Quick - Controls" + libraryIcon: ":/desktopplugin/images/toolbar.png" + version: "1.0" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 360; } + Property { name: "height"; type: "int"; value: 50; } + } + } + + Type { name: "QtQuick.Controls.Dial" //icon: ":/desktopplugin/images/progressbar16.png" @@ -267,4 +300,52 @@ MetaInfo { } } + Type { + name: "QtQuick.Layouts.RowLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Row Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + + Type { + name: "QtQuick.Layouts.ColumnLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Column Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + + Type { + name: "QtQuick.Layouts.GridLayout" + icon: ":/qtquickplugin/images/item-icon16.png" + + ItemLibraryEntry { + name: "Grid Layout" + category: "Qt Quick - Layouts" + libraryIcon: ":/qtquickplugin/images/item-icon.png" + version: "1.0" + requiredImport: "QtQuick.Layouts" + + Property { name: "width"; type: "int"; value: 100; } + Property { name: "height"; type: "int"; value: 100; } + } + } + } diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstance.h b/src/plugins/qmldesigner/designercore/include/nodeinstance.h index 5c5eafd9d5..cb3242afad 100644 --- a/src/plugins/qmldesigner/designercore/include/nodeinstance.h +++ b/src/plugins/qmldesigner/designercore/include/nodeinstance.h @@ -66,7 +66,7 @@ public: bool isResizable() const; QTransform transform() const; QTransform sceneTransform() const; - bool isInPositioner() const; + bool isInLayoutable() const; QPointF position() const; QSizeF size() const; int penWidth() const; @@ -95,7 +95,7 @@ protected: InformationName setInformationTransform(const QTransform &transform); InformationName setInformationPenWith(int penWidth); InformationName setInformationPosition(const QPointF &position); - InformationName setInformationIsInPositioner(bool isInPositioner); + InformationName setInformationIsInLayoutable(bool isInLayoutable); InformationName setInformationSceneTransform(const QTransform &sceneTransform); InformationName setInformationIsResizable(bool isResizable); InformationName setInformationIsMovable(bool isMovable); diff --git a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h index f9c7e54766..1d37ad4416 100644 --- a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h +++ b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h @@ -70,7 +70,7 @@ public: bool instanceIsAnchoredByChildren() const; bool instanceIsMovable() const; bool instanceIsResizable() const; - bool instanceIsInPositioner() const; + bool instanceIsInLayoutable() const; bool instanceHasRotationTransform() const; QRectF instanceBoundingRect() const; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp index 2216b1f6fa..1a67bcfac5 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp @@ -48,7 +48,7 @@ public: hasContent(false), isMovable(false), isResizable(false), - isInPositioner(false) + isInLayoutable(false) {} qint32 parentInstanceId; @@ -64,7 +64,7 @@ public: bool hasContent; bool isMovable; bool isResizable; - bool isInPositioner; + bool isInLayoutable; QHash<PropertyName, QVariant> propertyValues; @@ -198,10 +198,10 @@ QTransform NodeInstance::sceneTransform() const else return QTransform(); } -bool NodeInstance::isInPositioner() const +bool NodeInstance::isInLayoutable() const { if (isValid()) - return d->isInPositioner; + return d->isInLayoutable; else return false; } @@ -355,11 +355,11 @@ InformationName NodeInstance::setInformationPosition(const QPointF &position) return NoInformationChange; } -InformationName NodeInstance::setInformationIsInPositioner(bool isInPositioner) +InformationName NodeInstance::setInformationIsInLayoutable(bool isInLayoutable) { - if (d->isInPositioner != isInPositioner) { - d->isInPositioner = isInPositioner; - return IsInPositioner; + if (d->isInLayoutable != isInLayoutable) { + d->isInLayoutable = isInLayoutable; + return IsInLayoutable; } return NoInformationChange; @@ -474,7 +474,7 @@ InformationName NodeInstance::setInformation(InformationName name, const QVarian case Transform: return setInformationTransform(information.value<QTransform>()); break; case PenWidth: return setInformationPenWith(information.toInt()); break; case Position: return setInformationPosition(information.toPointF()); break; - case IsInPositioner: return setInformationIsInPositioner(information.toBool()); break; + case IsInLayoutable: return setInformationIsInLayoutable(information.toBool()); break; case SceneTransform: return setInformationSceneTransform(information.value<QTransform>()); break; case IsResizable: return setInformationIsResizable(information.toBool()); break; case IsMovable: return setInformationIsMovable(information.toBool()); break; diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 697ee77ac8..24e7653370 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -224,9 +224,9 @@ bool QmlItemNode::instanceIsResizable() const return nodeInstance().isResizable(); } -bool QmlItemNode::instanceIsInPositioner() const +bool QmlItemNode::instanceIsInLayoutable() const { - return nodeInstance().isInPositioner(); + return nodeInstance().isInLayoutable(); } bool QmlItemNode::instanceHasRotationTransform() const diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp index eafa5e8dc5..f5bcb49c94 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp @@ -225,7 +225,7 @@ QByteArray QtQuickApp::generateFileExtended(int fileType, int QtQuickApp::stubVersionMinor() const { - return m_componentSet == QtQuick20Components ? 3 : 23; + return m_componentSet == QtQuick20Components ? 4 : 23; } QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const diff --git a/src/shared/qbs b/src/shared/qbs -Subproject 091dc267d3526e7b3d8e05b32a2506aea114f77 +Subproject 29bb66d2fdc863fd5e9b0896fbd862c5b999d54 diff --git a/tests/system/suite_debugger/tst_simple_analyze/test.py b/tests/system/suite_debugger/tst_simple_analyze/test.py index 293fe1b05b..56ad572dd7 100644 --- a/tests/system/suite_debugger/tst_simple_analyze/test.py +++ b/tests/system/suite_debugger/tst_simple_analyze/test.py @@ -40,6 +40,12 @@ def main(): allowAppThroughWinFW(workingDir, projectName, False) switchViewTo(ViewConstants.ANALYZE) selectFromCombo(":Analyzer Toolbar.AnalyzerManagerToolBox_QComboBox", "QML Profiler") + recordButton = waitForObject("{container=':Qt Creator.Analyzer Toolbar_QDockWidget' " + "type='QToolButton' unnamed='1' visible='1' " + "toolTip?='*able profiling'}") + if not test.verify(recordButton.checked, "Verifying recording is enabled."): + test.log("Enabling recording for the test run") + clickButton(recordButton) clickButton(waitForObject(":Analyzer Toolbar.Start_QToolButton")) stopButton = waitForObject(":Qt Creator.Stop_QToolButton") elapsedLabel = waitForObject(":Analyzer Toolbar.Elapsed:_QLabel", 3000) |