forked from qt-creator/qt-creator
QmlDesigner: Check if root element is a graphical item
If the root element is not a graphical item, then we show a proper error message. Task-number: QTCREATORBUG-20014 Change-Id: I9c1ccbbeb6765bd098344ceef8024a703a8dc919 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
08a86169db
commit
3d64aa7aa6
@@ -44,6 +44,7 @@
|
||||
#include <model.h>
|
||||
#include <nodeabstractproperty.h>
|
||||
#include <nodelistproperty.h>
|
||||
#include <nodemetainfo.h>
|
||||
#include <rewriterview.h>
|
||||
#include <zoomaction.h>
|
||||
|
||||
@@ -159,6 +160,8 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
|
||||
if (QmlItemNode::isValidQmlItemNode(nextNode) && nextNode.modelNode().nodeSourceType() == ModelNode::NodeWithoutSource)
|
||||
setupFormEditorItemTree(nextNode.toQmlItemNode());
|
||||
}
|
||||
|
||||
checkRootModelNode();
|
||||
}
|
||||
|
||||
static void deleteWithoutChildren(const QList<FormEditorItem*> &items)
|
||||
@@ -296,7 +299,11 @@ void FormEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVer
|
||||
if (newItemNode.isValid()) //only setup QmlItems
|
||||
setupFormEditorItemTree(newItemNode);
|
||||
|
||||
|
||||
|
||||
m_currentTool->setItems(scene()->itemsForQmlItemNodes(toQmlItemNodeList(selectedModelNodes())));
|
||||
|
||||
checkRootModelNode();
|
||||
}
|
||||
|
||||
void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList)
|
||||
@@ -464,6 +471,8 @@ void FormEditorView::documentMessagesChanged(const QList<DocumentMessage> &error
|
||||
m_formEditorWidget->showErrorMessageBox(errors);
|
||||
else
|
||||
m_formEditorWidget->hideErrorMessageBox();
|
||||
|
||||
checkRootModelNode();
|
||||
}
|
||||
|
||||
void FormEditorView::customNotification(const AbstractView * /*view*/, const QString &identifier, const QList<ModelNode> &/*nodeList*/, const QList<QVariant> &/*data*/)
|
||||
@@ -796,6 +805,8 @@ void FormEditorView::setupFormEditorWidget()
|
||||
|
||||
if (!rewriterView()->warnings().isEmpty())
|
||||
m_formEditorWidget->showWarningMessageBox(rewriterView()->warnings());
|
||||
|
||||
checkRootModelNode();
|
||||
}
|
||||
|
||||
QmlItemNode findRecursiveQmlItemNode(const QmlObjectNode &firstQmlObjectNode)
|
||||
@@ -884,6 +895,21 @@ void FormEditorView::addOrRemoveFormEditorItem(const ModelNode &node)
|
||||
}
|
||||
}
|
||||
|
||||
void FormEditorView::checkRootModelNode()
|
||||
{
|
||||
if (m_formEditorWidget->errorMessageBoxIsVisible())
|
||||
return;
|
||||
|
||||
QTC_ASSERT(rootModelNode().isValid(), return);
|
||||
|
||||
if (!rootModelNode().metaInfo().isGraphicalItem())
|
||||
m_formEditorWidget->showErrorMessageBox(
|
||||
{DocumentMessage(tr("%1 is not supported as the root element by Form Editor.")
|
||||
.arg(rootModelNode().simplifiedTypeName()))});
|
||||
else
|
||||
m_formEditorWidget->hideErrorMessageBox();
|
||||
}
|
||||
|
||||
void FormEditorView::reset()
|
||||
{
|
||||
QTimer::singleShot(200, this, &FormEditorView::delayedReset);
|
||||
|
@@ -149,6 +149,7 @@ private:
|
||||
void temporaryBlockView(int duration = 1000);
|
||||
void resetNodeInstanceView();
|
||||
void addOrRemoveFormEditorItem(const ModelNode &node);
|
||||
void checkRootModelNode();
|
||||
|
||||
QPointer<FormEditorWidget> m_formEditorWidget;
|
||||
QPointer<FormEditorScene> m_scene;
|
||||
|
@@ -549,6 +549,11 @@ FormEditorGraphicsView *FormEditorWidget::graphicsView() const
|
||||
return m_graphicsView;
|
||||
}
|
||||
|
||||
bool FormEditorWidget::errorMessageBoxIsVisible() const
|
||||
{
|
||||
return m_documentErrorWidget && m_documentErrorWidget->isVisible();
|
||||
}
|
||||
|
||||
DocumentWarningWidget *FormEditorWidget::errorWidget()
|
||||
{
|
||||
if (m_documentErrorWidget.isNull()) {
|
||||
|
@@ -89,6 +89,8 @@ public:
|
||||
|
||||
FormEditorGraphicsView *graphicsView() const;
|
||||
|
||||
bool errorMessageBoxIsVisible() const;
|
||||
|
||||
protected:
|
||||
QActionGroup *toolActionGroup() const;
|
||||
DocumentWarningWidget *errorWidget();
|
||||
|
Reference in New Issue
Block a user