forked from qt-creator/qt-creator
QmlDesigner: Create a context menu for the 3D Editor
For now only 1 action is implemented (edit material), more actions are coming next. Task-number: QDS-7414 Task-number: QDS-7398 Change-Id: Id8e36c23d9a4d35ee94d55d3d6b15df78241a05d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "edit3dwidget.h"
|
||||
#include "edit3dvisibilitytogglesmenu.h"
|
||||
#include "metainfo.h"
|
||||
#include "modelnodeoperations.h"
|
||||
#include "qmldesignerconstants.h"
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "qmlvisualnode.h"
|
||||
@@ -49,8 +50,8 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
||||
m_view(view)
|
||||
Edit3DWidget::Edit3DWidget(Edit3DView *view)
|
||||
: m_view(view)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
|
||||
@@ -146,6 +147,8 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
||||
|
||||
handleActions(view->backgroundColorActions(), m_backgroundColorMenu, false);
|
||||
|
||||
createContextMenu();
|
||||
|
||||
view->setSeeker(seeker);
|
||||
seeker->setToolTip(QLatin1String("Seek particle system time when paused."));
|
||||
|
||||
@@ -173,6 +176,18 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
||||
showCanvas(false);
|
||||
}
|
||||
|
||||
void Edit3DWidget::createContextMenu()
|
||||
{
|
||||
m_contextMenu = new QMenu(this);
|
||||
m_editMaterialAction = m_contextMenu->addAction(tr("Edit Material"), [&] {
|
||||
SelectionContext selCtx(m_view);
|
||||
selCtx.setTargetNode(m_contextMenuTarget);
|
||||
ModelNodeOperations::editMaterial(selCtx);
|
||||
});
|
||||
|
||||
// TODO: add more actions: delete, create, etc
|
||||
}
|
||||
|
||||
void Edit3DWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_view)
|
||||
@@ -221,6 +236,15 @@ void Edit3DWidget::showBackgroundColorMenu(bool show, const QPoint &pos)
|
||||
m_backgroundColorMenu->close();
|
||||
}
|
||||
|
||||
void Edit3DWidget::showContextMenu(const QPoint &pos, const ModelNode &modelNode)
|
||||
{
|
||||
m_contextMenuTarget = modelNode;
|
||||
|
||||
m_editMaterialAction->setEnabled(modelNode.isValid());
|
||||
|
||||
m_contextMenu->popup(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void Edit3DWidget::linkActivated(const QString &link)
|
||||
{
|
||||
Q_UNUSED(link)
|
||||
|
||||
Reference in New Issue
Block a user