forked from qt-creator/qt-creator
QmlDesigner: Respect node locking in navigator and 3D view
If 3D scene root is locked, disable create options from context menu in 3D view. Also, don't highlight locked nodes as drop targets in navigator. Fixes: QDS-8731 Change-Id: If0c8b5497781c2623f2c57966d4689e345b85785 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -248,6 +248,16 @@ bool Edit3DWidget::isPasteAvailable() const
|
||||
return QApplication::clipboard()->text().startsWith(Constants::HEADER_3DPASTE_CONTENT);
|
||||
}
|
||||
|
||||
bool Edit3DWidget::isSceneLocked() const
|
||||
{
|
||||
if (m_view && m_view->hasModelNodeForInternalId(m_canvas->activeScene())) {
|
||||
ModelNode node = m_view->modelNodeForInternalId(m_canvas->activeScene());
|
||||
if (ModelNode::isThisOrAncestorLocked(node))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called by the view to update the "create" sub-menu when the Quick3D entries are ready.
|
||||
void Edit3DWidget::updateCreateSubMenu(const QStringList &keys,
|
||||
const QHash<QString, QList<ItemLibraryEntry>> &entriesMap)
|
||||
@@ -286,7 +296,7 @@ void Edit3DWidget::updateCreateSubMenu(const QStringList &keys,
|
||||
void Edit3DWidget::onCreateAction()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
if (!action || !m_view || !m_view->model())
|
||||
if (!action || !m_view || !m_view->model() || isSceneLocked())
|
||||
return;
|
||||
|
||||
m_view->executeInTransaction(__FUNCTION__, [&] {
|
||||
@@ -374,6 +384,9 @@ void Edit3DWidget::showContextMenu(const QPoint &pos, const ModelNode &modelNode
|
||||
const bool anyNodeSelected = view()->hasSelectedModelNodes();
|
||||
const bool selectionExcludingRoot = anyNodeSelected && !view()->rootModelNode().isSelected();
|
||||
|
||||
if (m_createSubMenu)
|
||||
m_createSubMenu->setEnabled(!isSceneLocked());
|
||||
|
||||
m_editComponentAction->setEnabled(isSingleComponent);
|
||||
m_editMaterialAction->setEnabled(isModel);
|
||||
m_duplicateAction->setEnabled(selectionExcludingRoot);
|
||||
|
@@ -52,6 +52,7 @@ private:
|
||||
void createContextMenu();
|
||||
|
||||
bool isPasteAvailable() const;
|
||||
bool isSceneLocked() const;
|
||||
|
||||
QPointer<Edit3DView> m_edit3DView;
|
||||
QPointer<Edit3DView> m_view;
|
||||
|
@@ -211,6 +211,7 @@ void NameItemDelegate::paint(QPainter *painter,
|
||||
}
|
||||
|
||||
ModelNode node = getModelNode(modelIndex);
|
||||
if (!ModelNode::isThisOrAncestorLocked(node)) {
|
||||
NavigatorWidget *widget = qobject_cast<NavigatorWidget *>(styleOption.widget->parent());
|
||||
if (widget && !widget->dragType().isEmpty()) {
|
||||
QByteArray dragType = widget->dragType();
|
||||
@@ -227,6 +228,7 @@ void NameItemDelegate::paint(QPainter *painter,
|
||||
}
|
||||
delete filter;
|
||||
}
|
||||
}
|
||||
|
||||
iconOffset = drawIcon(painter, styleOption, modelIndex);
|
||||
|
||||
|
Reference in New Issue
Block a user