forked from qt-creator/qt-creator
Enable Copy, Cut, and Paste in the Editor 3D
Task-number: QDS-1563 Change-Id: I22c3017b8c158d8bc084f050baef89fa8fffd365 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -112,16 +112,17 @@ void DesignerActionManager::polishActions() const
|
|||||||
[](ActionInterface *action) { return action->type() != ActionInterface::ContextMenu; });
|
[](ActionInterface *action) { return action->type() != ActionInterface::ContextMenu; });
|
||||||
|
|
||||||
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
||||||
|
Core::Context qmlDesignerEditor3DContext(Constants::C_QMLEDITOR3D);
|
||||||
Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR);
|
Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR);
|
||||||
|
|
||||||
Core::Context qmlDesignerUIContext;
|
Core::Context qmlDesignerUIContext;
|
||||||
qmlDesignerUIContext.add(qmlDesignerFormEditorContext);
|
qmlDesignerUIContext.add(qmlDesignerFormEditorContext);
|
||||||
|
qmlDesignerUIContext.add(qmlDesignerEditor3DContext);
|
||||||
qmlDesignerUIContext.add(qmlDesignerNavigatorContext);
|
qmlDesignerUIContext.add(qmlDesignerNavigatorContext);
|
||||||
|
|
||||||
for (auto *action : actions) {
|
for (auto *action : actions) {
|
||||||
if (!action->menuId().isEmpty()) {
|
if (!action->menuId().isEmpty()) {
|
||||||
const QString id =
|
const QString id = QString("QmlDesigner.%1").arg(QString::fromLatin1(action->menuId()));
|
||||||
QString("QmlDesigner.%1").arg(QString::fromLatin1(action->menuId()));
|
|
||||||
|
|
||||||
Core::Command *cmd = Core::ActionManager::registerAction(action->action(), id.toLatin1().constData(), qmlDesignerUIContext);
|
Core::Command *cmd = Core::ActionManager::registerAction(action->action(), id.toLatin1().constData(), qmlDesignerUIContext);
|
||||||
|
|
||||||
|
@@ -45,6 +45,8 @@ public:
|
|||||||
void updateRenderImage(const QImage &img);
|
void updateRenderImage(const QImage &img);
|
||||||
void updateActiveScene(qint32 activeScene);
|
void updateActiveScene(qint32 activeScene);
|
||||||
|
|
||||||
|
qint32 activeScene() const { return m_activeScene; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
|
@@ -37,6 +37,8 @@
|
|||||||
#include <viewmanager.h>
|
#include <viewmanager.h>
|
||||||
#include <qmldesignericons.h>
|
#include <qmldesignericons.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <designmodecontext.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -55,6 +57,9 @@ void Edit3DView::createEdit3DWidget()
|
|||||||
{
|
{
|
||||||
createEdit3DActions();
|
createEdit3DActions();
|
||||||
m_edit3DWidget = new Edit3DWidget(this);
|
m_edit3DWidget = new Edit3DWidget(this);
|
||||||
|
|
||||||
|
auto editor3DContext = new Internal::Editor3DContext(m_edit3DWidget.data());
|
||||||
|
Core::ICore::addContextObject(editor3DContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
WidgetInfo Edit3DView::widgetInfo()
|
WidgetInfo Edit3DView::widgetInfo()
|
||||||
@@ -88,8 +93,11 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
|
|||||||
const QString orientationKey = QStringLiteral("globalOrientation");
|
const QString orientationKey = QStringLiteral("globalOrientation");
|
||||||
const QString editLightKey = QStringLiteral("showEditLight");
|
const QString editLightKey = QStringLiteral("showEditLight");
|
||||||
|
|
||||||
if (sceneState.contains(sceneKey))
|
if (sceneState.contains(sceneKey)) {
|
||||||
edit3DWidget()->canvas()->updateActiveScene(sceneState[sceneKey].value<qint32>());
|
qint32 newActiveScene = sceneState[sceneKey].value<qint32>();
|
||||||
|
edit3DWidget()->canvas()->updateActiveScene(newActiveScene);
|
||||||
|
rootModelNode().setAuxiliaryData("3d-active-scene", newActiveScene);
|
||||||
|
}
|
||||||
|
|
||||||
if (sceneState.contains(selectKey))
|
if (sceneState.contains(selectKey))
|
||||||
m_selectionModeAction->action()->setChecked(sceneState[selectKey].toInt() == 0);
|
m_selectionModeAction->action()->setChecked(sceneState[selectKey].toInt() == 0);
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <toolbox.h>
|
#include <toolbox.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -42,6 +43,11 @@ namespace QmlDesigner {
|
|||||||
Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
||||||
m_view(view)
|
m_view(view)
|
||||||
{
|
{
|
||||||
|
Core::Context context(Constants::C_QMLEDITOR3D);
|
||||||
|
m_context = new Core::IContext(this);
|
||||||
|
m_context->setContext(context);
|
||||||
|
m_context->setWidget(this);
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::WheelFocus);
|
||||||
|
|
||||||
@@ -93,6 +99,14 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
|||||||
fillLayout->addWidget(m_canvas.data());
|
fillLayout->addWidget(m_canvas.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Edit3DWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||||
|
{
|
||||||
|
if (m_view)
|
||||||
|
m_view->contextHelp(callback);
|
||||||
|
|
||||||
|
callback({});
|
||||||
|
}
|
||||||
|
|
||||||
Edit3DCanvas *Edit3DWidget::canvas() const
|
Edit3DCanvas *Edit3DWidget::canvas() const
|
||||||
{
|
{
|
||||||
return m_canvas.data();
|
return m_canvas.data();
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <QtWidgets/qwidget.h>
|
#include <QtWidgets/qwidget.h>
|
||||||
#include <QtCore/qpointer.h>
|
#include <QtCore/qpointer.h>
|
||||||
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -42,12 +43,14 @@ public:
|
|||||||
|
|
||||||
Edit3DCanvas *canvas() const;
|
Edit3DCanvas *canvas() const;
|
||||||
Edit3DView *view() const;
|
Edit3DView *view() const;
|
||||||
|
void contextHelp(const Core::IContext::HelpCallback &callback) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<Edit3DView> m_edit3DView;
|
QPointer<Edit3DView> m_edit3DView;
|
||||||
QPointer<Edit3DView> m_view;
|
QPointer<Edit3DView> m_view;
|
||||||
QPointer<Edit3DCanvas> m_canvas;
|
QPointer<Edit3DCanvas> m_canvas;
|
||||||
QPointer<ToolBox> m_toolBox;
|
QPointer<ToolBox> m_toolBox;
|
||||||
|
Core::IContext *m_context = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -342,7 +342,6 @@ double FormEditorWidget::containerPadding() const
|
|||||||
return DesignerSettings::getValue(DesignerSettingsKey::CONTAINERPADDING).toDouble();
|
return DesignerSettings::getValue(DesignerSettingsKey::CONTAINERPADDING).toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FormEditorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
void FormEditorWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||||
{
|
{
|
||||||
if (m_formEditorView)
|
if (m_formEditorView)
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
#include <viewmanager.h>
|
#include <viewmanager.h>
|
||||||
#include <nodeinstanceview.h>
|
#include <nodeinstanceview.h>
|
||||||
|
#include "qmldesignerconstants.h"
|
||||||
|
#include "qmlvisualnode.h"
|
||||||
|
|
||||||
#include <projectexplorer/projecttree.h>
|
#include <projectexplorer/projecttree.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -44,6 +46,7 @@
|
|||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <qtsupport/qtsupportconstants.h>
|
#include <qtsupport/qtsupportconstants.h>
|
||||||
#include <qtsupport/qtversionmanager.h>
|
#include <qtsupport/qtversionmanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
@@ -449,7 +452,7 @@ void DesignDocument::paste()
|
|||||||
if (rootNode.type() == "empty")
|
if (rootNode.type() == "empty")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rootNode.id() == "designer__Selection") {
|
if (rootNode.id() == "designer__Selection") { // pasting multiple objects
|
||||||
currentModel()->attachView(&view);
|
currentModel()->attachView(&view);
|
||||||
|
|
||||||
ModelNode targetNode;
|
ModelNode targetNode;
|
||||||
@@ -458,8 +461,22 @@ void DesignDocument::paste()
|
|||||||
targetNode = view.selectedModelNodes().constFirst();
|
targetNode = view.selectedModelNodes().constFirst();
|
||||||
|
|
||||||
//In case we copy and paste a selection we paste in the parent item
|
//In case we copy and paste a selection we paste in the parent item
|
||||||
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty())
|
if ((view.selectedModelNodes().count() == selectedNodes.count()) && targetNode.isValid() && targetNode.hasParentProperty()) {
|
||||||
targetNode = targetNode.parentProperty().parentModelNode();
|
targetNode = targetNode.parentProperty().parentModelNode();
|
||||||
|
} else {
|
||||||
|
// if selection is empty and copied nodes are all 3D nodes, paste them under the active scene
|
||||||
|
bool all3DNodes = std::find_if(selectedNodes.begin(), selectedNodes.end(),
|
||||||
|
[](const ModelNode &node) { return !node.isSubclassOf("QtQuick3D.Node"); })
|
||||||
|
== selectedNodes.end();
|
||||||
|
if (all3DNodes) {
|
||||||
|
int activeSceneId = rootModelNode().auxiliaryData("3d-active-scene").toInt();
|
||||||
|
if (activeSceneId != -1) {
|
||||||
|
NodeListProperty sceneNodeProperty
|
||||||
|
= QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId);
|
||||||
|
targetNode = sceneNodeProperty.parentModelNode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetNode.isValid())
|
if (!targetNode.isValid())
|
||||||
targetNode = view.rootModelNode();
|
targetNode = view.rootModelNode();
|
||||||
@@ -487,24 +504,35 @@ void DesignDocument::paste()
|
|||||||
view.setSelectedModelNodes(pastedNodeList);
|
view.setSelectedModelNodes(pastedNodeList);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else { // pasting single object
|
||||||
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode](){
|
rewriterView()->executeInTransaction("DesignDocument::paste1", [this, &view, selectedNodes, rootNode]() {
|
||||||
currentModel()->attachView(&view);
|
currentModel()->attachView(&view);
|
||||||
ModelNode pastedNode(view.insertModel(rootNode));
|
ModelNode pastedNode(view.insertModel(rootNode));
|
||||||
ModelNode targetNode;
|
ModelNode targetNode;
|
||||||
|
|
||||||
if (!view.selectedModelNodes().isEmpty())
|
if (!view.selectedModelNodes().isEmpty()) {
|
||||||
targetNode = view.selectedModelNodes().constFirst();
|
targetNode = view.selectedModelNodes().constFirst();
|
||||||
|
} else {
|
||||||
|
// if selection is empty and this is a 3D Node, paste it under the active scene
|
||||||
|
if (pastedNode.isSubclassOf("QtQuick3D.Node")) {
|
||||||
|
int activeSceneId = rootModelNode().auxiliaryData("3d-active-scene").toInt();
|
||||||
|
if (activeSceneId != -1) {
|
||||||
|
NodeListProperty sceneNodeProperty
|
||||||
|
= QmlVisualNode::findSceneNodeProperty(rootModelNode().view(), activeSceneId);
|
||||||
|
targetNode = sceneNodeProperty.parentModelNode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetNode.isValid())
|
if (!targetNode.isValid())
|
||||||
targetNode = view.rootModelNode();
|
targetNode = view.rootModelNode();
|
||||||
|
|
||||||
if (targetNode.hasParentProperty() &&
|
if (targetNode.hasParentProperty() &&
|
||||||
(pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName()) &&
|
pastedNode.simplifiedTypeName() == targetNode.simplifiedTypeName() &&
|
||||||
(pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value()) &&
|
pastedNode.variantProperty("width").value() == targetNode.variantProperty("width").value() &&
|
||||||
(pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()))
|
pastedNode.variantProperty("height").value() == targetNode.variantProperty("height").value()) {
|
||||||
|
|
||||||
targetNode = targetNode.parentProperty().parentModelNode();
|
targetNode = targetNode.parentProperty().parentModelNode();
|
||||||
|
}
|
||||||
|
|
||||||
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
PropertyName defaultProperty(targetNode.metaInfo().defaultPropertyName());
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "designmodewidget.h"
|
#include "designmodewidget.h"
|
||||||
#include "formeditorwidget.h"
|
#include "formeditorwidget.h"
|
||||||
|
#include "edit3dwidget.h"
|
||||||
#include "navigatorwidget.h"
|
#include "navigatorwidget.h"
|
||||||
#include "texteditorwidget.h"
|
#include "texteditorwidget.h"
|
||||||
|
|
||||||
@@ -57,6 +58,18 @@ void FormEditorContext::contextHelp(const HelpCallback &callback) const
|
|||||||
qobject_cast<FormEditorWidget *>(m_widget)->contextHelp(callback);
|
qobject_cast<FormEditorWidget *>(m_widget)->contextHelp(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Editor3DContext::Editor3DContext(QWidget *widget)
|
||||||
|
: IContext(widget)
|
||||||
|
{
|
||||||
|
setWidget(widget);
|
||||||
|
setContext(Core::Context(Constants::C_QMLEDITOR3D, Constants::C_QT_QUICK_TOOLS_MENU));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Editor3DContext::contextHelp(const HelpCallback &callback) const
|
||||||
|
{
|
||||||
|
qobject_cast<Edit3DWidget *>(m_widget)->contextHelp(callback);
|
||||||
|
}
|
||||||
|
|
||||||
NavigatorContext::NavigatorContext(QWidget *widget)
|
NavigatorContext::NavigatorContext(QWidget *widget)
|
||||||
: IContext(widget)
|
: IContext(widget)
|
||||||
{
|
{
|
||||||
|
@@ -51,6 +51,15 @@ public:
|
|||||||
void contextHelp(const Core::IContext::HelpCallback &callback) const override;
|
void contextHelp(const Core::IContext::HelpCallback &callback) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Editor3DContext : public Core::IContext
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Editor3DContext(QWidget *widget);
|
||||||
|
void contextHelp(const Core::IContext::HelpCallback &callback) const override;
|
||||||
|
};
|
||||||
|
|
||||||
class NavigatorContext : public Core::IContext
|
class NavigatorContext : public Core::IContext
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -28,14 +28,15 @@
|
|||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
const char C_BACKSPACE[] = "QmlDesigner.Backspace";
|
const char C_BACKSPACE[] = "QmlDesigner.Backspace";
|
||||||
const char C_DELETE[] = "QmlDesigner.Delete";
|
const char C_DELETE[] = "QmlDesigner.Delete";
|
||||||
|
|
||||||
// Context
|
// Context
|
||||||
const char C_QMLDESIGNER[] = "QmlDesigner::QmlDesignerMain";
|
const char C_QMLDESIGNER[] = "QmlDesigner::QmlDesignerMain";
|
||||||
const char C_QMLFORMEDITOR[] = "QmlDesigner::FormEditor";
|
const char C_QMLFORMEDITOR[] = "QmlDesigner::FormEditor";
|
||||||
const char C_QMLNAVIGATOR[] = "QmlDesigner::Navigator";
|
const char C_QMLEDITOR3D[] = "QmlDesigner::Editor3D";
|
||||||
const char C_QMLTEXTEDITOR[] = "QmlDesigner::TextEditor";
|
const char C_QMLNAVIGATOR[] = "QmlDesigner::Navigator";
|
||||||
|
const char C_QMLTEXTEDITOR[] = "QmlDesigner::TextEditor";
|
||||||
|
|
||||||
// Special context for preview menu, shared b/w designer and text editor
|
// Special context for preview menu, shared b/w designer and text editor
|
||||||
const char C_QT_QUICK_TOOLS_MENU[] = "QmlDesigner::ToolsMenu";
|
const char C_QT_QUICK_TOOLS_MENU[] = "QmlDesigner::ToolsMenu";
|
||||||
|
@@ -287,14 +287,17 @@ void QmlDesignerPlugin::integrateIntoQtCreator(QWidget *modeWidget)
|
|||||||
Core::ICore::addContextObject(d->context);
|
Core::ICore::addContextObject(d->context);
|
||||||
Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER);
|
Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER);
|
||||||
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
||||||
|
Core::Context qmlDesignerEditor3dContext(Constants::C_QMLEDITOR3D);
|
||||||
Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR);
|
Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR);
|
||||||
|
|
||||||
d->context->context().add(qmlDesignerMainContext);
|
d->context->context().add(qmlDesignerMainContext);
|
||||||
d->context->context().add(qmlDesignerFormEditorContext);
|
d->context->context().add(qmlDesignerFormEditorContext);
|
||||||
|
d->context->context().add(qmlDesignerEditor3dContext);
|
||||||
d->context->context().add(qmlDesignerNavigatorContext);
|
d->context->context().add(qmlDesignerNavigatorContext);
|
||||||
d->context->context().add(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID);
|
d->context->context().add(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID);
|
||||||
|
|
||||||
d->shortCutManager.registerActions(qmlDesignerMainContext, qmlDesignerFormEditorContext, qmlDesignerNavigatorContext);
|
d->shortCutManager.registerActions(qmlDesignerMainContext, qmlDesignerFormEditorContext,
|
||||||
|
qmlDesignerEditor3dContext, qmlDesignerNavigatorContext);
|
||||||
|
|
||||||
const QStringList mimeTypes = { QmlJSTools::Constants::QML_MIMETYPE,
|
const QStringList mimeTypes = { QmlJSTools::Constants::QML_MIMETYPE,
|
||||||
QmlJSTools::Constants::QMLUI_MIMETYPE };
|
QmlJSTools::Constants::QMLUI_MIMETYPE };
|
||||||
|
@@ -77,6 +77,7 @@ ShortCutManager::ShortCutManager()
|
|||||||
|
|
||||||
void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContext,
|
void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContext,
|
||||||
const Core::Context &qmlDesignerFormEditorContext,
|
const Core::Context &qmlDesignerFormEditorContext,
|
||||||
|
const Core::Context &qmlDesignerEditor3DContext,
|
||||||
const Core::Context &qmlDesignerNavigatorContext)
|
const Core::Context &qmlDesignerNavigatorContext)
|
||||||
{
|
{
|
||||||
Core::ActionContainer *editMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
|
Core::ActionContainer *editMenu = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
|
||||||
@@ -166,18 +167,21 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 280);
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 280);
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext);
|
||||||
|
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerEditor3DContext);
|
||||||
command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Cut);
|
command->setDefaultKeySequence(QKeySequence::Cut);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 260, Utils::Icons::CUT_TOOLBAR.icon());
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 260, Utils::Icons::CUT_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext);
|
||||||
|
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerEditor3DContext);
|
||||||
command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Copy);
|
command->setDefaultKeySequence(QKeySequence::Copy);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 250, Utils::Icons::COPY_TOOLBAR.icon());
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 250, Utils::Icons::COPY_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext);
|
||||||
|
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerEditor3DContext);
|
||||||
command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Paste);
|
command->setDefaultKeySequence(QKeySequence::Paste);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
@@ -209,14 +213,13 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [&designerActionManager, this](const Core::Context &context){
|
connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [&designerActionManager, this](const Core::Context &context){
|
||||||
if (!context.contains(Constants::C_QMLFORMEDITOR) && !context.contains(Constants::C_QMLNAVIGATOR)) {
|
if (!context.contains(Constants::C_QMLFORMEDITOR) && !context.contains(Constants::C_QMLEDITOR3D) && !context.contains(Constants::C_QMLNAVIGATOR)) {
|
||||||
m_deleteAction.setEnabled(false);
|
m_deleteAction.setEnabled(false);
|
||||||
m_cutAction.setEnabled(false);
|
m_cutAction.setEnabled(false);
|
||||||
m_copyAction.setEnabled(false);
|
m_copyAction.setEnabled(false);
|
||||||
m_pasteAction.setEnabled(false);
|
m_pasteAction.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
designerActionManager.view()->emitSelectionChanged();
|
designerActionManager.view()->emitSelectionChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
void registerActions(const Core::Context &qmlDesignerMainContext,
|
void registerActions(const Core::Context &qmlDesignerMainContext,
|
||||||
const Core::Context &qmlDesignerFormEditorContext,
|
const Core::Context &qmlDesignerFormEditorContext,
|
||||||
|
const Core::Context &qmlDesignerEditor3DContext,
|
||||||
const Core::Context &qmlDesignerNavigatorContext);
|
const Core::Context &qmlDesignerNavigatorContext);
|
||||||
|
|
||||||
void connectUndoActions(DesignDocument *designDocument);
|
void connectUndoActions(DesignDocument *designDocument);
|
||||||
|
Reference in New Issue
Block a user