forked from qt-creator/qt-creator
QmlDesigner: Enable rendering of DesignerEffects
* Effects are items and we have to use __effect/source and allEffects to idenfify them and get the correct bounding rectangle. * For now we use a custom parser to work around issues when editig the model Change-Id: I78690498c44f8285d3bb6ce78eafcafb9c26b2f1 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -2444,12 +2444,12 @@ bool NodeMetaInfo::usesCustomParser() const
|
|||||||
if (!isValid())
|
if (!isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto type = typeName();
|
auto type = simplifiedTypeName();
|
||||||
return type == "QtQuick.VisualItemModel" || type == "Qt.VisualItemModel"
|
return type == "VisualItemModel"
|
||||||
|| type == "QtQuick.VisualDataModel" || type == "Qt.VisualDataModel"
|
|| type == "VisualDataModel"
|
||||||
|| type == "QtQuick.ListModel" || type == "Qt.ListModel"
|
|| type == "ListModel"
|
||||||
|| type == "QtQml.Models.ListModel" || type == "QtQuick.XmlListModel"
|
|| type == "XmlListModel"
|
||||||
|| type == "Qt.XmlListModel" || type == "QtQml.XmlListModel.XmlListModel";
|
|| type == "DesignEffect";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -436,10 +436,18 @@ QQuickItem *Qt5NodeInstanceServer::parentEffectItem(QQuickItem *item)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isEffectItem(QQuickItem *item, QQuickShaderEffectSource *sourceItem)
|
static bool isEffectItem(QQuickItem *item, QQuickShaderEffectSource *sourceItem, QQuickItem *target)
|
||||||
{
|
{
|
||||||
QQuickItemPrivate *pItem = QQuickItemPrivate::get(sourceItem);
|
QQuickItemPrivate *pItem = QQuickItemPrivate::get(sourceItem);
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
QQmlProperty prop(item, "__effect");
|
||||||
|
if (prop.read().toBool()) {
|
||||||
|
prop = QQmlProperty(item, "source");
|
||||||
|
return prop.read().value<QQuickItem *>() == target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pItem || !pItem->layer())
|
if (!pItem || !pItem->layer())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -477,7 +485,7 @@ QImage Qt5NodeInstanceServer::grabItem([[maybe_unused]] QQuickItem *item)
|
|||||||
if (auto parent = item->parentItem()) {
|
if (auto parent = item->parentItem()) {
|
||||||
const auto siblings = parent->childItems();
|
const auto siblings = parent->childItems();
|
||||||
for (auto sibling : siblings) {
|
for (auto sibling : siblings) {
|
||||||
if (isEffectItem(sibling, pItem->layer()->effectSource()))
|
if (isEffectItem(sibling, pItem->layer()->effectSource(), item))
|
||||||
return grabItem(sibling);
|
return grabItem(sibling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,10 +120,20 @@ QRectF ServerNodeInstance::effectAdjustedBoundingRect(QQuickItem *item)
|
|||||||
{
|
{
|
||||||
if (item) {
|
if (item) {
|
||||||
QQuickItemPrivate *pItem = QQuickItemPrivate::get(item);
|
QQuickItemPrivate *pItem = QQuickItemPrivate::get(item);
|
||||||
if (pItem && pItem->layer() && pItem->layer()->sourceRect().isValid())
|
|
||||||
|
QQmlProperty prop(item, "__effect");
|
||||||
|
|
||||||
|
if (pItem && pItem->layer() && pItem->layer()->sourceRect().isValid()) {
|
||||||
return pItem->layer()->sourceRect();
|
return pItem->layer()->sourceRect();
|
||||||
else
|
} else if (prop.read().toBool()) {
|
||||||
|
prop = QQmlProperty(item, "allEffects");
|
||||||
|
QRectF rect = prop.read().toRectF().adjusted(-20, -20, 20, 20);
|
||||||
|
if (rect.isValid())
|
||||||
|
return rect;
|
||||||
return item->boundingRect();
|
return item->boundingRect();
|
||||||
|
} else {
|
||||||
|
return item->boundingRect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user