diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp index 4f8d40a9ca64ba5e25d51f5bc868cec7fef30b39..34473c5ebb55755dc36dd8734d5dbc60ddbf1336 100644 --- a/src/plugins/coreplugin/designmode.cpp +++ b/src/plugins/coreplugin/designmode.cpp @@ -174,6 +174,11 @@ QStringList DesignMode::registeredMimeTypes() const return rc; } +/** + * Registers a widget to be displayed when an editor with a file specified in + * mimeTypes is opened. This also appends the additionalContext in ICore to + * the context, specified here. + */ void DesignMode::registerDesignWidget(QWidget *widget, const QStringList &mimeTypes, const QList<int> &context, diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 708860db70ede03748d9a90c7950cbe858aef7e4..23572260ccc4f089838ab6c1acb08a71f2544fec 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -159,7 +159,8 @@ void DesignModeWidget::showEditor(Core::IEditor *editor) fileName = editor->file()->fileName(); textEdit = qobject_cast<QPlainTextEdit*>(editor->widget()); textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); - m_fakeToolBar->addEditor(textEditor); + if (textEditor) + m_fakeToolBar->addEditor(textEditor); } if (debug) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 99cf54933bcdc75174c638d1485bd92a7a95dd41..16f1dfe7a8cbe1a2171a6f1dea0f9f28b1aab8cd 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -43,6 +43,7 @@ #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/command.h> #include <coreplugin/icore.h> +#include <coreplugin/icontext.h> #include <coreplugin/dialogs/iwizard.h> #include <coreplugin/editormanager/ieditorfactory.h> #include <coreplugin/editormanager/editormanager.h> @@ -227,8 +228,9 @@ void BauhausPlugin::createDesignModeWidget() connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)), this, SLOT(textEditorsClosed(QList<Core::IEditor*>))); - connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), - this, SLOT(modeChanged(Core::IMode*))); + connect(creatorCore, SIGNAL(contextChanged(Core::IContext*,QList<int>)), + this, SLOT(contextChanged(Core::IContext*,QList<int>))); + } void BauhausPlugin::updateEditor(Core::IEditor *editor) @@ -241,17 +243,22 @@ void BauhausPlugin::updateEditor(Core::IEditor *editor) } } -void BauhausPlugin::modeChanged(Core::IMode *mode) +void BauhausPlugin::contextChanged(Core::IContext *context, const QList<int> &additionalContexts) { - if (mode == m_designMode) { - m_isActive = true; - m_mainWidget->showEditor(m_editorManager->currentEditor()); - } else { - if (m_isActive) { - m_isActive = false; - m_mainWidget->showEditor(0); + Q_UNUSED(context) + + foreach(int additionalContext, additionalContexts) { + if (m_context->context().contains(additionalContext)) { + m_isActive = true; + m_mainWidget->showEditor(m_editorManager->currentEditor()); + return; } } + + if (m_isActive) { + m_isActive = false; + m_mainWidget->showEditor(0); + } } void BauhausPlugin::textEditorsClosed(QList<Core::IEditor*> editors) diff --git a/src/plugins/qmldesigner/qmldesignerplugin.h b/src/plugins/qmldesigner/qmldesignerplugin.h index 230535dcfc1fdbf1943011135b5e9ca7e303f10e..bd1194547baa2b877abc46292fcc9d43e64c08b6 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.h +++ b/src/plugins/qmldesigner/qmldesignerplugin.h @@ -42,6 +42,7 @@ class QAction; QT_END_NAMESPACE namespace Core { + class IContext; class IWizard; class ICore; class IEditorFactory; @@ -84,7 +85,7 @@ private slots: void textEditorsClosed(QList<Core::IEditor *> editors); void updateActions(Core::IEditor* editor); void updateEditor(Core::IEditor *editor); - void modeChanged(Core::IMode *mode); + void contextChanged(Core::IContext *context, const QList<int> &additionalContexts); private: void createDesignModeWidget();