forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/8.0'
Conflicts: src/plugins/debugger/debuggerdialogs.cpp src/plugins/qmldesigner/components/materialeditor/materialeditorview.cpp src/plugins/texteditor/fontsettingspage.cpp Change-Id: I5a6accd2065e0d8320045b57ade7b54a9a09aae0
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// Copyright (C) 2020 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "designersettings.h"
|
||||
#include "edit3dactions.h"
|
||||
#include "edit3dcanvas.h"
|
||||
#include "edit3dview.h"
|
||||
@@ -20,6 +19,7 @@
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <toolbox.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QActionGroup>
|
||||
@@ -171,6 +171,61 @@ void Edit3DWidget::createContextMenu()
|
||||
});
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (!m_contextMenu)
|
||||
return;
|
||||
|
||||
if (m_createSubMenu) {
|
||||
m_contextMenu->removeAction(m_createSubMenu->menuAction());
|
||||
m_createSubMenu.clear();
|
||||
}
|
||||
|
||||
m_nameToEntry.clear();
|
||||
m_createSubMenu = m_contextMenu->addMenu(tr("Create"));
|
||||
|
||||
for (const QString &cat : keys) {
|
||||
QList<ItemLibraryEntry> entries = entriesMap.value(cat);
|
||||
if (entries.isEmpty())
|
||||
continue;
|
||||
|
||||
QMenu *catMenu = m_createSubMenu->addMenu(cat);
|
||||
|
||||
std::sort(entries.begin(), entries.end(), [](const ItemLibraryEntry &a, const ItemLibraryEntry &b) {
|
||||
return a.name() < b.name();
|
||||
});
|
||||
|
||||
for (const ItemLibraryEntry &entry : std::as_const(entries)) {
|
||||
QAction *action = catMenu->addAction(entry.name(), this, &Edit3DWidget::onCreateAction);
|
||||
action->setData(entry.name());
|
||||
m_nameToEntry.insert(entry.name(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action triggered from the "create" sub-menu
|
||||
void Edit3DWidget::onCreateAction()
|
||||
{
|
||||
// QAction *action = qobject_cast<QAction *>(sender());
|
||||
// if (!action)
|
||||
// return;
|
||||
|
||||
// m_view->executeInTransaction(__FUNCTION__, [&] {
|
||||
// int activeScene = m_view->rootModelNode().auxiliaryData("active3dScene@Internal").toInt();
|
||||
|
||||
// auto modelNode = QmlVisualNode::createQml3DNode(m_view, m_nameToEntry.value(action->data().toString()),
|
||||
// activeScene).modelNode();
|
||||
// QTC_ASSERT(modelNode.isValid(), return);
|
||||
// m_view->setSelectedModelNode(modelNode);
|
||||
|
||||
// // if added node is a Model, assign it a material
|
||||
// if (modelNode.isSubclassOf("QtQuick3D.Model"))
|
||||
// m_view->assignMaterialTo3dModel(modelNode);
|
||||
// });
|
||||
}
|
||||
|
||||
void Edit3DWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||
{
|
||||
if (m_view)
|
||||
|
||||
Reference in New Issue
Block a user