void QmlDesignerPlugin::createDesignModeWidget() { d->mainWidget = new Internal::DesignModeWidget; d->context = new Internal::DesignModeContext(d->mainWidget); Core::ICore::addContextObject(d->context); Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER); Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR); Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR); d->context->context().add(qmlDesignerMainContext); d->context->context().add(qmlDesignerFormEditorContext); d->context->context().add(qmlDesignerNavigatorContext); d->context->context().add(ProjectExplorer::Constants::LANG_QMLJS); d->shortCutManager.registerActions(qmlDesignerMainContext, qmlDesignerFormEditorContext, qmlDesignerNavigatorContext); connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged, [=] (Core::IEditor *editor) { if (d && checkIfEditorIsQtQuick(editor) && isInDesignerMode()) { d->shortCutManager.updateActions(editor); changeEditor(); } }); connect(Core::EditorManager::instance(), &Core::EditorManager::editorsClosed, [=] (QList<Core::IEditor*> editors) { if (d) { if (d->documentManager.hasCurrentDesignDocument() && editors.contains(d->documentManager.currentDesignDocument()->textEditor())) hideDesigner(); d->documentManager.removeEditors(editors); } }); connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeChanged, [=] (Core::Id newMode, Core::Id oldMode) { if (d && Core::EditorManager::currentEditor() && checkIfEditorIsQtQuick (Core::EditorManager::currentEditor()) && !documentIsAlreadyOpen( currentDesignDocument(), Core::EditorManager::currentEditor(), newMode)) { if (!isDesignerMode(newMode) && isDesignerMode(oldMode)) hideDesigner(); else if (Core::EditorManager::currentEditor() && isDesignerMode(newMode)) showDesigner(); else if (currentDesignDocument()) hideDesigner(); } }); }
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode) { if (Core::EditorManager::currentEditor() && checkIfEditorIsQtQuick(Core::EditorManager::currentEditor()) && !documentIsAlreadyOpen(currentDesignDocument(), Core::EditorManager::currentEditor(), newMode)) { if (!isDesignerMode(newMode) && isDesignerMode(oldMode)) hideDesigner(); else if (Core::EditorManager::currentEditor() && isDesignerMode(newMode) && isQmlFile(Core::EditorManager::currentEditor())) showDesigner(); else if (currentDesignDocument()) hideDesigner(); } }