diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 97041931a3f..3d93a6edc69 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -912,10 +912,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er auto splitter = new MiniSplitter(Qt::Vertical); splitter->addWidget(dd->m_proWindow); splitter->addWidget(new OutputPanePlaceHolder(Constants::MODE_SESSION, splitter)); - auto context = new IContext(splitter); - context->setWidget(splitter); - context->setContextHelp("Managing Projects"); - ICore::addContextObject(context); + + IContext::attach(splitter, {}, "Managing Projects"); + dd->m_projectsMode.setWidget(splitter); dd->m_projectsMode.setEnabled(false); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 95679825025..0d48288cc93 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -33,12 +32,9 @@ #include #include -#include -#include #include #include #include -#include #include #include #include @@ -143,7 +139,7 @@ public: Internal::TaskModel *m_model; Internal::TaskFilterModel *m_filter; TaskView m_treeView; - Core::IContext *m_taskWindowContext; + const Core::Context m_taskWindowContext{Core::Context(Core::Constants::C_PROBLEM_PANE)}; QHash m_actionToHandlerMap; ITaskHandler *m_defaultHandler = nullptr; QToolButton *m_filterWarningsButton; @@ -194,10 +190,7 @@ TaskWindow::TaskWindow() : d(std::make_unique()) d->m_treeView.setAttribute(Qt::WA_MacShowFocusRect, false); d->m_treeView.resizeColumns(); - d->m_taskWindowContext = new Core::IContext(&d->m_treeView); - d->m_taskWindowContext->setWidget(&d->m_treeView); - d->m_taskWindowContext->setContext(Core::Context(Core::Constants::C_PROBLEM_PANE)); - Core::ICore::addContextObject(d->m_taskWindowContext); + Core::IContext::attach(&d->m_treeView, d->m_taskWindowContext); connect(d->m_treeView.selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex &index) { d->m_treeView.scrollTo(index); }); @@ -298,7 +291,7 @@ void TaskWindow::delayedInitialization() Id id = h->actionManagerId(); if (id.isValid()) { Core::Command *cmd = - Core::ActionManager::registerAction(action, id, d->m_taskWindowContext->context(), true); + Core::ActionManager::registerAction(action, id, d->m_taskWindowContext, true); action = cmd->action(); } d->m_treeView.addAction(action); diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index cef07005561..81623e1e72d 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -345,10 +345,7 @@ WelcomeMode::WelcomeMode() spacing(0), }.attachTo(m_modeWidget); - auto context = new IContext(m_modeWidget); - context->setWidget(m_modeWidget); - context->setContextHelp("Qt Creator Manual"); - ICore::addContextObject(context); + IContext::attach(m_modeWidget, {}, "Qt Creator Manual"); setWidget(m_modeWidget); }