From 1a1791abba4e0ce00b84d86a7606ac39d778c334 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Tue, 16 Apr 2013 10:56:56 +0200 Subject: [PATCH 1/8] consoleprocess: use empty string as default terminal Using empty string as default terminal avoids storing a path to QtCreator resources (which becomes invalid if creator is deleted) on mac. Change-Id: I9d5fe9bce38387d82de451652df6be9ec5eb5960 Reviewed-by: Oswald Buddenhagen Reviewed-by: Eike Ziller --- src/libs/utils/consoleprocess.cpp | 4 ++-- src/libs/utils/consoleprocess.h | 2 +- src/plugins/coreplugin/generalsettings.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/utils/consoleprocess.cpp b/src/libs/utils/consoleprocess.cpp index 630783fa18d..d5430d91d90 100644 --- a/src/libs/utils/consoleprocess.cpp +++ b/src/libs/utils/consoleprocess.cpp @@ -141,11 +141,11 @@ QString ConsoleProcess::msgCannotExecute(const QString & p, const QString &why) return tr("Cannot execute '%1': %2").arg(p, why); } -QString ConsoleProcess::terminalEmulator(const QSettings *settings) +QString ConsoleProcess::terminalEmulator(const QSettings *settings, bool nonEmpty) { if (settings) { const QString value = settings->value(QLatin1String("General/TerminalEmulator")).toString(); - if (!value.isEmpty()) + if (!nonEmpty || !value.isEmpty()) return value; } return defaultTerminalEmulator(); diff --git a/src/libs/utils/consoleprocess.h b/src/libs/utils/consoleprocess.h index 8dcff02bf13..5b99961ad94 100644 --- a/src/libs/utils/consoleprocess.h +++ b/src/libs/utils/consoleprocess.h @@ -96,7 +96,7 @@ public: static QString defaultTerminalEmulator(); static QStringList availableTerminalEmulators(); - static QString terminalEmulator(const QSettings *settings); + static QString terminalEmulator(const QSettings *settings, bool nonEmpty = true); static void setTerminalEmulator(QSettings *settings, const QString &term); signals: diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index e65f26978bc..92f03dd2d09 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -116,9 +116,11 @@ QWidget *GeneralSettings::createPage(QWidget *parent) m_page->reloadBehavior->setCurrentIndex(EditorManager::instance()->reloadSetting()); #ifdef Q_OS_UNIX const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators(); - const QString currentTerminal = ConsoleProcess::terminalEmulator(settings); + const QString currentTerminal = ConsoleProcess::terminalEmulator(settings, false); + const QString currentTerminalExplicit = ConsoleProcess::terminalEmulator(settings, true); m_page->terminalComboBox->addItems(availableTerminals); m_page->terminalComboBox->lineEdit()->setText(currentTerminal); + m_page->terminalComboBox->lineEdit()->setPlaceholderText(currentTerminalExplicit); #else m_page->terminalLabel->hide(); m_page->terminalComboBox->hide(); @@ -214,7 +216,7 @@ void GeneralSettings::resetWarnings() void GeneralSettings::resetTerminal() { #if defined(Q_OS_UNIX) - m_page->terminalComboBox->lineEdit()->setText(ConsoleProcess::defaultTerminalEmulator()); + m_page->terminalComboBox->lineEdit()->setText(QString()); #endif } From 9b45d0e2ebb126aae9fd4a302c896ab7d7d41f2e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 09:53:49 +0200 Subject: [PATCH 2/8] QmlDesigner: treat window as item For simplicity we just pretend Window is an item. The state editing is broken atm but does not crash. We will fix this later. Change-Id: I5da0c624b467448cccf16a88fa3ad3682f4ccc20 Reviewed-by: Marco Bubke --- .../designercore/model/qmlitemnode.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 75dffde67f3..697ee77ac85 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -42,10 +42,24 @@ namespace QmlDesigner { +namespace { + +bool isItemOrWindow(const ModelNode &modelNode) +{ + if (modelNode.metaInfo().isSubclassOf("QtQuick.Item", -1, -1)) + return true; + + if (modelNode.metaInfo().isSubclassOf("QtQuick.Window.Window", -1, -1) && modelNode.isRootNode()) + return true; + + return false; +} + +} bool QmlItemNode::isValid() const { - return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && modelNode().metaInfo().isSubclassOf("QtQuick.Item", -1, -1); + return QmlModelNodeFacade::isValid() && modelNode().metaInfo().isValid() && isItemOrWindow(modelNode()); } bool QmlItemNode::isRootNode() const From fecde3e8a16db2198482ba23520e9802490d3b2b Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 09:55:45 +0200 Subject: [PATCH 3/8] QmlDesigner.MetaInfo: cleanup and fix Packages can be qualified by several ".". We have to take this into account. Change-Id: I5da0c624b464448dc6f16aaafa3ad3682f423ccc Reviewed-by: Marco Bubke --- .../designercore/metainfo/nodemetainfo.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 0a1b6ba0aa2..05fdcd4598b 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -782,6 +782,16 @@ static QString getUnqualifiedName(const QString &name) return nameComponents.last(); } +static QString getPackage(const QString &name) +{ + QStringList nameComponents = name.split('.'); + if (nameComponents.size() < 2) + return QString(); + nameComponents.removeLast(); + + return nameComponents.join(QLatin1String(".")); +} + bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const { if (otherType == qualfiedTypeName()) @@ -790,13 +800,9 @@ bool NodeMetaInfoPrivate::cleverCheckType(const QString &otherType) const if (isFileComponent()) return false; - QStringList split = otherType.split('.'); - QString package; - QString typeName = otherType; - if (split.count() > 1) { - package = split.first(); - typeName = split.at(1); - } + const QString typeName = getUnqualifiedName(otherType); + const QString package = getPackage(otherType); + if (cppPackageName() == package) return QString(package + '.' + typeName) == cppPackageName() + '.' + getUnqualifiedName(qualfiedTypeName()); From 0398eb6acdf9df854f3ea3cbe8026ebce07b9a2d Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 10:01:37 +0200 Subject: [PATCH 4/8] QmlDesigner.Rewriter: fix for setting node source This was wrong and could trigger asserts. Change-Id: I5daac224b467444d46f16a888a3ad3682f423c20 Reviewed-by: Marco Bubke --- .../qmldesigner/designercore/model/texttomodelmerger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index b436ecdf851..dd2dfa21753 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -903,10 +903,10 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, } if (isComponentType(typeName) || isImplicitComponent) - setupComponentDelayed(modelNode, !differenceHandler.isValidator()); + setupComponentDelayed(modelNode, differenceHandler.isValidator()); if (isCustomParserType(typeName)) - setupCustomParserNodeDelayed(modelNode, !differenceHandler.isValidator()); + setupCustomParserNodeDelayed(modelNode, differenceHandler.isValidator()); context->enterScope(astNode); @@ -1001,7 +1001,7 @@ void TextToModelMerger::syncNode(ModelNode &modelNode, if (!defaultPropertyItems.isEmpty()) { if (isComponentType(modelNode.type())) - setupComponentDelayed(modelNode, !differenceHandler.isValidator()); + setupComponentDelayed(modelNode, differenceHandler.isValidator()); if (defaultPropertyName.isEmpty()) { qWarning() << "No default property for node type" << modelNode.type() << ", ignoring child items."; } else { From 67825ab2dc12513f4da00f6a3f8404010c27abff Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 10:07:33 +0200 Subject: [PATCH 5/8] QmlDesigner.MetaInfo: Fix for qualification If there is no package the unqualified name is the name not an empty string. Change-Id: I04a51fc79ea9e312e2035ce80eb0f846673a3a44 Reviewed-by: Marco Bubke --- src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index 05fdcd4598b..9c290630baf 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -778,7 +778,7 @@ static QString getUnqualifiedName(const QString &name) { const QStringList nameComponents = name.split('.'); if (nameComponents.size() < 2) - return QString(); + return name; return nameComponents.last(); } From 58e280de2cd61597fd1ab0e05b2a54afa0d6feb2 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 18 Apr 2013 11:56:23 +0200 Subject: [PATCH 6/8] QmlDesigner:Instances: Adding instance for QQuickWindow This allows QuickWindowNodeInstance to return the content item instead. The function parentObject() in ObjectNodeInstance now knows QQuickRootItem, because the parent of the root item should is the windows (which is just a QObject but treated as item from us). Change-Id: Ibaa7ccc8dd9346689cc4443ce0b594056feaa0cf Reviewed-by: Marco Bubke Reviewed-by: Thomas Hartmann --- .../qml2puppet/instances/instances.pri | 2 + .../instances/objectnodeinstance.cpp | 8 +- .../instances/quickwindownodeinstance.cpp | 592 ++++++++++++++++++ .../instances/quickwindownodeinstance.h | 140 +++++ .../instances/servernodeinstance.cpp | 3 + 5 files changed, 744 insertions(+), 1 deletion(-) create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp create mode 100644 share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 28a733cf669..3da4843c07e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -21,6 +21,7 @@ HEADERS += $$PWD/qmltransitionnodeinstance.h HEADERS += $$PWD/servernodeinstance.h HEADERS += $$PWD/anchorchangesnodeinstance.h HEADERS += $$PWD/positionernodeinstance.h +HEADERS += $$PWD/quickwindownodeinstance.h SOURCES += $$PWD/qt5nodeinstanceserver.cpp SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp @@ -43,3 +44,4 @@ SOURCES += $$PWD/qmltransitionnodeinstance.cpp SOURCES += $$PWD/servernodeinstance.cpp SOURCES += $$PWD/anchorchangesnodeinstance.cpp SOURCES += $$PWD/positionernodeinstance.cpp +SOURCES += $$PWD/quickwindownodeinstance.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp index ad5f357635a..71b8544e938 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp @@ -1124,8 +1124,14 @@ QObject *ObjectNodeInstance::parent() const QObject *parentObject(QObject *object) { QQuickItem *quickItem = qobject_cast(object); - if (quickItem) + if (quickItem && quickItem->parentItem()) { + + //QQuickRootItem is used by Window and we want to return the Window as parent + if (strcmp(quickItem->metaObject()->className(), "QQuickRootItem")) + return object->parent(); + return quickItem->parentItem(); + } return object->parent(); } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp new file mode 100644 index 00000000000..f4f86e0b5b6 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.cpp @@ -0,0 +1,592 @@ +/**************************************************************************** +** +** 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 "quickwindownodeinstance.h" + +#include "qt5nodeinstanceserver.h" + +#include +#include +#include + +#include + +#include + +#include + +#include + +namespace QmlDesigner { +namespace Internal { + +bool QuickWindowNodeInstance::s_createEffectItem = false; + +QuickWindowNodeInstance::QuickWindowNodeInstance(QQuickWindow *item) + : ObjectNodeInstance(item), + m_hasHeight(false), + m_hasWidth(false), + m_hasContent(true), + m_x(0.0), + m_y(0.0), + m_width(0.0), + m_height(0.0) +{ +} + +QuickWindowNodeInstance::~QuickWindowNodeInstance() +{ + if (quickItem()) + designerSupport()->derefFromEffectItem(quickItem()); +} + +bool QuickWindowNodeInstance::hasContent() const +{ + if (m_hasContent) + return true; + + return childItemsHaveContent(quickItem()); +} + +QList QuickWindowNodeInstance::childItems() const +{ + QList 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 QuickWindowNodeInstance::childItemsForChild(QQuickItem *childItem) const +{ + QList 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 +{ + return 0; +} + +bool QuickWindowNodeInstance::equalQuickItem(QQuickItem *item) const +{ + return item == quickItem(); +} + +void QuickWindowNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const +{ + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) + updateDirtyNodeRecursive(childItem); + } + + DesignerSupport::updateDirtyNode(parentItem); +} + +QImage QuickWindowNodeInstance::renderImage() const +{ + updateDirtyNodeRecursive(quickItem()); + + QRectF boundingRect = boundingRectWithStepChilds(quickItem()); + + QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize()); + + renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); + + return renderImage; +} + +QImage QuickWindowNodeInstance::renderPreviewImage(const QSize &previewImageSize) const +{ + QRectF previewItemBoundingRect = boundingRect(); + + if (previewItemBoundingRect.isValid() && quickItem()) + return designerSupport()->renderImageForItem(quickItem(), previewItemBoundingRect, previewImageSize); + + return QImage(); +} + +bool QuickWindowNodeInstance::isMovable() const +{ + return false; +} + +QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object) +{ + QQuickWindow *quickWindow = qobject_cast(object); + + Q_ASSERT(quickWindow); + + Pointer instance(new QuickWindowNodeInstance(quickWindow)); + + instance->setHasContent(anyItemHasContent(quickWindow->contentItem())); + quickWindow->contentItem()->setFlag(QQuickItem::ItemHasContents, true); + + static_cast(quickWindow->contentItem())->classBegin(); + + instance->populateResetHashes(); + + QQuickItemPrivate *privateItem = static_cast(QObjectPrivate::get(quickWindow->contentItem())); + + if (privateItem->window) { + qDebug() << "removing from window"; + if (!privateItem->parentItem) + QQuickWindowPrivate::get(privateItem->window)->parentlessItems.remove(quickWindow->contentItem()); + privateItem->derefWindow(); + privateItem->window = 0; + } + + return instance; +} + +void QuickWindowNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance) +{ + if (instanceId() == 0) { + DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem()); + } else { + quickItem()->setParentItem(qobject_cast(nodeInstanceServer()->quickView()->rootObject())); + } + + if (s_createEffectItem || instanceId() == 0) + designerSupport()->refFromEffectItem(quickItem()); + + ObjectNodeInstance::initialize(objectNodeInstance); + quickItem()->update(); +} + +bool QuickWindowNodeInstance::isQuickItem() const +{ + return true; +} + +QSizeF QuickWindowNodeInstance::size() const +{ + double width; + + if (DesignerSupport::isValidWidth(quickItem())) { + width = quickItem()->width(); + } else { + width = quickItem()->implicitWidth(); + } + + double height; + + if (DesignerSupport::isValidHeight(quickItem())) { + height = quickItem()->height(); + } else { + height = quickItem()->implicitHeight(); + } + + + return QSizeF(width, height); +} + +static inline bool isRectangleSane(const QRectF &rect) +{ + return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); +} + +QRectF QuickWindowNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const +{ + QRectF boundingRect = parentItem->boundingRect(); + + foreach (QQuickItem *childItem, parentItem->childItems()) { + if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { + QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); + if (isRectangleSane(transformedRect)) + boundingRect = boundingRect.united(transformedRect); + } + } + + return boundingRect; +} + +QRectF QuickWindowNodeInstance::boundingRect() const +{ + if (quickItem()) { + if (quickItem()->clip()) { + return quickItem()->boundingRect(); + } else { + return boundingRectWithStepChilds(quickItem()); + } + } + + return QRectF(); +} + +void QuickWindowNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) +{ + if (name == "state") + return; // states are only set by us + + if (name == "height") { + m_height = value.toDouble(); + if (value.isValid()) + m_hasHeight = true; + else + m_hasHeight = false; + } + + if (name == "width") { + m_width = value.toDouble(); + if (value.isValid()) + m_hasWidth = true; + else + m_hasWidth = false; + } + + if (name == "x") + m_x = value.toDouble(); + + if (name == "y") + m_y = value.toDouble(); + + ObjectNodeInstance::setPropertyVariant(name, value); + + quickItem()->update(); +} + +void QuickWindowNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) +{ + if (name == "state") + return; // states are only set by us + + ObjectNodeInstance::setPropertyBinding(name, expression); + + quickItem()->update(); +} + +QVariant QuickWindowNodeInstance::property(const PropertyName &name) const +{ + if (name == "visible") + return quickItem()->isVisible(); + return ObjectNodeInstance::property(name); +} + +void QuickWindowNodeInstance::resetHorizontal() + { + setPropertyVariant("x", m_x); + if (m_width > 0.0) { + setPropertyVariant("width", m_width); + } else { + setPropertyVariant("width", quickItem()->implicitWidth()); + } +} + +void QuickWindowNodeInstance::resetVertical() + { + setPropertyVariant("y", m_y); + if (m_height > 0.0) { + setPropertyVariant("height", m_height); + } else { + setPropertyVariant("height", quickItem()->implicitWidth()); + } +} + +static void doComponentCompleteRecursive(QQuickItem *item) +{ + if (item) { + if (DesignerSupport::isComponentComplete(item)) + return; + + foreach (QQuickItem *childItem, item->childItems()) + doComponentCompleteRecursive(childItem); + + static_cast(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) +{ + ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); + + 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 QuickWindowNodeInstance::anchor(const PropertyName &name) const +{ + if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name)) + return ObjectNodeInstance::anchor(name); + + QPair 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 QuickWindowNodeInstance::stateInstances() const +{ + QList instanceList; + QList stateList = DesignerSupport::statesForItem(quickItem()); + foreach (QObject *state, stateList) + { + if (state && nodeInstanceServer()->hasInstanceForObject(state)) + instanceList.append(nodeInstanceServer()->instanceForObject(state)); + } + + return instanceList; +} + +bool QuickWindowNodeInstance::isAnchoredBySibling() const +{ + return false; +} + +bool QuickWindowNodeInstance::isAnchoredByChildren() const +{ + if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item + return true; + + return false; +} + +QQuickItem *QuickWindowNodeInstance::quickItem() const +{ + if (object() == 0) + return 0; + + Q_ASSERT(qobject_cast(object())); + return static_cast(object())->contentItem(); +} + +DesignerSupport *QuickWindowNodeInstance::designerSupport() const +{ + return qt5NodeInstanceServer()->designerSupport(); +} + +Qt5NodeInstanceServer *QuickWindowNodeInstance::qt5NodeInstanceServer() const +{ + return qobject_cast(nodeInstanceServer()); +} + +void QuickWindowNodeInstance::createEffectItem(bool createEffectItem) +{ + s_createEffectItem = createEffectItem; +} + +void QuickWindowNodeInstance::updateDirtyNodeRecursive() +{ + foreach (QQuickItem *childItem, quickItem()->childItems()) + updateDirtyNodeRecursive(childItem); + + DesignerSupport::updateDirtyNode(quickItem()); +} + +} // namespace Internal +} // namespace QmlDesigner + diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h new file mode 100644 index 00000000000..31d2a1fdfa9 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickwindownodeinstance.h @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** 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 QUICKWINDOWNODEINSTANCE_H +#define QUICKWINDOWNODEINSTANCE_H + +#include + +#include "objectnodeinstance.h" + +#include +#include + +namespace QmlDesigner { +namespace Internal { + +class QuickWindowNodeInstance : public ObjectNodeInstance +{ +public: + typedef QSharedPointer Pointer; + typedef QWeakPointer WeakPointer; + + ~QuickWindowNodeInstance(); + + static Pointer create(QObject *objectToBeWrapped); + void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance); + + bool isQuickItem() const Q_DECL_OVERRIDE; + + QRectF boundingRect() const Q_DECL_OVERRIDE; + QPointF position() const Q_DECL_OVERRIDE; + QSizeF size() const Q_DECL_OVERRIDE; + QTransform transform() const Q_DECL_OVERRIDE; + QTransform customTransform() const Q_DECL_OVERRIDE; + QTransform sceneTransform() const Q_DECL_OVERRIDE; + double opacity() const Q_DECL_OVERRIDE; + + 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 childItems() const Q_DECL_OVERRIDE; + QList childItemsForChild(QQuickItem *childItem) const Q_DECL_OVERRIDE; + + bool isMovable() const Q_DECL_OVERRIDE; + + void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE; + void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE; + + QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE; + void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE; + + void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, + const PropertyName &oldParentProperty, + const ObjectNodeInstance::Pointer &newParentInstance, + const PropertyName &newParentProperty) Q_DECL_OVERRIDE; + + int penWidth() const Q_DECL_OVERRIDE; + + bool hasAnchor(const PropertyName &name) const Q_DECL_OVERRIDE; + QPair anchor(const PropertyName &name) const Q_DECL_OVERRIDE; + bool isAnchoredBySibling() const Q_DECL_OVERRIDE; + bool isAnchoredByChildren() const Q_DECL_OVERRIDE; + void doComponentComplete() Q_DECL_OVERRIDE; + + bool isResizable() const Q_DECL_OVERRIDE; + + void setHasContent(bool hasContent); + + QList stateInstances() const Q_DECL_OVERRIDE; + + QImage renderImage() const Q_DECL_OVERRIDE; + QImage renderPreviewImage(const QSize &previewImageSize) const Q_DECL_OVERRIDE; + + DesignerSupport *designerSupport() const; + Qt5NodeInstanceServer *qt5NodeInstanceServer() const; + + static void createEffectItem(bool createEffectItem); + + void updateDirtyNodeRecursive() Q_DECL_OVERRIDE; + +protected: + QuickWindowNodeInstance(QQuickWindow*); + QQuickItem *quickItem() const; + void resetHorizontal(); + void resetVertical(); + QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; + void updateDirtyNodeRecursive(QQuickItem *parentItem) const; + static bool anyItemHasContent(QQuickItem *graphicsItem); + static bool childItemsHaveContent(QQuickItem *graphicsItem); + +private: //variables + bool m_hasHeight; + bool m_hasWidth; + bool m_hasContent; + double m_x; + double m_y; + double m_width; + double m_height; + static bool s_createEffectItem; +}; + +} // namespace Internal +} // namespace QmlDesigner + +#endif // QUICKWINDOWNODEINSTANCE_H + diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp index b4bbf5cfc28..4bddcf1a8cb 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp @@ -40,6 +40,7 @@ #include "debugoutputcommand.h" #include "quickitemnodeinstance.h" +#include "quickwindownodeinstance.h" #include "nodeinstanceserver.h" #include "instancecontainer.h" @@ -194,6 +195,8 @@ Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject instance = Internal::QmlTransitionNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QQuickBehavior")) instance = Internal::BehaviorNodeInstance::create(objectToBeWrapped); + else if (isSubclassOf(objectToBeWrapped, "QQuickWindow")) + instance = Internal::QuickWindowNodeInstance::create(objectToBeWrapped); else if (isSubclassOf(objectToBeWrapped, "QObject")) instance = Internal::ObjectNodeInstance::create(objectToBeWrapped); else From de7a4818a938162bc672f4145dc08800b3725918 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 17 Apr 2013 12:37:17 +0200 Subject: [PATCH 7/8] QmlDesigner: Make the taking of ownership clean for the register functions Change-Id: Ibb9b054f49a04be65d16e8a55c45ee6524d39729 Reviewed-by: Thomas Hartmann --- src/plugins/qmldesigner/designercore/include/viewmanager.h | 4 ++-- src/plugins/qmldesigner/designercore/model/viewmanager.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmldesigner/designercore/include/viewmanager.h b/src/plugins/qmldesigner/designercore/include/viewmanager.h index a238692594d..70f353a80b8 100644 --- a/src/plugins/qmldesigner/designercore/include/viewmanager.h +++ b/src/plugins/qmldesigner/designercore/include/viewmanager.h @@ -71,8 +71,8 @@ public: void resetPropertyEditorView(); - void registerFormEditorTool(AbstractCustomTool *tool); // takes ownership - void registerView(AbstractView *view); + void registerFormEditorToolTakingOwnership(AbstractCustomTool *tool); + void registerViewTakingOwnership(AbstractView *view); QList widgetInfos(); diff --git a/src/plugins/qmldesigner/designercore/model/viewmanager.cpp b/src/plugins/qmldesigner/designercore/model/viewmanager.cpp index a5dcc37d580..b09e4d9bf41 100644 --- a/src/plugins/qmldesigner/designercore/model/viewmanager.cpp +++ b/src/plugins/qmldesigner/designercore/model/viewmanager.cpp @@ -89,12 +89,12 @@ void ViewManager::resetPropertyEditorView() m_propertyEditorView.resetView(); } -void ViewManager::registerFormEditorTool(AbstractCustomTool *tool) +void ViewManager::registerFormEditorToolTakingOwnership(AbstractCustomTool *tool) { m_formEditorView.registerTool(tool); } -void ViewManager::registerView(AbstractView *view) +void ViewManager::registerViewTakingOwnership(AbstractView *view) { m_additionalViews.append(view); } From 4647cb77d30e0a991faea197e8eba4fcec0d27a9 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 18 Apr 2013 11:35:23 +0200 Subject: [PATCH 8/8] Fix building treeviewfind test. Change-Id: If4211acb37cb3c87a901ebf3da030bd1da3cf99c Reviewed-by: Aurindam Jana Reviewed-by: Christian Stenger --- tests/auto/treeviewfind/treeviewfind.pro | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/auto/treeviewfind/treeviewfind.pro b/tests/auto/treeviewfind/treeviewfind.pro index 00aa98ae5d2..f2f6250a15e 100644 --- a/tests/auto/treeviewfind/treeviewfind.pro +++ b/tests/auto/treeviewfind/treeviewfind.pro @@ -1,8 +1,7 @@ +QTC_PLUGIN_DEPENDS += find include(../qttest.pri) -include($$IDE_SOURCE_TREE/src/plugins/find/find.pri) - -LIBS *= -L$$IDE_LIBRARY_PATH/QtProject +LIBS *= -L$$IDE_PLUGIN_PATH/QtProject SOURCES += \ tst_treeviewfind.cpp