diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-08-01 20:31:02 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2023-08-02 08:38:46 +0000 |
commit | 5245cad8110423af5121f1262a79ec91b9fbcc1f (patch) | |
tree | 850400b7a9986b8796f1075dfd410d167bf3fb37 | |
parent | 8dd46d03998e41d86890bcb7daaa20c6425a89b4 (diff) |
ProjectExplorer: Add context object into connections
Change-Id: I50b9e8357881a2626e8026e7910399f0ae0a1d28
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
12 files changed, 32 insertions, 29 deletions
diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index f2f1d02310..4fe82b14cd 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -115,7 +115,7 @@ public: const auto selectionWidget = new CustomParsersSelectionWidget(this); layout->addWidget(selectionWidget); - connect(selectionWidget, &CustomParsersSelectionWidget::selectionChanged, + connect(selectionWidget, &CustomParsersSelectionWidget::selectionChanged, this, [selectionWidget, bc] { bc->setCustomParsers(selectionWidget->selectedParsers()); }); diff --git a/src/plugins/projectexplorer/customparser.cpp b/src/plugins/projectexplorer/customparser.cpp index 327e6ac844..c04b240d12 100644 --- a/src/plugins/projectexplorer/customparser.cpp +++ b/src/plugins/projectexplorer/customparser.cpp @@ -322,7 +322,7 @@ private: CustomParsersSelectionWidget::CustomParsersSelectionWidget(QWidget *parent) : DetailsWidget(parent) { const auto widget = new SelectionWidget(this); - connect(widget, &SelectionWidget::selectionChanged, [this] { + connect(widget, &SelectionWidget::selectionChanged, this, [this] { updateSummary(); emit selectionChanged(); }); diff --git a/src/plugins/projectexplorer/customparserssettingspage.cpp b/src/plugins/projectexplorer/customparserssettingspage.cpp index fd16d41ff6..b1238f684a 100644 --- a/src/plugins/projectexplorer/customparserssettingspage.cpp +++ b/src/plugins/projectexplorer/customparserssettingspage.cpp @@ -49,7 +49,7 @@ public: buttonLayout->addWidget(editButton); buttonLayout->addStretch(1); - connect(addButton, &QPushButton::clicked, [this] { + connect(addButton, &QPushButton::clicked, this, [this] { CustomParserConfigDialog dlg(this); dlg.setSettings(CustomParserSettings()); if (dlg.exec() != QDialog::Accepted) @@ -60,13 +60,13 @@ public: m_customParsers << newParser; resetListView(); }); - connect(removeButton, &QPushButton::clicked, [this] { + connect(removeButton, &QPushButton::clicked, this, [this] { const QList<QListWidgetItem *> sel = m_parserListView.selectedItems(); QTC_ASSERT(sel.size() == 1, return); m_customParsers.removeAt(m_parserListView.row(sel.first())); delete sel.first(); }); - connect(editButton, &QPushButton::clicked, [this] { + connect(editButton, &QPushButton::clicked, this, [this] { const QList<QListWidgetItem *> sel = m_parserListView.selectedItems(); QTC_ASSERT(sel.size() == 1, return); CustomParserSettings &s = m_customParsers[m_parserListView.row(sel.first())]; @@ -78,7 +78,7 @@ public: s.warning = dlg.settings().warning; }); - connect(&m_parserListView, &QListWidget::itemChanged, [this](QListWidgetItem *item) { + connect(&m_parserListView, &QListWidget::itemChanged, this, [this](QListWidgetItem *item) { m_customParsers[m_parserListView.row(item)].displayName = item->text(); resetListView(); }); diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index fa5d41a623..cb05e25a38 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -1508,8 +1508,8 @@ void ClangToolChain::syncAutodetectedWithParentToolchains() QObject::disconnect(m_mingwToolchainAddedConnection); if (!ToolChainManager::isLoaded()) { - QObject::connect(ToolChainManager::instance(), &ToolChainManager::toolChainsLoaded, - [id = id()] { + connect(ToolChainManager::instance(), &ToolChainManager::toolChainsLoaded, this, + [id = id()] { if (ToolChain * const tc = ToolChainManager::findToolChain(id)) { if (tc->typeId() == Constants::CLANG_TOOLCHAIN_TYPEID) static_cast<ClangToolChain *>(tc)->syncAutodetectedWithParentToolchains(); @@ -1526,14 +1526,14 @@ void ClangToolChain::syncAutodetectedWithParentToolchains() // Subscribe only autodetected toolchains. ToolChainManager *tcManager = ToolChainManager::instance(); m_mingwToolchainAddedConnection - = QObject::connect(tcManager, &ToolChainManager::toolChainAdded, [this](ToolChain *tc) { + = connect(tcManager, &ToolChainManager::toolChainAdded, this, [this](ToolChain *tc) { if (tc->typeId() == Constants::MINGW_TOOLCHAIN_TYPEID && !mingwToolChainFromId(m_parentToolChainId)) { m_parentToolChainId = tc->id(); } }); m_thisToolchainRemovedConnection - = QObject::connect(tcManager, &ToolChainManager::toolChainRemoved, [this](ToolChain *tc) { + = connect(tcManager, &ToolChainManager::toolChainRemoved, this, [this](ToolChain *tc) { if (tc == this) { QObject::disconnect(m_thisToolchainRemovedConnection); QObject::disconnect(m_mingwToolchainAddedConnection); diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index 19aa8923d5..9b90effa3b 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -780,7 +780,7 @@ void MsvcToolChain::environmentModifications(QPromise<MsvcToolChain::GenerateEnv void MsvcToolChain::initEnvModWatcher(const QFuture<GenerateEnvResult> &future) { - QObject::connect(&m_envModWatcher, &QFutureWatcher<GenerateEnvResult>::resultReadyAt, [&]() { + connect(&m_envModWatcher, &QFutureWatcher<GenerateEnvResult>::resultReadyAt, this, [this] { const GenerateEnvResult &result = m_envModWatcher.result(); if (result.error) { QString errorMessage = *result.error; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 111aec12aa..d31f2a7a8a 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1290,7 +1290,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // FIXME: This menu will never become visible if the user tried to open it once // without a project loaded. - connect(generatorContainer->menu(), &QMenu::aboutToShow, [menu = generatorContainer->menu()] { + connect(generatorContainer->menu(), &QMenu::aboutToShow, + this, [menu = generatorContainer->menu()] { menu->clear(); if (Project * const project = ProjectManager::startupProject()) { for (const auto &generator : project->allGenerators()) { @@ -3124,8 +3125,8 @@ void ProjectExplorerPluginPrivate::updateUnloadProjectMenu() menu->clear(); for (Project *project : ProjectManager::projects()) { QAction *action = menu->addAction(Tr::tr("Close Project \"%1\"").arg(project->displayName())); - connect(action, &QAction::triggered, - [project] { ProjectExplorerPlugin::unloadProject(project); } ); + connect(action, &QAction::triggered, this, + [project] { ProjectExplorerPlugin::unloadProject(project); }); } } @@ -3853,7 +3854,8 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFileName) const HandleIncludeGuards handleGuards = canTryToRenameIncludeGuards(node); if (!folderNode->canRenameFile(oldFilePath, newFilePath)) { - QTimer::singleShot(0, [oldFilePath, newFilePath, projectFileName, handleGuards] { + QTimer::singleShot(0, m_instance, + [oldFilePath, newFilePath, projectFileName, handleGuards] { int res = QMessageBox::question(ICore::dialogParent(), Tr::tr("Project Editing Failed"), Tr::tr("The project file %1 cannot be automatically changed.\n\n" @@ -3877,7 +3879,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFileName) .arg(newFilePath.toUserOutput()) .arg(projectFileName); - QTimer::singleShot(0, [renameFileError] { + QTimer::singleShot(0, m_instance, [renameFileError] { QMessageBox::warning(ICore::dialogParent(), Tr::tr("Project Editing Failed"), renameFileError); @@ -3888,7 +3890,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFileName) .arg(oldFilePath.toUserOutput()) .arg(newFilePath.toUserOutput()); - QTimer::singleShot(0, [renameFileError] { + QTimer::singleShot(0, m_instance, [renameFileError] { QMessageBox::warning(ICore::dialogParent(), Tr::tr("Cannot Rename File"), renameFileError); }); } diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index 5def44f948..1b2b1b1edc 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -523,14 +523,14 @@ public: QAction *action = new QAction(Tr::tr("Remove Project from Recent Projects")); const auto projectModel = qobject_cast<ProjectModel *>(model); contextMenu.addAction(action); - connect(action, &QAction::triggered, [idx, projectModel](){ + connect(action, &QAction::triggered, this, [idx, projectModel] { const QVariant projectFile = idx.data(ProjectModel::FilePathRole); ProjectExplorerPlugin::removeFromRecentProjects(FilePath::fromVariant(projectFile)); projectModel->resetProjects(); }); contextMenu.addSeparator(); action = new QAction(Tr::tr("Clear Recent Project List")); - connect(action, &QAction::triggered, [projectModel]() { + connect(action, &QAction::triggered, this, [projectModel] { ProjectExplorerPlugin::clearRecentProjects(); projectModel->resetProjects(); }); diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 980dec8bf8..806e387fdf 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -855,7 +855,7 @@ void InterpreterAspect::addToLayout(LayoutItem &builder) this, &InterpreterAspect::updateCurrentInterpreter); auto manageButton = new QPushButton(Tr::tr("Manage...")); - connect(manageButton, &QPushButton::clicked, [this] { + connect(manageButton, &QPushButton::clicked, this, [this] { Core::ICore::showOptionsDialog(m_settingsDialogId); }); diff --git a/src/plugins/projectexplorer/runsettingspropertiespage.cpp b/src/plugins/projectexplorer/runsettingspropertiespage.cpp index 1aeecabf95..0b780cee3e 100644 --- a/src/plugins/projectexplorer/runsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/runsettingspropertiespage.cpp @@ -324,7 +324,7 @@ void RunSettingsWidget::aboutToShowDeployMenu() for (DeployConfigurationFactory *factory : DeployConfigurationFactory::find(m_target)) { QAction *action = m_addDeployMenu->addAction(factory->defaultDisplayName()); - connect(action, &QAction::triggered, [factory, this]() { + connect(action, &QAction::triggered, this, [factory, this] { DeployConfiguration *newDc = factory->create(m_target); if (!newDc) return; diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 58603a64f9..c829e4f087 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -241,17 +241,17 @@ TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>()) connect(hub, &TaskHub::showTask, this, &TaskWindow::showTask); connect(hub, &TaskHub::openTask, this, &TaskWindow::openTask); - connect(d->m_filter, &TaskFilterModel::rowsAboutToBeRemoved, + connect(d->m_filter, &TaskFilterModel::rowsAboutToBeRemoved, this, [this](const QModelIndex &, int first, int last) { d->m_visibleIssuesCount -= d->m_filter->issuesCount(first, last); emit setBadgeNumber(d->m_visibleIssuesCount); }); - connect(d->m_filter, &TaskFilterModel::rowsInserted, + connect(d->m_filter, &TaskFilterModel::rowsInserted, this, [this](const QModelIndex &, int first, int last) { d->m_visibleIssuesCount += d->m_filter->issuesCount(first, last); emit setBadgeNumber(d->m_visibleIssuesCount); }); - connect(d->m_filter, &TaskFilterModel::modelReset, [this] { + connect(d->m_filter, &TaskFilterModel::modelReset, this, [this] { d->m_visibleIssuesCount = d->m_filter->issuesCount(0, d->m_filter->rowCount()); emit setBadgeNumber(d->m_visibleIssuesCount); }); diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index a0dc19392e..8954a93fa1 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -210,7 +210,7 @@ public: m_addButton->setStyleSheet("text-align:center;"); m_cloneButton = new QPushButton(Tr::tr("Clone"), this); - connect(m_cloneButton, &QAbstractButton::clicked, [this] { cloneToolChain(); }); + connect(m_cloneButton, &QAbstractButton::clicked, this, [this] { cloneToolChain(); }); m_delButton = new QPushButton(Tr::tr("Remove"), this); @@ -280,7 +280,7 @@ public: connect(ToolChainManager::instance(), &ToolChainManager::toolChainsChanged, this, &ToolChainOptionsWidget::toolChainSelectionChanged); - connect(m_delButton, &QAbstractButton::clicked, [this] { + connect(m_delButton, &QAbstractButton::clicked, this, [this] { if (ToolChainTreeItem *item = currentTreeItem()) markForRemoval(item); }); @@ -303,7 +303,8 @@ public: QAction *createAction(const QString &name, ToolChainFactory *factory, Utils::Id language) { auto action = new QAction(name, nullptr); - connect(action, &QAction::triggered, [this, factory, language] { createToolChain(factory, language); }); + connect(action, &QAction::triggered, this, + [this, factory, language] { createToolChain(factory, language); }); return action; } diff --git a/src/plugins/qbsprojectmanager/qbssettings.cpp b/src/plugins/qbsprojectmanager/qbssettings.cpp index d631f23ced..87d5b5b284 100644 --- a/src/plugins/qbsprojectmanager/qbssettings.cpp +++ b/src/plugins/qbsprojectmanager/qbssettings.cpp @@ -172,10 +172,10 @@ public: layout->addRow(Tr::tr("Default installation directory:"), &m_defaultInstallDirLineEdit); layout->addRow(Tr::tr("Qbs version:"), &m_versionLabel); - connect(&m_qbsExePathChooser, &PathChooser::textChanged, [this] { + connect(&m_qbsExePathChooser, &PathChooser::textChanged, this, [this] { m_versionLabel.setText(getQbsVersionString()); }); - connect(&m_resetQbsExeButton, &QPushButton::clicked, [this] { + connect(&m_resetQbsExeButton, &QPushButton::clicked, this, [this] { m_qbsExePathChooser.setFilePath(QbsSettings::defaultQbsExecutableFilePath()); }); } |