forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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());
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -1508,7 +1508,7 @@ void ClangToolChain::syncAutodetectedWithParentToolchains()
|
||||
QObject::disconnect(m_mingwToolchainAddedConnection);
|
||||
|
||||
if (!ToolChainManager::isLoaded()) {
|
||||
QObject::connect(ToolChainManager::instance(), &ToolChainManager::toolChainsLoaded,
|
||||
connect(ToolChainManager::instance(), &ToolChainManager::toolChainsLoaded, this,
|
||||
[id = id()] {
|
||||
if (ToolChain * const tc = ToolChainManager::findToolChain(id)) {
|
||||
if (tc->typeId() == Constants::CLANG_TOOLCHAIN_TYPEID)
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,7 +3125,7 @@ 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,
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user