forked from qt-creator/qt-creator
QmlDesigner: Prevent bundle effect add when no active 3D scene found
Fixes: QDS-10205 Change-Id: I88f3e6f95ea9beab1470dd8057d2b01497c2caf0 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:
@@ -26,7 +26,7 @@ StudioControls.Menu {
|
||||
|
||||
StudioControls.MenuItem {
|
||||
text: qsTr("Add an instance")
|
||||
enabled: root.targetAvailable
|
||||
enabled: root.targetAvailable && ContentLibraryBackend.rootView.hasActive3DScene
|
||||
onTriggered: ContentLibraryBackend.effectsModel.addInstance(root.targetItem)
|
||||
}
|
||||
|
||||
|
@@ -181,6 +181,7 @@ void ContentLibraryView::modelAttached(Model *model)
|
||||
|
||||
m_sceneId = model->active3DSceneId();
|
||||
|
||||
m_widget->setHasActive3DScene(m_sceneId != -1);
|
||||
m_widget->clearSearchFilter();
|
||||
|
||||
m_widget->effectsModel()->loadBundle();
|
||||
@@ -214,6 +215,7 @@ void ContentLibraryView::importsChanged(const Imports &addedImports, const Impor
|
||||
void ContentLibraryView::active3DSceneChanged(qint32 sceneId)
|
||||
{
|
||||
m_sceneId = sceneId;
|
||||
m_widget->setHasActive3DScene(m_sceneId != -1);
|
||||
}
|
||||
|
||||
void ContentLibraryView::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
|
||||
|
@@ -662,6 +662,20 @@ void ContentLibraryWidget::setHasMaterialLibrary(bool b)
|
||||
m_materialsModel->updateIsEmpty();
|
||||
}
|
||||
|
||||
bool ContentLibraryWidget::hasActive3DScene() const
|
||||
{
|
||||
return m_hasActive3DScene;
|
||||
}
|
||||
|
||||
void ContentLibraryWidget::setHasActive3DScene(bool b)
|
||||
{
|
||||
if (m_hasActive3DScene == b)
|
||||
return;
|
||||
|
||||
m_hasActive3DScene = b;
|
||||
emit hasActive3DSceneChanged();
|
||||
}
|
||||
|
||||
void ContentLibraryWidget::reloadQmlSource()
|
||||
{
|
||||
const QString materialBrowserQmlPath = qmlSourcesPath() + "/ContentLibrary.qml";
|
||||
|
@@ -29,8 +29,9 @@ class ContentLibraryWidget : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport NOTIFY hasQuick3DImportChanged)
|
||||
Q_PROPERTY(bool hasQuick3DImport READ hasQuick3DImport NOTIFY hasQuick3DImportChanged)
|
||||
Q_PROPERTY(bool hasMaterialLibrary READ hasMaterialLibrary NOTIFY hasMaterialLibraryChanged)
|
||||
Q_PROPERTY(bool hasActive3DScene READ hasActive3DScene WRITE setHasActive3DScene NOTIFY hasActive3DSceneChanged)
|
||||
|
||||
// Needed for a workaround for a bug where after drag-n-dropping an item, the ScrollView scrolls to a random position
|
||||
Q_PROPERTY(bool isDragging MEMBER m_isDragging NOTIFY isDraggingChanged)
|
||||
@@ -49,6 +50,9 @@ public:
|
||||
bool hasMaterialLibrary() const;
|
||||
void setHasMaterialLibrary(bool b);
|
||||
|
||||
bool hasActive3DScene() const;
|
||||
void setHasActive3DScene(bool b);
|
||||
|
||||
Q_INVOKABLE void handleSearchFilterChanged(const QString &filterText);
|
||||
|
||||
void setMaterialsModel(QPointer<ContentLibraryMaterialsModel> newMaterialsModel);
|
||||
@@ -75,6 +79,7 @@ signals:
|
||||
void updateSceneEnvStateRequested();
|
||||
void hasQuick3DImportChanged();
|
||||
void hasMaterialLibraryChanged();
|
||||
void hasActive3DSceneChanged();
|
||||
void isDraggingChanged();
|
||||
|
||||
protected:
|
||||
@@ -111,6 +116,7 @@ private:
|
||||
QPoint m_dragStartPoint;
|
||||
|
||||
bool m_hasMaterialLibrary = false;
|
||||
bool m_hasActive3DScene = false;
|
||||
bool m_hasQuick3DImport = false;
|
||||
bool m_isDragging = false;
|
||||
QString m_baseUrl;
|
||||
|
@@ -541,7 +541,8 @@ void Edit3DWidget::dragEnterEvent(QDragEnterEvent *dragEnterEvent)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_MATERIAL)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_BUNDLE_EFFECT)
|
||||
|| dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_TEXTURE)) {
|
||||
dragEnterEvent->acceptProposedAction();
|
||||
if (m_view->active3DSceneNode().isValid())
|
||||
dragEnterEvent->acceptProposedAction();
|
||||
} else if (dragEnterEvent->mimeData()->hasFormat(Constants::MIME_TYPE_ITEM_LIBRARY_INFO)) {
|
||||
QByteArray data = dragEnterEvent->mimeData()->data(Constants::MIME_TYPE_ITEM_LIBRARY_INFO);
|
||||
if (!data.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user