Welcome/PE: Use new IContext::attach() function

Change-Id: I793dfc5b4d9143a71fb388335d33816620c04477
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-07-04 10:02:34 +02:00
parent f0d125f35a
commit d37ca65d4f
3 changed files with 7 additions and 18 deletions

View File

@@ -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);

View File

@@ -17,7 +17,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/session.h>
#include <utils/algorithm.h>
@@ -33,12 +32,9 @@
#include <utils/utilsicons.h>
#include <QAbstractTextDocumentLayout>
#include <QApplication>
#include <QDir>
#include <QLabel>
#include <QMenu>
#include <QPainter>
#include <QScrollBar>
#include <QStyledItemDelegate>
#include <QTextDocument>
#include <QToolButton>
@@ -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<const QAction *, ITaskHandler *> m_actionToHandlerMap;
ITaskHandler *m_defaultHandler = nullptr;
QToolButton *m_filterWarningsButton;
@@ -194,10 +190,7 @@ TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>())
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);

View File

@@ -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);
}