forked from qt-creator/qt-creator
QmlDesigner: Rename "Effect" to "Item" in the content library
Item includes any item except materials and textures Change-Id: Icf981661dcd611638fe33fae18f65ad62a5e617c Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -91,7 +91,7 @@ HelperWidgets.ScrollView {
|
||||
id: repeater
|
||||
model: bundleCategoryItems
|
||||
|
||||
delegate: ContentLibraryEffect {
|
||||
delegate: ContentLibraryItem {
|
||||
width: root.cellWidth
|
||||
height: root.cellHeight
|
||||
|
||||
|
@@ -24,7 +24,7 @@ Item {
|
||||
|
||||
onPressed: (mouse) => {
|
||||
if (mouse.button === Qt.LeftButton && !ContentLibraryBackend.rootView.importerRunning)
|
||||
ContentLibraryBackend.rootView.startDragEffect(modelData, mapToGlobal(mouse.x, mouse.y))
|
||||
ContentLibraryBackend.rootView.startDragItem(modelData, mapToGlobal(mouse.x, mouse.y))
|
||||
else if (mouse.button === Qt.RightButton)
|
||||
root.showContextMenu()
|
||||
}
|
||||
@@ -43,7 +43,7 @@ Item {
|
||||
source: modelData.bundleItemIcon
|
||||
cache: false
|
||||
|
||||
Rectangle { // circular indicator for imported bundle effect
|
||||
Rectangle { // circular indicator for imported bundle item
|
||||
width: 10
|
||||
height: 10
|
||||
radius: 5
|
||||
@@ -57,7 +57,7 @@ Item {
|
||||
|
||||
ToolTip {
|
||||
visible: indicatorMouseArea.containsMouse
|
||||
text: qsTr("Effect is imported to project")
|
||||
text: qsTr("Item is imported to the project")
|
||||
delay: 1000
|
||||
}
|
||||
|
@@ -135,7 +135,7 @@ HelperWidgets.ScrollView {
|
||||
}
|
||||
DelegateChoice {
|
||||
roleValue: "item"
|
||||
delegate: ContentLibraryEffect {
|
||||
delegate: ContentLibraryItem {
|
||||
width: root.cellWidth
|
||||
height: root.cellHeight
|
||||
|
||||
|
@@ -830,7 +830,7 @@ extend_qtc_plugin(QmlDesigner
|
||||
contentlibrarymaterialscategory.cpp contentlibrarymaterialscategory.h
|
||||
contentlibrarymaterial.cpp contentlibrarymaterial.h
|
||||
contentlibraryiconprovider.cpp contentlibraryiconprovider.h
|
||||
contentlibraryeffect.cpp contentlibraryeffect.h
|
||||
contentlibraryitem.cpp contentlibraryitem.h
|
||||
contentlibraryeffectscategory.cpp contentlibraryeffectscategory.h
|
||||
contentlibraryeffectsmodel.cpp contentlibraryeffectsmodel.h
|
||||
contentlibraryusermodel.cpp contentlibraryusermodel.h
|
||||
|
@@ -3,14 +3,12 @@
|
||||
|
||||
#include "contentlibraryeffectscategory.h"
|
||||
|
||||
#include "contentlibraryeffect.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ContentLibraryEffectsCategory::ContentLibraryEffectsCategory(QObject *parent, const QString &name)
|
||||
: QObject(parent), m_name(name) {}
|
||||
|
||||
void ContentLibraryEffectsCategory::addBundleItem(ContentLibraryEffect *bundleItem)
|
||||
void ContentLibraryEffectsCategory::addBundleItem(ContentLibraryItem *bundleItem)
|
||||
{
|
||||
m_categoryItems.append(bundleItem);
|
||||
}
|
||||
@@ -19,7 +17,7 @@ bool ContentLibraryEffectsCategory::updateImportedState(const QStringList &impor
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
for (ContentLibraryEffect *item : std::as_const(m_categoryItems))
|
||||
for (ContentLibraryItem *item : std::as_const(m_categoryItems))
|
||||
changed |= item->setImported(importedItems.contains(item->qml().chopped(4)));
|
||||
|
||||
return changed;
|
||||
@@ -28,7 +26,7 @@ bool ContentLibraryEffectsCategory::updateImportedState(const QStringList &impor
|
||||
bool ContentLibraryEffectsCategory::filter(const QString &searchText)
|
||||
{
|
||||
bool visible = false;
|
||||
for (ContentLibraryEffect *item : std::as_const(m_categoryItems))
|
||||
for (ContentLibraryItem *item : std::as_const(m_categoryItems))
|
||||
visible |= item->filter(searchText);
|
||||
|
||||
if (visible != m_visible) {
|
||||
@@ -55,7 +53,7 @@ bool ContentLibraryEffectsCategory::expanded() const
|
||||
return m_expanded;
|
||||
}
|
||||
|
||||
QList<ContentLibraryEffect *> ContentLibraryEffectsCategory::categoryItems() const
|
||||
QList<ContentLibraryItem *> ContentLibraryEffectsCategory::categoryItems() const
|
||||
{
|
||||
return m_categoryItems;
|
||||
}
|
||||
|
@@ -3,12 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "contentlibraryitem.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryEffect;
|
||||
|
||||
class ContentLibraryEffectsCategory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -16,20 +16,20 @@ class ContentLibraryEffectsCategory : public QObject
|
||||
Q_PROPERTY(QString bundleCategoryName MEMBER m_name CONSTANT)
|
||||
Q_PROPERTY(bool bundleCategoryVisible MEMBER m_visible NOTIFY categoryVisibleChanged)
|
||||
Q_PROPERTY(bool bundleCategoryExpanded MEMBER m_expanded NOTIFY categoryExpandChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryEffect *> bundleCategoryItems MEMBER m_categoryItems
|
||||
Q_PROPERTY(QList<ContentLibraryItem *> bundleCategoryItems MEMBER m_categoryItems
|
||||
NOTIFY categoryItemsChanged)
|
||||
|
||||
public:
|
||||
ContentLibraryEffectsCategory(QObject *parent, const QString &name);
|
||||
|
||||
void addBundleItem(ContentLibraryEffect *bundleItem);
|
||||
void addBundleItem(ContentLibraryItem *bundleItem);
|
||||
bool updateImportedState(const QStringList &importedMats);
|
||||
bool filter(const QString &searchText);
|
||||
|
||||
QString name() const;
|
||||
bool visible() const;
|
||||
bool expanded() const;
|
||||
QList<ContentLibraryEffect *> categoryItems() const;
|
||||
QList<ContentLibraryItem *> categoryItems() const;
|
||||
|
||||
signals:
|
||||
void categoryVisibleChanged();
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
bool m_visible = true;
|
||||
bool m_expanded = true;
|
||||
|
||||
QList<ContentLibraryEffect *> m_categoryItems;
|
||||
QList<ContentLibraryItem *> m_categoryItems;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -4,8 +4,8 @@
|
||||
#include "contentlibraryeffectsmodel.h"
|
||||
|
||||
#include "contentlibrarybundleimporter.h"
|
||||
#include "contentlibraryeffect.h"
|
||||
#include "contentlibraryeffectscategory.h"
|
||||
#include "contentlibraryitem.h"
|
||||
#include "contentlibrarywidget.h"
|
||||
|
||||
#include <qmldesignerplugin.h>
|
||||
@@ -171,7 +171,7 @@ void ContentLibraryEffectsModel::loadBundle()
|
||||
TypeName type = QLatin1String("%1.%2")
|
||||
.arg(bundleType, qml.chopped(4)).toLatin1(); // chopped(4): remove .qml
|
||||
|
||||
auto bundleItem = new ContentLibraryEffect(category, itemName, qml, type, icon, files);
|
||||
auto bundleItem = new ContentLibraryItem(category, itemName, qml, type, icon, files);
|
||||
|
||||
category->addBundleItem(bundleItem);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ void ContentLibraryEffectsModel::resetModel()
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void ContentLibraryEffectsModel::addInstance(ContentLibraryEffect *bundleItem)
|
||||
void ContentLibraryEffectsModel::addInstance(ContentLibraryItem *bundleItem)
|
||||
{
|
||||
QString err = m_widget->importer()->importComponent(m_bundlePath, bundleItem->type(),
|
||||
bundleItem->qml(),
|
||||
@@ -263,7 +263,7 @@ void ContentLibraryEffectsModel::addInstance(ContentLibraryEffect *bundleItem)
|
||||
qWarning() << __FUNCTION__ << err;
|
||||
}
|
||||
|
||||
void ContentLibraryEffectsModel::removeFromProject(ContentLibraryEffect *bundleItem)
|
||||
void ContentLibraryEffectsModel::removeFromProject(ContentLibraryItem *bundleItem)
|
||||
{
|
||||
QString err = m_widget->importer()->unimportComponent(bundleItem->type(), bundleItem->qml());
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryEffect;
|
||||
class ContentLibraryItem;
|
||||
class ContentLibraryEffectsCategory;
|
||||
class ContentLibraryWidget;
|
||||
|
||||
@@ -41,8 +41,8 @@ public:
|
||||
void resetModel();
|
||||
void updateIsEmpty();
|
||||
|
||||
Q_INVOKABLE void addInstance(QmlDesigner::ContentLibraryEffect *bundleItem);
|
||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryEffect *bundleItem);
|
||||
Q_INVOKABLE void addInstance(QmlDesigner::ContentLibraryItem *bundleItem);
|
||||
Q_INVOKABLE void removeFromProject(QmlDesigner::ContentLibraryItem *bundleItem);
|
||||
|
||||
QString bundleId() const;
|
||||
|
||||
|
@@ -1,23 +1,23 @@
|
||||
// Copyright (C) 2023 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "contentlibraryeffect.h"
|
||||
#include "contentlibraryitem.h"
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
ContentLibraryEffect::ContentLibraryEffect(QObject *parent,
|
||||
const QString &name,
|
||||
const QString &qml,
|
||||
const TypeName &type,
|
||||
const QUrl &icon,
|
||||
const QStringList &files)
|
||||
ContentLibraryItem::ContentLibraryItem(QObject *parent,
|
||||
const QString &name,
|
||||
const QString &qml,
|
||||
const TypeName &type,
|
||||
const QUrl &icon,
|
||||
const QStringList &files)
|
||||
: QObject(parent), m_name(name), m_qml(qml), m_type(type), m_icon(icon), m_files(files)
|
||||
{
|
||||
m_allFiles = m_files;
|
||||
m_allFiles.push_back(m_qml);
|
||||
}
|
||||
|
||||
bool ContentLibraryEffect::filter(const QString &searchText)
|
||||
bool ContentLibraryItem::filter(const QString &searchText)
|
||||
{
|
||||
if (m_visible != m_name.contains(searchText, Qt::CaseInsensitive)) {
|
||||
m_visible = !m_visible;
|
||||
@@ -27,32 +27,32 @@ bool ContentLibraryEffect::filter(const QString &searchText)
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
QUrl ContentLibraryEffect::icon() const
|
||||
QUrl ContentLibraryItem::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
QString ContentLibraryEffect::qml() const
|
||||
QString ContentLibraryItem::qml() const
|
||||
{
|
||||
return m_qml;
|
||||
}
|
||||
|
||||
TypeName ContentLibraryEffect::type() const
|
||||
TypeName ContentLibraryItem::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QStringList ContentLibraryEffect::files() const
|
||||
QStringList ContentLibraryItem::files() const
|
||||
{
|
||||
return m_files;
|
||||
}
|
||||
|
||||
bool ContentLibraryEffect::visible() const
|
||||
bool ContentLibraryItem::visible() const
|
||||
{
|
||||
return m_visible;
|
||||
}
|
||||
|
||||
bool ContentLibraryEffect::setImported(bool imported)
|
||||
bool ContentLibraryItem::setImported(bool imported)
|
||||
{
|
||||
if (m_imported != imported) {
|
||||
m_imported = imported;
|
||||
@@ -63,12 +63,12 @@ bool ContentLibraryEffect::setImported(bool imported)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContentLibraryEffect::imported() const
|
||||
bool ContentLibraryItem::imported() const
|
||||
{
|
||||
return m_imported;
|
||||
}
|
||||
|
||||
QStringList ContentLibraryEffect::allFiles() const
|
||||
QStringList ContentLibraryItem::allFiles() const
|
||||
{
|
||||
return m_allFiles;
|
||||
}
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryEffect : public QObject
|
||||
class ContentLibraryItem : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -22,12 +22,12 @@ class ContentLibraryEffect : public QObject
|
||||
Q_PROPERTY(QString itemType MEMBER m_itemType CONSTANT)
|
||||
|
||||
public:
|
||||
ContentLibraryEffect(QObject *parent,
|
||||
const QString &name,
|
||||
const QString &qml,
|
||||
const TypeName &type,
|
||||
const QUrl &icon,
|
||||
const QStringList &files);
|
||||
ContentLibraryItem(QObject *parent,
|
||||
const QString &name,
|
||||
const QString &qml,
|
||||
const TypeName &type,
|
||||
const QUrl &icon,
|
||||
const QStringList &files);
|
||||
|
||||
bool filter(const QString &searchText);
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include "contentlibraryusermodel.h"
|
||||
|
||||
#include "contentlibrarybundleimporter.h"
|
||||
#include "contentlibraryeffect.h"
|
||||
#include "contentlibraryitem.h"
|
||||
#include "contentlibrarymaterial.h"
|
||||
#include "contentlibrarymaterialscategory.h"
|
||||
#include "contentlibrarytexture.h"
|
||||
@@ -82,7 +82,7 @@ void ContentLibraryUserModel::updateIsEmptyMaterials()
|
||||
|
||||
void ContentLibraryUserModel::updateIsEmpty3D()
|
||||
{
|
||||
bool anyItemVisible = Utils::anyOf(m_user3DItems, [&](ContentLibraryEffect *item) {
|
||||
bool anyItemVisible = Utils::anyOf(m_user3DItems, [&](ContentLibraryItem *item) {
|
||||
return item->visible();
|
||||
});
|
||||
|
||||
@@ -90,7 +90,7 @@ void ContentLibraryUserModel::updateIsEmpty3D()
|
||||
|
||||
if (newEmpty != m_isEmpty3D) {
|
||||
m_isEmpty3D = newEmpty;
|
||||
emit isEmptyMaterialsChanged();
|
||||
emit isEmpty3DChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void ContentLibraryUserModel::addTextures(const QStringList &paths)
|
||||
emit dataChanged(index(texSectionIdx), index(texSectionIdx));
|
||||
}
|
||||
|
||||
void ContentLibraryUserModel::add3DInstance(ContentLibraryEffect *bundleItem)
|
||||
void ContentLibraryUserModel::add3DInstance(ContentLibraryItem *bundleItem)
|
||||
{
|
||||
QString err = m_widget->importer()->importComponent(m_bundlePath3D.path(), bundleItem->type(),
|
||||
bundleItem->qml(),
|
||||
@@ -408,7 +408,7 @@ void ContentLibraryUserModel::load3DBundle()
|
||||
QString qml = itemObj.value("qml").toString();
|
||||
TypeName type = QLatin1String("%1.%2").arg(typePrefix, qml.chopped(4)).toLatin1();
|
||||
|
||||
auto bundleItem = new ContentLibraryEffect(nullptr, itemName, qml, type, icon, files);
|
||||
auto bundleItem = new ContentLibraryItem(nullptr, itemName, qml, type, icon, files);
|
||||
|
||||
m_user3DItems.append(bundleItem);
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ QT_FORWARD_DECLARE_CLASS(QUrl)
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryEffect;
|
||||
class ContentLibraryItem;
|
||||
class ContentLibraryMaterial;
|
||||
class ContentLibraryTexture;
|
||||
class ContentLibraryWidget;
|
||||
@@ -30,8 +30,8 @@ class ContentLibraryUserModel : public QAbstractListModel
|
||||
Q_PROPERTY(bool hasModelSelection READ hasModelSelection NOTIFY hasModelSelectionChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryMaterial *> userMaterials MEMBER m_userMaterials NOTIFY userMaterialsChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryTexture *> userTextures MEMBER m_userTextures NOTIFY userTexturesChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryEffect *> user3DItems MEMBER m_user3DItems NOTIFY user3DItemsChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryEffect *> userEffects MEMBER m_userEffects NOTIFY userEffectsChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryItem *> user3DItems MEMBER m_user3DItems NOTIFY user3DItemsChanged)
|
||||
Q_PROPERTY(QList<ContentLibraryItem *> userEffects MEMBER m_userEffects NOTIFY userEffectsChanged)
|
||||
|
||||
public:
|
||||
ContentLibraryUserModel(ContentLibraryWidget *parent = nullptr);
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void addMaterial(const QString &name, const QString &qml, const QUrl &icon, const QStringList &files);
|
||||
void addTextures(const QStringList &paths);
|
||||
|
||||
void add3DInstance(ContentLibraryEffect *bundleItem);
|
||||
void add3DInstance(ContentLibraryItem *bundleItem);
|
||||
|
||||
void setBundleObj(const QJsonObject &newBundleObj);
|
||||
QJsonObject &bundleJsonObjectRef();
|
||||
@@ -86,7 +86,6 @@ signals:
|
||||
|
||||
void applyToSelectedTriggered(QmlDesigner::ContentLibraryMaterial *mat, bool add = false);
|
||||
|
||||
|
||||
void matBundleExistsChanged();
|
||||
void bundle3DExistsChanged();
|
||||
|
||||
@@ -106,8 +105,8 @@ private:
|
||||
|
||||
QList<ContentLibraryMaterial *> m_userMaterials;
|
||||
QList<ContentLibraryTexture *> m_userTextures;
|
||||
QList<ContentLibraryEffect *> m_userEffects;
|
||||
QList<ContentLibraryEffect *> m_user3DItems;
|
||||
QList<ContentLibraryItem *> m_userEffects;
|
||||
QList<ContentLibraryItem *> m_user3DItems;
|
||||
QStringList m_userCategories;
|
||||
|
||||
QJsonObject m_bundleObjMaterial;
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#include "contentlibraryview.h"
|
||||
|
||||
#include "contentlibrarybundleimporter.h"
|
||||
#include "contentlibraryeffect.h"
|
||||
#include "contentlibraryitem.h"
|
||||
#include "contentlibraryeffectsmodel.h"
|
||||
#include "contentlibrarymaterial.h"
|
||||
#include "contentlibrarymaterialsmodel.h"
|
||||
@@ -70,9 +70,9 @@ WidgetInfo ContentLibraryView::widgetInfo()
|
||||
[&] (QmlDesigner::ContentLibraryTexture *tex) {
|
||||
m_draggedBundleTexture = tex;
|
||||
});
|
||||
connect(m_widget, &ContentLibraryWidget::bundleEffectDragStarted, this,
|
||||
[&] (QmlDesigner::ContentLibraryEffect *eff) {
|
||||
m_draggedBundleEffect = eff;
|
||||
connect(m_widget, &ContentLibraryWidget::bundleItemDragStarted, this,
|
||||
[&] (QmlDesigner::ContentLibraryItem *item) {
|
||||
m_draggedBundleItem = item;
|
||||
});
|
||||
|
||||
connect(m_widget, &ContentLibraryWidget::addTextureRequested, this,
|
||||
@@ -143,23 +143,23 @@ void ContentLibraryView::connectImporter()
|
||||
QTC_ASSERT(typeName.size(), return);
|
||||
if (isMaterialBundle(bundleId)) {
|
||||
applyBundleMaterialToDropTarget({}, typeName);
|
||||
} else if (isEffectBundle(bundleId)) {
|
||||
if (!m_bundleEffectTarget)
|
||||
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
||||
} else if (isItemBundle(bundleId)) {
|
||||
if (!m_bundleItemTarget)
|
||||
m_bundleItemTarget = Utils3D::active3DSceneNode(this);
|
||||
|
||||
QTC_ASSERT(m_bundleEffectTarget, return);
|
||||
QTC_ASSERT(m_bundleItemTarget, return);
|
||||
|
||||
executeInTransaction("ContentLibraryView::widgetInfo", [&] {
|
||||
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
||||
ModelNode newEffNode = createModelNode(
|
||||
QVector3D pos = m_bundleItemPos.value<QVector3D>();
|
||||
ModelNode newNode = createModelNode(
|
||||
typeName, -1, -1, {{"x", pos.x()}, {"y", pos.y()}, {"z", pos.z()}});
|
||||
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
||||
m_bundleItemTarget.defaultNodeListProperty().reparentHere(newNode);
|
||||
clearSelectedModelNodes();
|
||||
selectModelNode(newEffNode);
|
||||
selectModelNode(newNode);
|
||||
});
|
||||
|
||||
m_bundleEffectTarget = {};
|
||||
m_bundleEffectPos = {};
|
||||
m_bundleItemTarget = {};
|
||||
m_bundleItemPos = {};
|
||||
}
|
||||
});
|
||||
#else
|
||||
@@ -170,27 +170,27 @@ void ContentLibraryView::connectImporter()
|
||||
QTC_ASSERT(metaInfo.isValid(), return);
|
||||
if (isMaterialBundle(bundleId)) {
|
||||
applyBundleMaterialToDropTarget({}, metaInfo);
|
||||
} else if (isEffectBundle(bundleId)) {
|
||||
if (!m_bundleEffectTarget)
|
||||
m_bundleEffectTarget = Utils3D::active3DSceneNode(this);
|
||||
} else if (isItemBundle(bundleId)) {
|
||||
if (!m_bundleItemTarget)
|
||||
m_bundleItemTarget = Utils3D::active3DSceneNode(this);
|
||||
|
||||
QTC_ASSERT(m_bundleEffectTarget, return);
|
||||
QTC_ASSERT(m_bundleItemTarget, return);
|
||||
|
||||
executeInTransaction("ContentLibraryView::connectImporter", [&] {
|
||||
QVector3D pos = m_bundleEffectPos.value<QVector3D>();
|
||||
ModelNode newEffNode = createModelNode(metaInfo.typeName(),
|
||||
QVector3D pos = m_bundleItemPos.value<QVector3D>();
|
||||
ModelNode newNode = createModelNode(metaInfo.typeName(),
|
||||
metaInfo.majorVersion(),
|
||||
metaInfo.minorVersion(),
|
||||
{{"x", pos.x()},
|
||||
{"y", pos.y()},
|
||||
{"z", pos.z()}});
|
||||
m_bundleEffectTarget.defaultNodeListProperty().reparentHere(newEffNode);
|
||||
m_bundleItemTarget.defaultNodeListProperty().reparentHere(newNode);
|
||||
clearSelectedModelNodes();
|
||||
selectModelNode(newEffNode);
|
||||
selectModelNode(newNode);
|
||||
});
|
||||
|
||||
m_bundleEffectTarget = {};
|
||||
m_bundleEffectPos = {};
|
||||
m_bundleItemTarget = {};
|
||||
m_bundleItemPos = {};
|
||||
}
|
||||
});
|
||||
#endif
|
||||
@@ -209,13 +209,13 @@ void ContentLibraryView::connectImporter()
|
||||
QmlObjectNode(mat).destroy();
|
||||
});
|
||||
});
|
||||
} else if (isEffectBundle(bundleId)) {
|
||||
// delete instances of the bundle effect that is about to be unimported
|
||||
} else if (isItemBundle(bundleId)) {
|
||||
// delete instances of the bundle item that is about to be unimported
|
||||
executeInTransaction("ContentLibraryView::connectImporter", [&] {
|
||||
NodeMetaInfo metaInfo = model()->metaInfo(type);
|
||||
QList<ModelNode> effects = allModelNodesOfType(metaInfo);
|
||||
for (ModelNode &eff : effects)
|
||||
eff.destroy();
|
||||
QList<ModelNode> nodes = allModelNodesOfType(metaInfo);
|
||||
for (ModelNode &node : nodes)
|
||||
node.destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -227,7 +227,8 @@ bool ContentLibraryView::isMaterialBundle(const QString &bundleId) const
|
||||
return bundleId == compUtils.materialsBundleId() || bundleId == compUtils.userMaterialsBundleId();
|
||||
}
|
||||
|
||||
bool ContentLibraryView::isEffectBundle(const QString &bundleId) const
|
||||
// item bundle includes effects and 3D components
|
||||
bool ContentLibraryView::isItemBundle(const QString &bundleId) const
|
||||
{
|
||||
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||
return bundleId == compUtils.effectsBundleId() || bundleId == compUtils.userEffectsBundleId()
|
||||
@@ -345,18 +346,18 @@ void ContentLibraryView::customNotification(const AbstractView *view,
|
||||
m_widget->addTexture(m_draggedBundleTexture);
|
||||
|
||||
m_draggedBundleTexture = nullptr;
|
||||
} else if (identifier == "drop_bundle_effect") {
|
||||
} else if (identifier == "drop_bundle_item") {
|
||||
QTC_ASSERT(nodeList.size() == 1, return);
|
||||
|
||||
auto compUtils = QmlDesignerPlugin::instance()->documentManager().generatedComponentUtils();
|
||||
bool is3D = m_draggedBundleEffect->type().startsWith(compUtils.user3DBundleType().toLatin1());
|
||||
bool is3D = m_draggedBundleItem->type().startsWith(compUtils.user3DBundleType().toLatin1());
|
||||
|
||||
m_bundleEffectPos = data.size() == 1 ? data.first() : QVariant();
|
||||
m_bundleItemPos = data.size() == 1 ? data.first() : QVariant();
|
||||
if (is3D)
|
||||
m_widget->userModel()->add3DInstance(m_draggedBundleEffect);
|
||||
m_widget->userModel()->add3DInstance(m_draggedBundleItem);
|
||||
else
|
||||
m_widget->effectsModel()->addInstance(m_draggedBundleEffect);
|
||||
m_bundleEffectTarget = nodeList.first() ? nodeList.first() : Utils3D::active3DSceneNode(this);
|
||||
m_widget->effectsModel()->addInstance(m_draggedBundleItem);
|
||||
m_bundleItemTarget = nodeList.first() ? nodeList.first() : Utils3D::active3DSceneNode(this);
|
||||
} else if (identifier == "add_material_to_content_lib") {
|
||||
QTC_ASSERT(nodeList.size() == 1 && data.size() == 1, return);
|
||||
|
||||
@@ -760,6 +761,7 @@ void ContentLibraryView::updateBundlesQuick3DVersion()
|
||||
#endif
|
||||
m_widget->materialsModel()->setQuick3DImportVersion(major, minor);
|
||||
m_widget->effectsModel()->setQuick3DImportVersion(major, minor);
|
||||
m_widget->userModel()->setQuick3DImportVersion(major, minor);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -14,7 +14,7 @@ QT_FORWARD_DECLARE_CLASS(QPixmap)
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryEffect;
|
||||
class ContentLibraryItem;
|
||||
class ContentLibraryMaterial;
|
||||
class ContentLibraryTexture;
|
||||
class ContentLibraryWidget;
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
private:
|
||||
void connectImporter();
|
||||
bool isMaterialBundle(const QString &bundleId) const;
|
||||
bool isEffectBundle(const QString &bundleId) const;
|
||||
bool isItemBundle(const QString &bundleId) const;
|
||||
void active3DSceneChanged(qint32 sceneId);
|
||||
void updateBundlesQuick3DVersion();
|
||||
void addLibMaterial(const ModelNode &mat, const QPixmap &icon);
|
||||
@@ -73,12 +73,12 @@ private:
|
||||
#endif
|
||||
QPointer<ContentLibraryWidget> m_widget;
|
||||
QList<ModelNode> m_bundleMaterialTargets;
|
||||
ModelNode m_bundleEffectTarget; // target of the dropped bundle effect
|
||||
QVariant m_bundleEffectPos; // pos of the dropped bundle effect
|
||||
ModelNode m_bundleItemTarget; // target of the dropped bundle item
|
||||
QVariant m_bundleItemPos; // pos of the dropped bundle item
|
||||
QList<ModelNode> m_selectedModels; // selected 3D model nodes
|
||||
ContentLibraryMaterial *m_draggedBundleMaterial = nullptr;
|
||||
ContentLibraryTexture *m_draggedBundleTexture = nullptr;
|
||||
ContentLibraryEffect *m_draggedBundleEffect = nullptr;
|
||||
ContentLibraryItem *m_draggedBundleItem = nullptr;
|
||||
bool m_bundleMaterialAddToSelected = false;
|
||||
bool m_hasQuick3DImport = false;
|
||||
qint32 m_sceneId = -1;
|
||||
|
@@ -4,8 +4,8 @@
|
||||
#include "contentlibrarywidget.h"
|
||||
|
||||
#include "contentlibrarybundleimporter.h"
|
||||
#include "contentlibraryeffect.h"
|
||||
#include "contentlibraryeffectsmodel.h"
|
||||
#include "contentlibraryitem.h"
|
||||
#include "contentlibrarymaterial.h"
|
||||
#include "contentlibrarymaterialsmodel.h"
|
||||
#include "contentlibrarytexture.h"
|
||||
@@ -68,18 +68,18 @@ bool ContentLibraryWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
Model *model = document->currentModel();
|
||||
QTC_ASSERT(model, return false);
|
||||
|
||||
if (m_effectToDrag) {
|
||||
if (m_itemToDrag) {
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
if ((me->globalPos() - m_dragStartPoint).manhattanLength() > 20) {
|
||||
QByteArray data;
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
QDataStream stream(&data, QIODevice::WriteOnly);
|
||||
stream << m_effectToDrag->type();
|
||||
mimeData->setData(Constants::MIME_TYPE_BUNDLE_EFFECT, data);
|
||||
stream << m_itemToDrag->type();
|
||||
mimeData->setData(Constants::MIME_TYPE_BUNDLE_ITEM, data);
|
||||
|
||||
emit bundleEffectDragStarted(m_effectToDrag);
|
||||
model->startDrag(mimeData, m_effectToDrag->icon().toLocalFile());
|
||||
m_effectToDrag = nullptr;
|
||||
emit bundleItemDragStarted(m_itemToDrag);
|
||||
model->startDrag(mimeData, m_itemToDrag->icon().toLocalFile());
|
||||
m_itemToDrag = nullptr;
|
||||
}
|
||||
} else if (m_materialToDrag) {
|
||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||
@@ -113,7 +113,7 @@ bool ContentLibraryWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
}
|
||||
} else if (event->type() == QMouseEvent::MouseButtonRelease) {
|
||||
m_effectToDrag = nullptr;
|
||||
m_itemToDrag = nullptr;
|
||||
m_materialToDrag = nullptr;
|
||||
m_textureToDrag = nullptr;
|
||||
setIsDragging(false);
|
||||
@@ -697,6 +697,8 @@ void ContentLibraryWidget::setHasQuick3DImport(bool b)
|
||||
|
||||
m_materialsModel->updateIsEmpty();
|
||||
m_effectsModel->updateIsEmpty();
|
||||
m_userModel->updateIsEmptyMaterials();
|
||||
m_userModel->updateIsEmpty3D();
|
||||
}
|
||||
|
||||
bool ContentLibraryWidget::hasMaterialLibrary() const
|
||||
@@ -713,6 +715,8 @@ void ContentLibraryWidget::setHasMaterialLibrary(bool b)
|
||||
emit hasMaterialLibraryChanged();
|
||||
|
||||
m_materialsModel->updateIsEmpty();
|
||||
m_userModel->updateIsEmptyMaterials();
|
||||
m_userModel->updateIsEmpty3D();
|
||||
}
|
||||
|
||||
bool ContentLibraryWidget::hasActive3DScene() const
|
||||
@@ -806,10 +810,9 @@ QString ContentLibraryWidget::findTextureBundlePath()
|
||||
return texBundleDir.path();
|
||||
}
|
||||
|
||||
void ContentLibraryWidget::startDragEffect(QmlDesigner::ContentLibraryEffect *eff,
|
||||
const QPointF &mousePos)
|
||||
void ContentLibraryWidget::startDragItem(QmlDesigner::ContentLibraryItem *item, const QPointF &mousePos)
|
||||
{
|
||||
m_effectToDrag = eff;
|
||||
m_itemToDrag = item;
|
||||
m_dragStartPoint = mousePos.toPoint();
|
||||
setIsDragging(true);
|
||||
}
|
||||
|
@@ -23,8 +23,8 @@ class StudioQuickWidget;
|
||||
namespace QmlDesigner {
|
||||
|
||||
class ContentLibraryBundleImporter;
|
||||
class ContentLibraryEffect;
|
||||
class ContentLibraryEffectsModel;
|
||||
class ContentLibraryItem;
|
||||
class ContentLibraryMaterial;
|
||||
class ContentLibraryMaterialsModel;
|
||||
class ContentLibraryTexture;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
QPointer<ContentLibraryEffectsModel> effectsModel() const;
|
||||
QPointer<ContentLibraryUserModel> userModel() const;
|
||||
|
||||
Q_INVOKABLE void startDragEffect(QmlDesigner::ContentLibraryEffect *eff, const QPointF &mousePos);
|
||||
Q_INVOKABLE void startDragItem(QmlDesigner::ContentLibraryItem *item, const QPointF &mousePos);
|
||||
Q_INVOKABLE void startDragMaterial(QmlDesigner::ContentLibraryMaterial *mat, const QPointF &mousePos);
|
||||
Q_INVOKABLE void startDragTexture(QmlDesigner::ContentLibraryTexture *tex, const QPointF &mousePos);
|
||||
Q_INVOKABLE void addImage(QmlDesigner::ContentLibraryTexture *tex);
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
ContentLibraryBundleImporter *importer() const;
|
||||
|
||||
signals:
|
||||
void bundleEffectDragStarted(QmlDesigner::ContentLibraryEffect *bundleEff);
|
||||
void bundleItemDragStarted(QmlDesigner::ContentLibraryItem *item);
|
||||
void bundleMaterialDragStarted(QmlDesigner::ContentLibraryMaterial *bundleMat);
|
||||
void bundleTextureDragStarted(QmlDesigner::ContentLibraryTexture *bundleTex);
|
||||
void addTextureRequested(const QString texPath, QmlDesigner::AddTextureMode mode);
|
||||
@@ -134,12 +134,11 @@ private:
|
||||
QPointer<ContentLibraryUserModel> m_userModel;
|
||||
|
||||
ContentLibraryBundleImporter *m_importer = nullptr;
|
||||
|
||||
QShortcut *m_qmlSourceUpdateShortcut = nullptr;
|
||||
|
||||
QString m_filterText;
|
||||
|
||||
ContentLibraryEffect *m_effectToDrag = nullptr;
|
||||
ContentLibraryItem *m_itemToDrag = nullptr;
|
||||
ContentLibraryMaterial *m_materialToDrag = nullptr;
|
||||
ContentLibraryTexture *m_textureToDrag = nullptr;
|
||||
QPoint m_dragStartPoint;
|
||||
|
@@ -507,7 +507,7 @@ void Edit3DView::nodeAtPosReady(const ModelNode &modelNode, const QVector3D &pos
|
||||
} else if (m_nodeAtPosReqType == NodeAtPosReqType::BundleMaterialDrop) {
|
||||
emitCustomNotification("drop_bundle_material", {modelNode}); // To ContentLibraryView
|
||||
} else if (m_nodeAtPosReqType == NodeAtPosReqType::BundleEffectDrop) {
|
||||
emitCustomNotification("drop_bundle_effect", {modelNode}, {pos3d}); // To ContentLibraryView
|
||||
emitCustomNotification("drop_bundle_item", {modelNode}, {pos3d}); // To ContentLibraryView
|
||||
} else if (m_nodeAtPosReqType == NodeAtPosReqType::TextureDrop) {
|
||||
emitCustomNotification("apply_texture_to_model3D", {modelNode, m_droppedModelNode});
|
||||
} else if (m_nodeAtPosReqType == NodeAtPosReqType::AssetDrop) {
|
||||
|
@@ -685,7 +685,7 @@ void Edit3DWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
|
||||
} else if (actionManager.externalDragHasSupportedAssets(dragEnterEvent->mimeData())
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_MATERIAL)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_ITEM)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_TEXTURE)) {
|
||||
if (Utils3D::active3DSceneNode(m_view).isValid())
|
||||
dragEnterEvent->acceptProposedAction();
|
||||
@@ -730,8 +730,8 @@ void Edit3DWidget::dropEvent(QDropEvent *dropEvent)
|
||||
return;
|
||||
}
|
||||
|
||||
// handle dropping bundle effects
|
||||
if (dropEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)) {
|
||||
// handle dropping bundle items
|
||||
if (dropEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_ITEM)) {
|
||||
m_view->dropBundleEffect(pos);
|
||||
m_view->model()->endDrag();
|
||||
return;
|
||||
|
@@ -455,7 +455,7 @@ QStringList NavigatorTreeModel::mimeTypes() const
|
||||
Constants::MIME_TYPE_MATERIAL,
|
||||
Constants::MIME_TYPE_BUNDLE_TEXTURE,
|
||||
Constants::MIME_TYPE_BUNDLE_MATERIAL,
|
||||
Constants::MIME_TYPE_BUNDLE_EFFECT,
|
||||
Constants::MIME_TYPE_BUNDLE_ITEM,
|
||||
Constants::MIME_TYPE_ASSETS});
|
||||
|
||||
return types;
|
||||
@@ -570,9 +570,9 @@ bool NavigatorTreeModel::dropMimeData(const QMimeData *mimeData,
|
||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)) {
|
||||
if (targetNode.isValid())
|
||||
m_view->emitCustomNotification("drop_bundle_material", {targetNode}); // To ContentLibraryView
|
||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)) {
|
||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_BUNDLE_ITEM)) {
|
||||
if (targetNode.isValid())
|
||||
m_view->emitCustomNotification("drop_bundle_effect", {targetNode}); // To ContentLibraryView
|
||||
m_view->emitCustomNotification("drop_bundle_item", {targetNode}); // To ContentLibraryView
|
||||
} else if (mimeData->hasFormat(Constants::MIME_TYPE_ASSETS)) {
|
||||
const QStringList assetsPaths = QString::fromUtf8(mimeData->data(Constants::MIME_TYPE_ASSETS)).split(',');
|
||||
NodeAbstractProperty targetProperty;
|
||||
|
@@ -106,7 +106,7 @@ inline constexpr char MIME_TYPE_ITEM_LIBRARY_INFO[]
|
||||
inline constexpr char MIME_TYPE_ASSETS[] = "application/vnd.qtdesignstudio.assets";
|
||||
inline constexpr char MIME_TYPE_MATERIAL[] = "application/vnd.qtdesignstudio.material";
|
||||
inline constexpr char MIME_TYPE_TEXTURE[] = "application/vnd.qtdesignstudio.texture";
|
||||
inline constexpr char MIME_TYPE_BUNDLE_EFFECT[] = "application/vnd.qtdesignstudio.bundleeffect";
|
||||
inline constexpr char MIME_TYPE_BUNDLE_ITEM[] = "application/vnd.qtdesignstudio.bundleitem";
|
||||
inline constexpr char MIME_TYPE_BUNDLE_MATERIAL[] = "application/vnd.qtdesignstudio.bundlematerial";
|
||||
inline constexpr char MIME_TYPE_BUNDLE_TEXTURE[] = "application/vnd.qtdesignstudio.bundletexture";
|
||||
inline constexpr char MIME_TYPE_ASSET_IMAGE[] = "application/vnd.qtdesignstudio.asset.image";
|
||||
|
Reference in New Issue
Block a user