diff --git a/src/plugins/coreplugin/icontext.cpp b/src/plugins/coreplugin/icontext.cpp index fe948c518c3..0aef68cdba4 100644 --- a/src/plugins/coreplugin/icontext.cpp +++ b/src/plugins/coreplugin/icontext.cpp @@ -41,6 +41,15 @@ void IContext::attach(QWidget *widget, const Context &context, const HelpItem &h ICore::addContextObject(icontext); } +void IContext::attach(QWidget *widget, const Context &context, const HelpProvider &helpProvider) +{ + auto icontext = new IContext(widget); // As QObject parent. + icontext->setContext(context); + icontext->setWidget(widget); + icontext->setContextHelpProvider(helpProvider); + ICore::addContextObject(icontext); +} + QDebug operator<<(QDebug debug, const Core::Context &context) { debug.nospace() << "Context("; diff --git a/src/plugins/coreplugin/icontext.h b/src/plugins/coreplugin/icontext.h index 2b836690fc9..41d7d150ca4 100644 --- a/src/plugins/coreplugin/icontext.h +++ b/src/plugins/coreplugin/icontext.h @@ -69,6 +69,9 @@ public: static void attach(QWidget *widget, const Context &context, const HelpItem &contextHelp = {}); + static void attach(QWidget *widget, + const Context &context, + const HelpProvider &helpProvider); protected: Context m_context; diff --git a/src/plugins/designer/formeditor.cpp b/src/plugins/designer/formeditor.cpp index e1e357f9754..4d478d2adc7 100644 --- a/src/plugins/designer/formeditor.cpp +++ b/src/plugins/designer/formeditor.cpp @@ -92,21 +92,6 @@ using namespace Utils; namespace Designer::Internal { -class DesignerContext final : public IContext -{ -public: - DesignerContext(const Context &context, QWidget *widget, QObject *parent) - : IContext(parent) - { - setContext(context); - setWidget(widget); - setContextHelpProvider([](const HelpCallback &callback) { - const QDesignerFormEditorInterface *core = designerEditor(); - callback(core->integration()->contextHelpId()); - }); - } -}; - /* A stub-like, read-only text editor which displays UI files as text. Could be used as a * read/write editor too, but due to lack of XML editor, highlighting and other such * functionality, editing is disabled. @@ -443,7 +428,11 @@ void FormEditorData::fullInit() Context designerContexts = m_contexts; designerContexts.add(Core::Constants::C_EDITORMANAGER); - ICore::addContextObject(new DesignerContext(designerContexts, m_modeWidget, this)); + + IContext::attach(m_modeWidget, designerContexts, [](const IContext::HelpCallback &callback) { + const QDesignerFormEditorInterface *core = designerEditor(); + callback(core->integration()->contextHelpId()); + }); DesignMode::registerDesignWidget(m_modeWidget, QStringList(Utils::Constants::FORM_MIMETYPE),