diff options
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index ab38b33aaf..33bc2ee156 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -28,6 +28,9 @@ #include <qmlprivategate.h> +#include <QtQuick/private/qquickitem_p.h> +#include <QtQuick/private/qquickshadereffectsource_p.h> + #include <QQmlProperty> #include <QQmlExpression> #include <QQuickView> @@ -476,11 +479,12 @@ QImage QuickItemNodeInstance::renderImage() const } renderImage.setDevicePixelRatio(devicePixelRatio); #else - if (s_unifiedRenderPath) + if (s_unifiedRenderPath) { renderImage = nodeInstanceServer()->grabWindow(); - else + renderImage = renderImage.copy(renderBoundingRect.toRect()); + } else { renderImage = nodeInstanceServer()->grabItem(quickItem()); - renderImage = renderImage.copy(renderBoundingRect.toRect()); + } /* When grabbing an offscren window the device pixel ratio is 1 */ renderImage.setDevicePixelRatio(1); @@ -613,6 +617,34 @@ static inline bool isRectangleSane(const QRectF &rect) return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); } +static bool isEffectItem(QQuickItem *item) +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + Q_UNUSED(item) + return false; +#else + if (qobject_cast<QQuickShaderEffectSource *>(item)) + return true; + + const auto propName = "source"; + + QQmlProperty prop(item, QString::fromLatin1(propName)); + if (!prop.isValid()) + return false; + + QQuickShaderEffectSource *source = prop.read().value<QQuickShaderEffectSource *>(); + + if (source && source->sourceItem()) { + QQuickItemPrivate *pItem = QQuickItemPrivate::get(source->sourceItem()); + + if (pItem && pItem->layer() && pItem->layer()->enabled() && pItem->layer()->effect()) + return true; + } + + return false; +#endif +} + QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const { QRectF boundingRect = parentItem->boundingRect(); @@ -620,8 +652,9 @@ QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) boundingRect = boundingRect.united(QRectF(QPointF(0, 0), size())); for (QQuickItem *childItem : parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem)); + if (!nodeInstanceServer()->hasInstanceForObject(childItem) && !isEffectItem(childItem)) { + QRectF transformedRect = childItem->mapRectToItem(parentItem, + boundingRectWithStepChilds(childItem)); if (isRectangleSane(transformedRect)) boundingRect = boundingRect.united(transformedRect); } |