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
This commit is contained in:
Eike Ziller
2013-04-23 11:13:25 +02:00
48 changed files with 1270 additions and 1209 deletions

31
README
View File

@@ -37,27 +37,28 @@ Installation ("make install") is not needed. It is however possible, using
make install INSTALL_ROOT=$INSTALL_DIRECTORY make install INSTALL_ROOT=$INSTALL_DIRECTORY
Compiling Qt Quick Designer Private Header Dependencies
--------------------------- ---------------------------
Qt Quick Designer (QmlDesigner plugin) depends on "private" headers from Qt The Qt Quick Designer and the QNX plugin, and on Windows the Utils library,use
4.8.0, specifically from the QtDeclarative module. These private headers always private headers of Qt. These private headers always end with an "_p.h". Digia
end with an "_p.h". Digia does not promise to keep these files or APIs binary and the Qt Project do not promise to keep these files or APIs binary or source
or source compatible between releases. This means that when compiled, the compatible between releases. This means that when compiled, Qt Creator has a
plugin has a dependency to the exact Qt version it was compiled with. Running dependency to the exact Qt version it was compiled with. Running Qt Creator
Qt Creator with the plugin against updated Qt libraries (also for patch against updated Qt libraries (also for patch releases) might lead to link time
releases) might lead to link time failures, or even crashes. 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 qmake "QT_PRIVATE_HEADERS=" $SOURCE_DIRECTORY/qtcreator.pro
The plugin is not compiled if the private header files are not found. This The plugins are also automatically omitted if the private header files are
might be the case when you use a Qt version from your distribution, or not found. This might be the case when you use a Qt version from your
installed a self-compiled Qt to a separate directory via 'make install'. You distribution, or installed a self-compiled Qt to a separate directory via
can fix this by either re-building your Qt with the "-developer-build" 'make install'. You can fix this by either re-building your Qt with the
configure option, or by passing the include directory in the source directory "-developer-build" configure option, or by passing the include directory in
to qmake. For example: the source directory to qmake. For example:
qmake "QT_PRIVATE_HEADERS=$$QT_BUILD_TREE/include" $SOURCE_DIRECTORY/qtcreator.pro qmake "QT_PRIVATE_HEADERS=$$QT_BUILD_TREE/include" $SOURCE_DIRECTORY/qtcreator.pro

View File

@@ -26,7 +26,7 @@
\contentspage index.html \contentspage index.html
\previouspage creator-overview.html \previouspage creator-overview.html
\page creator-quick-tour.html \page creator-quick-tour.html
\nextpage creator-build-example-application.html \nextpage creator-configuring.html
\title User Interface \title User Interface

View File

@@ -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}.
*/

View File

@@ -24,7 +24,7 @@
/*! /*!
\contentspage index.html \contentspage index.html
\previouspage creator-quick-tour.html \previouspage creator-configuring.html
\page creator-build-example-application.html \page creator-build-example-application.html
\nextpage creator-tutorials.html \nextpage creator-tutorials.html

View File

@@ -46,6 +46,7 @@
\list \list
\li \l{IDE Overview} \li \l{IDE Overview}
\li \l{User Interface} \li \l{User Interface}
\li \l{Configuring Qt Creator}
\li \l{Building and Running an Example} \li \l{Building and Running an Example}
\li \l{Tutorials} \li \l{Tutorials}
\endlist \endlist
@@ -147,6 +148,7 @@
\list \list
\li \l{IDE Overview} \li \l{IDE Overview}
\li \l{User Interface} \li \l{User Interface}
\li \l{Configuring Qt Creator}
\li \l{Building and Running an Example} \li \l{Building and Running an Example}
\li \l{Tutorials} \li \l{Tutorials}
\list \list

View File

@@ -81,8 +81,8 @@ QString InformationContainer::nameAsString() const
return QLatin1String("PenWidth"); return QLatin1String("PenWidth");
case Position: case Position:
return QLatin1String("Position"); return QLatin1String("Position");
case IsInPositioner: case IsInLayoutable:
return QLatin1String("IsInPositioner"); return QLatin1String("IsInLayoutable");
case SceneTransform: case SceneTransform:
return QLatin1String("SceneTransform"); return QLatin1String("SceneTransform");
case IsResizable: case IsResizable:

View File

@@ -33,16 +33,25 @@
namespace QmlDesigner { namespace QmlDesigner {
static TypeName properDelemitingOfType(const TypeName &typeName)
{
TypeName convertedTypeName = typeName;
int lastIndex = typeName.lastIndexOf('.');
if (lastIndex > 0)
convertedTypeName[lastIndex] = '/';
return convertedTypeName;
}
InstanceContainer::InstanceContainer() InstanceContainer::InstanceContainer()
: m_instanceId(-1), m_majorNumber(-1), m_minorNumber(-1) : 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) 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_nodeSource(nodeSource), m_nodeSourceType(nodeSourceType), m_metaType(metaType)
{ {
m_type.replace('.', '/');
} }
qint32 InstanceContainer::instanceId() const qint32 InstanceContainer::instanceId() const

View File

@@ -47,7 +47,7 @@ enum InformationName
InstanceTypeForProperty, InstanceTypeForProperty,
PenWidth, PenWidth,
Position, Position,
IsInPositioner, IsInLayoutable,
SceneTransform, SceneTransform,
IsResizable, IsResizable,
IsMovable, IsMovable,

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
INCLUDEPATH += $$PWD/ INCLUDEPATH += $$PWD/
HEADERS += $$PWD/qt5nodeinstanceserver.h HEADERS += $$PWD/qt5nodeinstanceserver.h
HEADERS += $$PWD//graphicalnodeinstance.h
HEADERS += $$PWD/qt5informationnodeinstanceserver.h HEADERS += $$PWD/qt5informationnodeinstanceserver.h
HEADERS += $$PWD/qt5rendernodeinstanceserver.h HEADERS += $$PWD/qt5rendernodeinstanceserver.h
HEADERS += $$PWD/qt5previewnodeinstanceserver.h HEADERS += $$PWD/qt5previewnodeinstanceserver.h
@@ -21,8 +22,10 @@ HEADERS += $$PWD/servernodeinstance.h
HEADERS += $$PWD/anchorchangesnodeinstance.h HEADERS += $$PWD/anchorchangesnodeinstance.h
HEADERS += $$PWD/positionernodeinstance.h HEADERS += $$PWD/positionernodeinstance.h
HEADERS += $$PWD/quickwindownodeinstance.h HEADERS += $$PWD/quickwindownodeinstance.h
HEADERS += $$PWD/layoutnodeinstance.h
SOURCES += $$PWD/qt5nodeinstanceserver.cpp SOURCES += $$PWD/qt5nodeinstanceserver.cpp
SOURCES += $$PWD/graphicalnodeinstance.cpp
SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp
SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp
SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp
@@ -43,3 +46,4 @@ SOURCES += $$PWD/servernodeinstance.cpp
SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/anchorchangesnodeinstance.cpp
SOURCES += $$PWD/positionernodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp
SOURCES += $$PWD/quickwindownodeinstance.cpp SOURCES += $$PWD/quickwindownodeinstance.cpp
SOURCES += $$PWD/layoutnodeinstance.cpp

View File

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

View File

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

View File

@@ -891,7 +891,7 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN
informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent())); informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent()));
informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable())); informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable()));
informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable())); 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(), PenWidth, instance.penWidth()));
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren()));
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling()));

View File

@@ -53,6 +53,32 @@
#include <private/qquickanimation_p.h> #include <private/qquickanimation_p.h>
#include <private/qqmltimer_p.h> #include <private/qqmltimer_p.h>
#include <private/qqmlengine_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) static bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName)
{ {
@@ -73,7 +99,7 @@ ObjectNodeInstance::ObjectNodeInstance(QObject *object)
m_metaObject(0), m_metaObject(0),
m_instanceId(-1), m_instanceId(-1),
m_deleteHeldInstance(true), m_deleteHeldInstance(true),
m_isInPositioner(false) m_isInLayoutable(false)
{ {
} }
@@ -192,6 +218,21 @@ bool ObjectNodeInstance::isQuickItem() const
return false; 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 bool ObjectNodeInstance::equalGraphicsItem(QGraphicsItem * /*item*/) const
{ {
return false; return false;
@@ -877,6 +918,10 @@ void tweakObjects(QObject *object)
QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context) QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context)
{ {
ComponentCompleteDisabler disableComponentComplete;
Q_UNUSED(disableComponentComplete)
QQmlComponent *component = new QQmlComponent(context->engine()); QQmlComponent *component = new QQmlComponent(context->engine());
QByteArray importArray; QByteArray importArray;
@@ -932,6 +977,10 @@ static inline QString fixComponentPathForIncompatibleQt(const QString &component
QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlContext *context) QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlContext *context)
{ {
ComponentCompleteDisabler disableComponentComplete;
Q_UNUSED(disableComponentComplete)
QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath)); QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath));
QObject *object = component.beginCreate(context); 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) QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, const QStringList &imports, QQmlContext *context)
{ {
ComponentCompleteDisabler disableComponentComplete;
Q_UNUSED(disableComponentComplete)
QQmlComponent component(context->engine()); QQmlComponent component(context->engine());
QByteArray importArray; QByteArray importArray;
@@ -1021,17 +1074,17 @@ bool ObjectNodeInstance::isMovable() const
return false; 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()
{ {
} }

View File

@@ -63,7 +63,6 @@ class ObjectNodeInstance
public: public:
typedef QSharedPointer<ObjectNodeInstance> Pointer; typedef QSharedPointer<ObjectNodeInstance> Pointer;
typedef QWeakPointer<ObjectNodeInstance> WeakPointer; typedef QWeakPointer<ObjectNodeInstance> WeakPointer;
explicit ObjectNodeInstance(QObject *object);
virtual ~ObjectNodeInstance(); virtual ~ObjectNodeInstance();
void destroy(); void destroy();
@@ -97,6 +96,9 @@ public:
virtual bool isTransition() const; virtual bool isTransition() const;
virtual bool isPositioner() const; virtual bool isPositioner() const;
virtual bool isQuickItem() const; virtual bool isQuickItem() const;
virtual bool isQuickWindow() const;
virtual bool isGraphical() const;
virtual bool isLayoutable() const;
virtual bool equalGraphicsItem(QGraphicsItem *item) const; virtual bool equalGraphicsItem(QGraphicsItem *item) const;
@@ -153,9 +155,9 @@ public:
virtual bool hasContent() const; virtual bool hasContent() const;
virtual bool isResizable() const; virtual bool isResizable() const;
virtual bool isMovable() const; virtual bool isMovable() const;
bool isInPositioner() const; bool isInLayoutable() const;
void setInPositioner(bool isInPositioner); void setInLayoutable(bool isInLayoutable);
virtual void refreshPositioner(); virtual void refreshLayoutable();
bool hasBindingForProperty(const PropertyName &name, bool *hasChanged = 0) const; bool hasBindingForProperty(const PropertyName &name, bool *hasChanged = 0) const;
@@ -181,6 +183,7 @@ public:
virtual void updateDirtyNodeRecursive(); virtual void updateDirtyNodeRecursive();
protected: protected:
explicit ObjectNodeInstance(QObject *object);
void doResetProperty(const PropertyName &propertyName); void doResetProperty(const PropertyName &propertyName);
void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty); void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty);
void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty); void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty);
@@ -201,7 +204,7 @@ private:
NodeInstanceMetaObject *m_metaObject; NodeInstanceMetaObject *m_metaObject;
qint32 m_instanceId; qint32 m_instanceId;
bool m_deleteHeldInstance; bool m_deleteHeldInstance;
bool m_isInPositioner; bool m_isInLayoutable;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -42,6 +42,11 @@ bool PositionerNodeInstance::isPositioner() const
return true; return true;
} }
bool PositionerNodeInstance::isLayoutable() const
{
return true;
}
bool PositionerNodeInstance::isResizable() const bool PositionerNodeInstance::isResizable() const
{ {
return true; return true;
@@ -87,7 +92,7 @@ QQuickBasePositioner *PositionerNodeInstance::positioner() const
return static_cast<QQuickBasePositioner*>(object()); return static_cast<QQuickBasePositioner*>(object());
} }
void PositionerNodeInstance::refreshPositioner() void PositionerNodeInstance::refreshLayoutable()
{ {
bool success = QMetaObject::invokeMethod(positioner(), "prePositioning"); bool success = QMetaObject::invokeMethod(positioner(), "prePositioning");
Q_ASSERT(success); Q_ASSERT(success);

View File

@@ -51,10 +51,11 @@ public:
void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE;
bool isPositioner() const Q_DECL_OVERRIDE; bool isPositioner() const Q_DECL_OVERRIDE;
bool isLayoutable() const Q_DECL_OVERRIDE;
bool isResizable() const Q_DECL_OVERRIDE; bool isResizable() const Q_DECL_OVERRIDE;
void refreshPositioner() Q_DECL_OVERRIDE; void refreshLayoutable() Q_DECL_OVERRIDE;
protected: protected:
PositionerNodeInstance(QQuickBasePositioner *item); PositionerNodeInstance(QQuickBasePositioner *item);

View File

@@ -65,7 +65,7 @@ void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands()
{ {
static bool inFunction = false; static bool inFunction = false;
if (!rootNodeInstance().holdsQuickItem()) if (!rootNodeInstance().holdsGraphical())
return; return;
if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) { 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() QImage Qt5PreviewNodeInstanceServer::renderPreviewImage()
{ {
rootNodeInstance().updateDirtyNodeRecursive(); rootNodeInstance().updateDirtyNodeRecursive();

View File

@@ -45,105 +45,15 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
bool QuickItemNodeInstance::s_createEffectItem = false;
QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item) QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item)
: ObjectNodeInstance(item), : GraphicalNodeInstance(item),
m_hasHeight(false),
m_hasWidth(false),
m_isResizable(true), m_isResizable(true),
m_hasContent(true), m_isMovable(true)
m_isMovable(true),
m_x(0.0),
m_y(0.0),
m_width(0.0),
m_height(0.0)
{ {
} }
QuickItemNodeInstance::~QuickItemNodeInstance() 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) static QTransform transformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer)
@@ -160,40 +70,6 @@ QTransform QuickItemNodeInstance::transform() const
return transformForItem(quickItem(), nodeInstanceServer()); 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 QObject *QuickItemNodeInstance::parent() const
{ {
@@ -202,53 +78,6 @@ QObject *QuickItemNodeInstance::parent() const
return quickItem()->parentItem(); 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 bool QuickItemNodeInstance::isMovable() const
{ {
if (isRootNodeInstance()) if (isRootNodeInstance())
@@ -280,212 +109,12 @@ QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object)
return instance; 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 bool QuickItemNodeInstance::isQuickItem() const
{ {
return true; 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 bool QuickItemNodeInstance::isResizable() const
{ {
if (isRootNodeInstance()) if (isRootNodeInstance())
@@ -494,143 +123,38 @@ bool QuickItemNodeInstance::isResizable() const
return m_isResizable && quickItem() && quickItem()->parentItem(); return m_isResizable && quickItem() && quickItem()->parentItem();
} }
void QuickItemNodeInstance::setResizable(bool resizeable) void QuickItemNodeInstance::setResizable(bool resizable)
{ {
m_isResizable = resizeable; m_isResizable = resizable;
}
int QuickItemNodeInstance::penWidth() const
{
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();
} }
void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty)
{ {
if (oldParentInstance && oldParentInstance->isPositioner()) { if (oldParentInstance && oldParentInstance->isPositioner()) {
setInPositioner(false); setInLayoutable(false);
setMovable(true); setMovable(true);
} }
ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
if (newParentInstance && newParentInstance->isPositioner()) { if (newParentInstance && newParentInstance->isPositioner()) {
setInPositioner(true); setInLayoutable(true);
setMovable(false); setMovable(false);
} }
if (oldParentInstance && oldParentInstance->isPositioner() && !(newParentInstance && newParentInstance->isPositioner())) { if (oldParentInstance && oldParentInstance->isPositioner() && !(newParentInstance && newParentInstance->isPositioner())) {
if (!hasBindingForProperty("x")) if (!hasBindingForProperty("x"))
setPropertyVariant("x", m_x); setPropertyVariant("x", x());
if (!hasBindingForProperty("y")) if (!hasBindingForProperty("y"))
setPropertyVariant("y", m_y); setPropertyVariant("y", y());
} }
refresh(); refresh();
DesignerSupport::updateDirtyNode(quickItem()); DesignerSupport::updateDirtyNode(quickItem());
if (parentInstance() && isInPositioner()) if (parentInstance() && isInLayoutable())
parentInstance()->refreshPositioner(); 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 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;
} }
bool QuickItemNodeInstance::isAnchoredBySibling() const bool QuickItemNodeInstance::isAnchoredBySibling() const
@@ -647,43 +171,16 @@ bool QuickItemNodeInstance::isAnchoredBySibling() const
return false; 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 QQuickItem *QuickItemNodeInstance::quickItem() const
{ {
if (object() == 0) if (object() == 0)
return 0; return 0;
Q_ASSERT(qobject_cast<QQuickItem*>(object()));
return static_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 Internal
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -32,7 +32,7 @@
#include <QtGlobal> #include <QtGlobal>
#include "objectnodeinstance.h" #include "graphicalnodeinstance.h"
#include <QQuickItem> #include <QQuickItem>
#include <designersupport.h> #include <designersupport.h>
@@ -40,7 +40,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
class QuickItemNodeInstance : public ObjectNodeInstance class QuickItemNodeInstance : public GraphicalNodeInstance
{ {
public: public:
typedef QSharedPointer<QuickItemNodeInstance> Pointer; typedef QSharedPointer<QuickItemNodeInstance> Pointer;
@@ -49,91 +49,27 @@ public:
~QuickItemNodeInstance(); ~QuickItemNodeInstance();
static Pointer create(QObject *objectToBeWrapped); 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 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; 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; 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 isAnchoredBySibling() const Q_DECL_OVERRIDE;
bool isAnchoredByChildren() const Q_DECL_OVERRIDE;
void doComponentComplete() Q_DECL_OVERRIDE;
bool isResizable() const Q_DECL_OVERRIDE; bool isResizable() const Q_DECL_OVERRIDE;
void setResizable(bool resizeable); bool isMovable() const Q_DECL_OVERRIDE;
bool isQuickItem() 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: protected:
QuickItemNodeInstance(QQuickItem*); QuickItemNodeInstance(QQuickItem*);
QQuickItem *quickItem() const; QQuickItem *quickItem() const;
void resetHorizontal(); void setMovable(bool movable);
void resetVertical(); void setResizable(bool resizable);
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);
private: //variables private: //variables
bool m_hasHeight;
bool m_hasWidth;
bool m_isResizable; bool m_isResizable;
bool m_hasContent;
bool m_isMovable; bool m_isMovable;
double m_x;
double m_y;
double m_width;
double m_height;
static bool s_createEffectItem;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -29,160 +29,22 @@
#include "quickwindownodeinstance.h" #include "quickwindownodeinstance.h"
#include "qt5nodeinstanceserver.h"
#include <QQmlExpression>
#include <QQuickView>
#include <QQuickItem> #include <QQuickItem>
#include <private/qquickitem_p.h> #include <private/qquickitem_p.h>
#include <cmath>
#include <QHash>
#include <QDebug>
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
bool QuickWindowNodeInstance::s_createEffectItem = false;
QuickWindowNodeInstance::QuickWindowNodeInstance(QQuickWindow *item) QuickWindowNodeInstance::QuickWindowNodeInstance(QQuickWindow *item)
: ObjectNodeInstance(item), : GraphicalNodeInstance(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)
{ {
} }
QuickWindowNodeInstance::~QuickWindowNodeInstance() 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 QObject *QuickWindowNodeInstance::parent() const
@@ -190,49 +52,6 @@ QObject *QuickWindowNodeInstance::parent() const
return 0; 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) QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object)
{ {
QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object); QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object);
@@ -261,229 +80,13 @@ QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object
return instance; 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); bool QuickWindowNodeInstance::isQuickWindow() const
quickItem()->update();
}
bool QuickWindowNodeInstance::isQuickItem() const
{ {
return true; 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) 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()); 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 bool QuickWindowNodeInstance::isAnchoredBySibling() const
{ {
return false; 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 QQuickItem *QuickWindowNodeInstance::quickItem() const
{ {
if (object() == 0) if (object() == 0)
return 0; return 0;
Q_ASSERT(qobject_cast<QQuickWindow*>(object()));
return static_cast<QQuickWindow*>(object())->contentItem(); 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 Internal
} // namespace QmlDesigner } // namespace QmlDesigner

View File

@@ -32,7 +32,7 @@
#include <QtGlobal> #include <QtGlobal>
#include "objectnodeinstance.h" #include "graphicalnodeinstance.h"
#include <QQuickWindow> #include <QQuickWindow>
#include <designersupport.h> #include <designersupport.h>
@@ -40,7 +40,7 @@
namespace QmlDesigner { namespace QmlDesigner {
namespace Internal { namespace Internal {
class QuickWindowNodeInstance : public ObjectNodeInstance class QuickWindowNodeInstance : public GraphicalNodeInstance
{ {
public: public:
typedef QSharedPointer<QuickWindowNodeInstance> Pointer; typedef QSharedPointer<QuickWindowNodeInstance> Pointer;
@@ -49,88 +49,27 @@ public:
~QuickWindowNodeInstance(); ~QuickWindowNodeInstance();
static Pointer create(QObject *objectToBeWrapped); static Pointer create(QObject *objectToBeWrapped);
void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance);
bool isQuickItem() const Q_DECL_OVERRIDE; bool isQuickWindow() 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; 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, void reparent(const ObjectNodeInstance::Pointer &oldParentInstance,
const PropertyName &oldParentProperty, const PropertyName &oldParentProperty,
const ObjectNodeInstance::Pointer &newParentInstance, 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 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: protected:
QuickWindowNodeInstance(QQuickWindow*); QuickWindowNodeInstance(QQuickWindow*);
QQuickItem *quickItem() const; QQuickItem *quickItem() const;
void resetHorizontal(); void resetHorizontal();
void resetVertical(); 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 } // namespace Internal

View File

@@ -37,6 +37,7 @@
#include "qmlstatenodeinstance.h" #include "qmlstatenodeinstance.h"
#include "anchorchangesnodeinstance.h" #include "anchorchangesnodeinstance.h"
#include "positionernodeinstance.h" #include "positionernodeinstance.h"
#include "layoutnodeinstance.h"
#include "debugoutputcommand.h" #include "debugoutputcommand.h"
#include "quickitemnodeinstance.h" #include "quickitemnodeinstance.h"
@@ -150,9 +151,9 @@ void ServerNodeInstance::setNodeSource(const QString &source)
m_nodeInstance->setNodeSource(source); m_nodeInstance->setNodeSource(source);
} }
bool ServerNodeInstance::holdsQuickItem() const bool ServerNodeInstance::holdsGraphical() const
{ {
return m_nodeInstance->isQuickItem(); return m_nodeInstance->isGraphical();
} }
void ServerNodeInstance::updateDirtyNodeRecursive() void ServerNodeInstance::updateDirtyNodeRecursive()
@@ -181,6 +182,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject
instance = Internal::DummyNodeInstance::create(); instance = Internal::DummyNodeInstance::create();
else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner")) else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner"))
instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); instance = Internal::PositionerNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickLayout"))
instance = Internal::LayoutNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickItem")) else if (isSubclassOf(objectToBeWrapped, "QQuickItem"))
instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped); instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQmlComponent")) else if (isSubclassOf(objectToBeWrapped, "QQmlComponent"))
@@ -408,9 +411,9 @@ bool ServerNodeInstance::isMovable() const
return m_nodeInstance->isMovable(); 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 bool ServerNodeInstance::hasAnchor(const PropertyName &name) const

View File

@@ -130,7 +130,7 @@ public:
bool hasContent() const; bool hasContent() const;
bool isResizable() const; bool isResizable() const;
bool isMovable() const; bool isMovable() const;
bool isInPositioner() const; bool isInLayoutable() const;
bool isSubclassOf(const QString &superTypeName) const; bool isSubclassOf(const QString &superTypeName) const;
bool isRootNodeInstance() const; bool isRootNodeInstance() const;
@@ -196,7 +196,7 @@ private: // functions
void setNodeSource(const QString &source); void setNodeSource(const QString &source);
bool holdsQuickItem() const; bool holdsGraphical() const;
void updateDirtyNodeRecursive(); void updateDirtyNodeRecursive();

View File

@@ -885,7 +885,7 @@ static QVector<InformationContainer> createInformationVector(const QList<ServerN
informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent())); informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent()));
informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable())); informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable()));
informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable())); 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(), PenWidth, instance.penWidth()));
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren()));
informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling())); informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling()));

View File

@@ -379,7 +379,7 @@ bool ServerNodeInstance::isMovable() const
return m_nodeInstance->isMovable(); return m_nodeInstance->isMovable();
} }
bool ServerNodeInstance::isInPositioner() const bool ServerNodeInstance::isInLayoutable() const
{ {
return m_nodeInstance->isInPositioner(); return m_nodeInstance->isInPositioner();
} }

View File

@@ -127,7 +127,7 @@ public:
bool hasContent() const; bool hasContent() const;
bool isResizable() const; bool isResizable() const;
bool isMovable() const; bool isMovable() const;
bool isInPositioner() const; bool isInLayoutable() const;
bool isSubclassOf(const QString &superTypeName) const; bool isSubclassOf(const QString &superTypeName) const;
bool isRootNodeInstance() const; bool isRootNodeInstance() const;

View File

@@ -29,11 +29,15 @@ QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
#elif defined(Q_OS_QNX) #elif defined(Q_OS_QNX)
if (!QDir::isAbsolutePath(path)) if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("app/native/%1").arg(path); return QString::fromLatin1("app/native/%1").arg(path);
#elif defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) #elif !defined(Q_OS_ANDROID)
const QString pathInInstallDir = QString pathInInstallDir =
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists()) if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir; return pathInInstallDir;
pathInInstallDir =
QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
#endif #endif
return path; return path;
} }

View File

@@ -45,6 +45,7 @@
#include <qtsupport/baseqtversion.h> #include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h> #include <qtsupport/qtkitinformation.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <utils/environment.h>
#include <QDateTime> #include <QDateTime>
#include <QSettings> #include <QSettings>
@@ -734,6 +735,15 @@ void AndroidConfigurations::load()
QSettings *settings = Core::ICore::instance()->settings(); QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(SettingsGroup); settings->beginGroup(SettingsGroup);
m_config = AndroidConfig(*settings); 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(); settings->endGroup();
} }

View File

@@ -278,6 +278,7 @@ void AndroidSettingsWidget::sdkLocationEditingFinished()
return; return;
} }
m_androidConfig.sdkLocation = location; m_androidConfig.sdkLocation = location;
searchForAnt(location.toString());
saveSettings(true); saveSettings(true);
m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices()); m_AVDModel.setAvdList(AndroidConfigurations::instance().androidVirtualDevices());
m_ui->AVDManagerFrame->setEnabled(true); m_ui->AVDManagerFrame->setEnabled(true);
@@ -289,9 +290,28 @@ void AndroidSettingsWidget::ndkLocationEditingFinished()
m_androidConfig.toolchainHost.clear(); // force toolchain host detection m_androidConfig.toolchainHost.clear(); // force toolchain host detection
if (!checkNDK(location)) if (!checkNDK(location))
return; return;
searchForAnt(location.toString());
saveSettings(true); 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() void AndroidSettingsWidget::antLocationEditingFinished()
{ {
Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text()); Utils::FileName location = Utils::FileName::fromUserInput(m_ui->AntLocationLineEdit->text());

View File

@@ -75,6 +75,7 @@ public:
private slots: private slots:
void sdkLocationEditingFinished(); void sdkLocationEditingFinished();
void ndkLocationEditingFinished(); void ndkLocationEditingFinished();
void searchForAnt(const QString &location);
void antLocationEditingFinished(); void antLocationEditingFinished();
void openJDKLocationEditingFinished(); void openJDKLocationEditingFinished();
void browseSDKLocation(); void browseSDKLocation();

View File

@@ -739,6 +739,7 @@ void MainWindow::registerDefaultActions()
if (supportsFullScreen) { if (supportsFullScreen) {
// Full Screen Action // Full Screen Action
m_toggleFullScreenAction = new QAction(fullScreenActionText, this); m_toggleFullScreenAction = new QAction(fullScreenActionText, this);
m_toggleFullScreenAction->setMenuRole(QAction::NoRole);
m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost()); m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost());
cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext); cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11"))); cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));

View File

@@ -144,7 +144,7 @@ static inline bool itemsHaveSameParent(const QList<ModelNode> &siblingList)
QmlItemNode currentParent = currentItem.instanceParent().toQmlItemNode(); QmlItemNode currentParent = currentItem.instanceParent().toQmlItemNode();
if (!currentParent.isValid()) if (!currentParent.isValid())
return false; return false;
if (currentItem.instanceIsInPositioner()) if (currentItem.instanceIsInLayoutable())
return false; return false;
if (currentParent != parent) if (currentParent != parent)
return false; return false;

View File

@@ -103,7 +103,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
if (formEditorItem if (formEditorItem
&& selectedNodes.contains(formEditorItem->qmlItemNode()) && selectedNodes.contains(formEditorItem->qmlItemNode())
&& formEditorItem->qmlItemNode().instanceIsMovable() && formEditorItem->qmlItemNode().instanceIsMovable()
&& !formEditorItem->qmlItemNode().instanceIsInPositioner() && !formEditorItem->qmlItemNode().instanceIsInLayoutable()
&& (formEditorItem->qmlItemNode().hasShowContent())) && (formEditorItem->qmlItemNode().hasShowContent()))
return true; return true;
} }
@@ -113,7 +113,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
if (formEditorItem if (formEditorItem
&& formEditorItem->qmlItemNode().isValid() && formEditorItem->qmlItemNode().isValid()
&& formEditorItem->qmlItemNode().instanceIsMovable() && formEditorItem->qmlItemNode().instanceIsMovable()
&& !formEditorItem->qmlItemNode().instanceIsInPositioner() && !formEditorItem->qmlItemNode().instanceIsInLayoutable()
&& selectedNodes.contains(formEditorItem->qmlItemNode())) && selectedNodes.contains(formEditorItem->qmlItemNode()))
return true; return true;
} }

View File

@@ -634,7 +634,7 @@ bool FormEditorView::isMoveToolAvailable() const
{ {
if (selectedQmlItemNodes().count() == 1) if (selectedQmlItemNodes().count() == 1)
return selectedQmlItemNodes().first().instanceIsMovable() && return selectedQmlItemNodes().first().instanceIsMovable() &&
!selectedQmlItemNodes().first().instanceIsInPositioner(); !selectedQmlItemNodes().first().instanceIsInLayoutable();
return true; return true;
} }

View File

@@ -367,7 +367,7 @@ QList<FormEditorItem*> movalbeItems(const QList<FormEditorItem*> &itemList)
QMutableListIterator<FormEditorItem*> listIterator(filteredItemList); QMutableListIterator<FormEditorItem*> listIterator(filteredItemList);
while (listIterator.hasNext()) { while (listIterator.hasNext()) {
FormEditorItem *item = listIterator.next(); 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(); listIterator.remove();
} }

View File

@@ -75,7 +75,7 @@ void ResizeIndicator::setItems(const QList<FormEditorItem*> &itemList)
&& item->qmlItemNode().isValid() && item->qmlItemNode().isValid()
&& item->qmlItemNode().instanceIsResizable() && item->qmlItemNode().instanceIsResizable()
&& !item->qmlItemNode().instanceHasRotationTransform() && !item->qmlItemNode().instanceHasRotationTransform()
&& !item->qmlItemNode().instanceIsInPositioner()) { && !item->qmlItemNode().instanceIsInLayoutable()) {
ResizeController controller(m_layerItem, item); ResizeController controller(m_layerItem, item);
m_itemControllerHash.insert(item, controller); m_itemControllerHash.insert(item, controller);
} }

View File

@@ -104,7 +104,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
&& formEditorItem->qmlItemNode().isValid() && formEditorItem->qmlItemNode().isValid()
&& m_beginFormEditorItem->childItems().contains(formEditorItem) && m_beginFormEditorItem->childItems().contains(formEditorItem)
&& formEditorItem->qmlItemNode().instanceIsMovable() && formEditorItem->qmlItemNode().instanceIsMovable()
&& !formEditorItem->qmlItemNode().instanceIsInPositioner()) && !formEditorItem->qmlItemNode().instanceIsInLayoutable())
{ {
newNodeList.append(formEditorItem->qmlItemNode()); newNodeList.append(formEditorItem->qmlItemNode());
} }
@@ -113,7 +113,7 @@ void RubberBandSelectionManipulator::select(SelectionType selectionType)
if (newNodeList.isEmpty() if (newNodeList.isEmpty()
&& m_beginFormEditorItem->qmlItemNode().isValid() && m_beginFormEditorItem->qmlItemNode().isValid()
&& m_beginFormEditorItem->qmlItemNode().instanceIsMovable() && m_beginFormEditorItem->qmlItemNode().instanceIsMovable()
&& !m_beginFormEditorItem->qmlItemNode().instanceIsInPositioner()) && !m_beginFormEditorItem->qmlItemNode().instanceIsInLayoutable())
newNodeList.append(m_beginFormEditorItem->qmlItemNode()); newNodeList.append(m_beginFormEditorItem->qmlItemNode());
QList<QmlItemNode> nodeList; QList<QmlItemNode> nodeList;

View File

@@ -152,7 +152,7 @@ void SelectionTool::hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
if (formEditorItem if (formEditorItem
&& formEditorItem->qmlItemNode().isValid() && formEditorItem->qmlItemNode().isValid()
&& !formEditorItem->qmlItemNode().instanceIsInPositioner() && !formEditorItem->qmlItemNode().instanceIsInLayoutable()
&& formEditorItem->qmlItemNode().instanceIsMovable() && formEditorItem->qmlItemNode().instanceIsMovable()
&& (formEditorItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems)) && (formEditorItem->qmlItemNode().hasShowContent() || !m_selectOnlyContentItems))
{ {

View File

@@ -235,6 +235,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 { Type {
name: "QtQuick.Controls.ToolBar" name: "QtQuick.Controls.ToolBar"
icon: ":/desktopplugin/images/toolbar16.png" icon: ":/desktopplugin/images/toolbar16.png"
@@ -251,6 +268,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 { Type {
name: "QtQuick.Controls.Dial" name: "QtQuick.Controls.Dial"
//icon: ":/desktopplugin/images/progressbar16.png" //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; }
}
}
} }

View File

@@ -66,7 +66,7 @@ public:
bool isResizable() const; bool isResizable() const;
QTransform transform() const; QTransform transform() const;
QTransform sceneTransform() const; QTransform sceneTransform() const;
bool isInPositioner() const; bool isInLayoutable() const;
QPointF position() const; QPointF position() const;
QSizeF size() const; QSizeF size() const;
int penWidth() const; int penWidth() const;
@@ -95,7 +95,7 @@ protected:
InformationName setInformationTransform(const QTransform &transform); InformationName setInformationTransform(const QTransform &transform);
InformationName setInformationPenWith(int penWidth); InformationName setInformationPenWith(int penWidth);
InformationName setInformationPosition(const QPointF &position); InformationName setInformationPosition(const QPointF &position);
InformationName setInformationIsInPositioner(bool isInPositioner); InformationName setInformationIsInLayoutable(bool isInLayoutable);
InformationName setInformationSceneTransform(const QTransform &sceneTransform); InformationName setInformationSceneTransform(const QTransform &sceneTransform);
InformationName setInformationIsResizable(bool isResizable); InformationName setInformationIsResizable(bool isResizable);
InformationName setInformationIsMovable(bool isMovable); InformationName setInformationIsMovable(bool isMovable);

View File

@@ -70,7 +70,7 @@ public:
bool instanceIsAnchoredByChildren() const; bool instanceIsAnchoredByChildren() const;
bool instanceIsMovable() const; bool instanceIsMovable() const;
bool instanceIsResizable() const; bool instanceIsResizable() const;
bool instanceIsInPositioner() const; bool instanceIsInLayoutable() const;
bool instanceHasRotationTransform() const; bool instanceHasRotationTransform() const;
QRectF instanceBoundingRect() const; QRectF instanceBoundingRect() const;

View File

@@ -48,7 +48,7 @@ public:
hasContent(false), hasContent(false),
isMovable(false), isMovable(false),
isResizable(false), isResizable(false),
isInPositioner(false) isInLayoutable(false)
{} {}
qint32 parentInstanceId; qint32 parentInstanceId;
@@ -64,7 +64,7 @@ public:
bool hasContent; bool hasContent;
bool isMovable; bool isMovable;
bool isResizable; bool isResizable;
bool isInPositioner; bool isInLayoutable;
QHash<PropertyName, QVariant> propertyValues; QHash<PropertyName, QVariant> propertyValues;
@@ -198,10 +198,10 @@ QTransform NodeInstance::sceneTransform() const
else else
return QTransform(); return QTransform();
} }
bool NodeInstance::isInPositioner() const bool NodeInstance::isInLayoutable() const
{ {
if (isValid()) if (isValid())
return d->isInPositioner; return d->isInLayoutable;
else else
return false; return false;
} }
@@ -355,11 +355,11 @@ InformationName NodeInstance::setInformationPosition(const QPointF &position)
return NoInformationChange; return NoInformationChange;
} }
InformationName NodeInstance::setInformationIsInPositioner(bool isInPositioner) InformationName NodeInstance::setInformationIsInLayoutable(bool isInLayoutable)
{ {
if (d->isInPositioner != isInPositioner) { if (d->isInLayoutable != isInLayoutable) {
d->isInPositioner = isInPositioner; d->isInLayoutable = isInLayoutable;
return IsInPositioner; return IsInLayoutable;
} }
return NoInformationChange; return NoInformationChange;
@@ -474,7 +474,7 @@ InformationName NodeInstance::setInformation(InformationName name, const QVarian
case Transform: return setInformationTransform(information.value<QTransform>()); break; case Transform: return setInformationTransform(information.value<QTransform>()); break;
case PenWidth: return setInformationPenWith(information.toInt()); break; case PenWidth: return setInformationPenWith(information.toInt()); break;
case Position: return setInformationPosition(information.toPointF()); 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 SceneTransform: return setInformationSceneTransform(information.value<QTransform>()); break;
case IsResizable: return setInformationIsResizable(information.toBool()); break; case IsResizable: return setInformationIsResizable(information.toBool()); break;
case IsMovable: return setInformationIsMovable(information.toBool()); break; case IsMovable: return setInformationIsMovable(information.toBool()); break;

View File

@@ -224,9 +224,9 @@ bool QmlItemNode::instanceIsResizable() const
return nodeInstance().isResizable(); return nodeInstance().isResizable();
} }
bool QmlItemNode::instanceIsInPositioner() const bool QmlItemNode::instanceIsInLayoutable() const
{ {
return nodeInstance().isInPositioner(); return nodeInstance().isInLayoutable();
} }
bool QmlItemNode::instanceHasRotationTransform() const bool QmlItemNode::instanceHasRotationTransform() const

View File

@@ -225,7 +225,7 @@ QByteArray QtQuickApp::generateFileExtended(int fileType,
int QtQuickApp::stubVersionMinor() const int QtQuickApp::stubVersionMinor() const
{ {
return m_componentSet == QtQuick20Components ? 3 : 23; return m_componentSet == QtQuick20Components ? 4 : 23;
} }
QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const

View File

@@ -40,6 +40,12 @@ def main():
allowAppThroughWinFW(workingDir, projectName, False) allowAppThroughWinFW(workingDir, projectName, False)
switchViewTo(ViewConstants.ANALYZE) switchViewTo(ViewConstants.ANALYZE)
selectFromCombo(":Analyzer Toolbar.AnalyzerManagerToolBox_QComboBox", "QML Profiler") 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")) clickButton(waitForObject(":Analyzer Toolbar.Start_QToolButton"))
stopButton = waitForObject(":Qt Creator.Stop_QToolButton") stopButton = waitForObject(":Qt Creator.Stop_QToolButton")
elapsedLabel = waitForObject(":Analyzer Toolbar.Elapsed:_QLabel", 3000) elapsedLabel = waitForObject(":Analyzer Toolbar.Elapsed:_QLabel", 3000)