forked from qt-creator/qt-creator
QmlDesigner: Add onboarding text to 3D edit view when there is no 3D
Change-Id: If9513da39efcc19129de6867ea7357bc6c0e2af4 Fixes: QDS-1748 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -36,9 +36,10 @@
|
||||
#include <qmldesignerconstants.h>
|
||||
#include <viewmanager.h>
|
||||
#include <qmldesignericons.h>
|
||||
#include <designmodecontext.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <designmodecontext.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -62,6 +63,20 @@ void Edit3DView::createEdit3DWidget()
|
||||
Core::ICore::addContextObject(editor3DContext);
|
||||
}
|
||||
|
||||
void Edit3DView::checkImports()
|
||||
{
|
||||
bool has3dImport = false;
|
||||
const QList<Import> imports = model()->imports();
|
||||
for (const auto &import : imports) {
|
||||
if (import.url() == "QtQuick3D") {
|
||||
has3dImport = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
edit3DWidget()->showCanvas(has3dImport);
|
||||
}
|
||||
|
||||
WidgetInfo Edit3DView::widgetInfo()
|
||||
{
|
||||
if (!m_edit3DWidget)
|
||||
@@ -130,13 +145,30 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
|
||||
m_editLightAction->action()->setChecked(false);
|
||||
}
|
||||
|
||||
void Edit3DView::modelAttached(Model *model)
|
||||
{
|
||||
AbstractView::modelAttached(model);
|
||||
|
||||
checkImports();
|
||||
}
|
||||
|
||||
void Edit3DView::modelAboutToBeDetached(Model *model)
|
||||
{
|
||||
Q_UNUSED(model)
|
||||
|
||||
// Clear the image when model is detached (i.e. changing documents)
|
||||
QImage emptyImage;
|
||||
edit3DWidget()->canvas()->updateRenderImage(emptyImage);
|
||||
// Hide the canvas when model is detached (i.e. changing documents)
|
||||
edit3DWidget()->showCanvas(false);
|
||||
|
||||
AbstractView::modelAboutToBeDetached(model);
|
||||
}
|
||||
|
||||
void Edit3DView::importsChanged(const QList<Import> &addedImports,
|
||||
const QList<Import> &removedImports)
|
||||
{
|
||||
Q_UNUSED(addedImports)
|
||||
Q_UNUSED(removedImports)
|
||||
|
||||
checkImports();
|
||||
}
|
||||
|
||||
void Edit3DView::sendInputEvent(QInputEvent *e) const
|
||||
@@ -266,5 +298,21 @@ QVector<Edit3DAction *> Edit3DView::rightActions() const
|
||||
return m_rightActions;
|
||||
}
|
||||
|
||||
void Edit3DView::addQuick3DImport()
|
||||
{
|
||||
const QList<Import> imports = model()->possibleImports();
|
||||
for (const auto &import : imports) {
|
||||
if (import.url() == "QtQuick3D") {
|
||||
model()->changeImports({import}, {});
|
||||
|
||||
// Subcomponent manager update needed to make item library entries appear
|
||||
QmlDesignerPlugin::instance()->currentDesignDocument()->updateSubcomponentManager();
|
||||
return;
|
||||
}
|
||||
}
|
||||
Core::AsynchronousMessageBox::warning(tr("Failed to Add Import"),
|
||||
tr("Could not add QtQuick3D import to project."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user