diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-12-07 16:25:11 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-12-08 08:50:07 +0000 |
commit | 5769fd82d3cab9a0f2eb30a1cfbbf20aa09d3859 (patch) | |
tree | 5dc490880f3862db7eb77525a2f8852d6f7d8b92 | |
parent | 94e98281e97cb3150f3e121228b2de2256dd5aff (diff) | |
download | qt-creator-5769fd82d3cab9a0f2eb30a1cfbbf20aa09d3859.tar.gz |
CorePlugin: Pass context object to lambda connections
Remove some unneeded lambda () brackets.
Change-Id: Id664cfc3b46685f63fb205beaf16a7c271ad95d9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
23 files changed, 85 insertions, 86 deletions
diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp index 4d89f7861c..701defb9c7 100644 --- a/src/plugins/coreplugin/actionmanager/command.cpp +++ b/src/plugins/coreplugin/actionmanager/command.cpp @@ -525,10 +525,10 @@ QAction *Command::touchBarAction() const void Command::augmentActionWithShortcutToolTip(QAction *a) const { a->setToolTip(stringWithAppendedShortcut(a->text())); - QObject::connect(this, &Command::keySequenceChanged, a, [this, a]() { + QObject::connect(this, &Command::keySequenceChanged, a, [this, a] { a->setToolTip(stringWithAppendedShortcut(a->text())); }); - QObject::connect(a, &QAction::changed, this, [this, a]() { + QObject::connect(a, &QAction::changed, this, [this, a] { a->setToolTip(stringWithAppendedShortcut(a->text())); }); } diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 3cb41fa1b5..ba99755164 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -171,52 +171,52 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) MacroExpander *expander = Utils::globalMacroExpander(); expander->registerVariable("CurrentDate:ISO", tr("The current date (ISO)."), - []() { return QDate::currentDate().toString(Qt::ISODate); }); + [] { return QDate::currentDate().toString(Qt::ISODate); }); expander->registerVariable("CurrentTime:ISO", tr("The current time (ISO)."), - []() { return QTime::currentTime().toString(Qt::ISODate); }); + [] { return QTime::currentTime().toString(Qt::ISODate); }); expander->registerVariable("CurrentDate:RFC", tr("The current date (RFC2822)."), - []() { return QDate::currentDate().toString(Qt::RFC2822Date); }); + [] { return QDate::currentDate().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentTime:RFC", tr("The current time (RFC2822)."), - []() { return QTime::currentTime().toString(Qt::RFC2822Date); }); + [] { return QTime::currentTime().toString(Qt::RFC2822Date); }); expander->registerVariable("CurrentDate:Locale", tr("The current date (Locale)."), - []() { return QLocale::system() + [] { return QLocale::system() .toString(QDate::currentDate(), QLocale::ShortFormat); }); expander->registerVariable("CurrentTime:Locale", tr("The current time (Locale)."), - []() { return QLocale::system() + [] { return QLocale::system() .toString(QTime::currentTime(), QLocale::ShortFormat); }); expander->registerVariable("Config:DefaultProjectDirectory", tr("The configured default directory for projects."), - []() { return DocumentManager::projectsDirectory().toString(); }); + [] { return DocumentManager::projectsDirectory().toString(); }); expander->registerVariable("Config:LastFileDialogDirectory", tr("The directory last visited in a file dialog."), - []() { return DocumentManager::fileDialogLastVisitedDirectory().toString(); }); + [] { return DocumentManager::fileDialogLastVisitedDirectory().toString(); }); expander->registerVariable("HostOs:isWindows", tr("Is %1 running on Windows?").arg(Constants::IDE_DISPLAY_NAME), - []() { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); }); + [] { return QVariant(Utils::HostOsInfo::isWindowsHost()).toString(); }); expander->registerVariable("HostOs:isOSX", tr("Is %1 running on OS X?").arg(Constants::IDE_DISPLAY_NAME), - []() { return QVariant(Utils::HostOsInfo::isMacHost()).toString(); }); + [] { return QVariant(Utils::HostOsInfo::isMacHost()).toString(); }); expander->registerVariable("HostOs:isLinux", tr("Is %1 running on Linux?").arg(Constants::IDE_DISPLAY_NAME), - []() { return QVariant(Utils::HostOsInfo::isLinuxHost()).toString(); }); + [] { return QVariant(Utils::HostOsInfo::isLinuxHost()).toString(); }); expander->registerVariable("HostOs:isUnix", tr("Is %1 running on any unix-based platform?") .arg(Constants::IDE_DISPLAY_NAME), - []() { return QVariant(Utils::HostOsInfo::isAnyUnixHost()).toString(); }); + [] { return QVariant(Utils::HostOsInfo::isAnyUnixHost()).toString(); }); expander->registerVariable("HostOs:PathListSeparator", tr("The path list separator for the platform."), - []() { return QString(Utils::HostOsInfo::pathListSeparator()); }); + [] { return QString(Utils::HostOsInfo::pathListSeparator()); }); expander->registerVariable("HostOs:ExecutableSuffix", tr("The platform executable suffix."), - []() { return QString(Utils::HostOsInfo::withExecutableSuffix("")); }); + [] { return QString(Utils::HostOsInfo::withExecutableSuffix("")); }); expander->registerVariable("IDE:ResourcePath", tr("The directory where %1 finds its pre-installed resources.") .arg(Constants::IDE_DISPLAY_NAME), - []() { return ICore::resourcePath().toString(); }); + [] { return ICore::resourcePath().toString(); }); expander->registerPrefix("CurrentDate:", tr("The current date (QDate formatstring)."), [](const QString &fmt) { return QDate::currentDate().toString(fmt); }); expander->registerPrefix("CurrentTime:", tr("The current time (QTime formatstring)."), [](const QString &fmt) { return QTime::currentTime().toString(fmt); }); expander->registerVariable("UUID", tr("Generate a new UUID."), - []() { return QUuid::createUuid().toString(); }); + [] { return QUuid::createUuid().toString(); }); expander->registerPrefix("#:", tr("A comment."), [](const QString &) { return QString(); }); @@ -264,7 +264,7 @@ static void registerActionsForOptions() const QString actionTitle = Tr::tr("%1 > %2 Preferences...") .arg(categoryDisplay.value(page->category()), page->displayName()); auto action = new QAction(actionTitle, m_instance); - QObject::connect(action, &QAction::triggered, m_instance, [id = page->id()]() { + QObject::connect(action, &QAction::triggered, m_instance, [id = page->id()] { ICore::showOptionsDialog(id); }); ActionManager::registerAction(action, commandId); @@ -299,10 +299,9 @@ QObject *CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args) { if (!ExtensionSystem::PluginManager::isInitializationDone()) { - connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::initializationDone, - this, [this, workingDirectory, args]() { - remoteCommand(QStringList(), workingDirectory, args); - }); + connect(ExtensionSystem::PluginManager::instance(), + &ExtensionSystem::PluginManager::initializationDone, + this, [=] { remoteCommand(QStringList(), workingDirectory, args); }); return nullptr; } const FilePaths filePaths = Utils::transform(args, FilePath::fromUserInput); @@ -350,13 +349,13 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM if (QDir().exists(pathChooser->filePath().toString())) { auto *showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), menu); - connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser]() { + connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser] { Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->filePath()); }); menu->insertAction(firstAction, showInGraphicalShell); auto *showInTerminal = new QAction(Core::FileUtils::msgTerminalHereAction(), menu); - connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser]() { + connect(showInTerminal, &QAction::triggered, pathChooser, [pathChooser] { if (pathChooser->openTerminalHandler()) pathChooser->openTerminalHandler()(); else @@ -366,7 +365,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM } else { auto *mkPathAct = new QAction(tr("Create Folder"), menu); - connect(mkPathAct, &QAction::triggered, pathChooser, [pathChooser]() { + connect(mkPathAct, &QAction::triggered, pathChooser, [pathChooser] { QDir().mkpath(pathChooser->filePath().toString()); pathChooser->triggerChanged(); }); @@ -380,7 +379,7 @@ void CorePlugin::addToPathChooserContextMenu(Utils::PathChooser *pathChooser, QM void CorePlugin::checkSettings() { const auto showMsgBox = [this](const QString &msg, QMessageBox::Icon icon) { - connect(ICore::instance(), &ICore::coreOpened, this, [msg, icon]() { + connect(ICore::instance(), &ICore::coreOpened, this, [msg, icon] { QMessageBox msgBox(ICore::dialogParent()); msgBox.setWindowTitle(tr("Settings File Error")); msgBox.setText(msg); diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp index 101b888056..08325a24cf 100644 --- a/src/plugins/coreplugin/designmode.cpp +++ b/src/plugins/coreplugin/designmode.cpp @@ -56,7 +56,7 @@ static DesignModePrivate *d = nullptr; DesignMode::DesignMode() { - ICore::addPreCloseListener([]() -> bool { + ICore::addPreCloseListener([] { m_instance->currentEditorChanged(nullptr); return true; }); diff --git a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp index 4125f45847..fa72ae0bae 100644 --- a/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/filepropertiesdialog.cpp @@ -84,13 +84,13 @@ FilePropertiesDialog::FilePropertiesDialog(const FilePath &filePath, QWidget *pa }.attachTo(this); // clang-format on - connect(m_readable, &QCheckBox::clicked, [this](bool checked) { + connect(m_readable, &QCheckBox::clicked, this, [this](bool checked) { setPermission(QFile::ReadUser | QFile::ReadOwner, checked); }); - connect(m_writable, &QCheckBox::clicked, [this](bool checked) { + connect(m_writable, &QCheckBox::clicked, this, [this](bool checked) { setPermission(QFile::WriteUser | QFile::WriteOwner, checked); }); - connect(m_executable, &QCheckBox::clicked, [this](bool checked) { + connect(m_executable, &QCheckBox::clicked, this, [this](bool checked) { setPermission(QFile::ExeUser | QFile::ExeOwner, checked); }); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); diff --git a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp index 4e0db083be..c744e1c736 100644 --- a/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp +++ b/src/plugins/coreplugin/dialogs/readonlyfilesdialog.cpp @@ -490,7 +490,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const FilePaths &filePaths) // Also save the buttongroup for every file to get the result for each entry. buttonGroups.append({filePath, radioButtonGroup}); QObject::connect(radioButtonGroup, &QButtonGroup::buttonClicked, - [this] { updateSelectAll(); }); + q, [this] { updateSelectAll(); }); } // Apply the Mac file dialog style. @@ -543,7 +543,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const FilePaths &filePaths) m_setAll->addItem(saveAsText); setAllIndexForOperation[SaveAs] = m_setAll->count() - 1; } - QObject::connect(m_setAll, &QComboBox::activated, [this](int index) { setAll(index); }); + QObject::connect(m_setAll, &QComboBox::activated, q, [this](int index) { setAll(index); }); // Filter which columns should be visible and resize them to content. for (int i = 0; i < NumberOfColumns; ++i) { diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index bceee3b1a2..f3edb6d612 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -231,7 +231,7 @@ void DocumentManagerPrivate::registerSaveAllAction() cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? QString() : tr("Ctrl+Shift+S"))); mfile->addAction(cmd, Constants::G_FILE_SAVE); m_saveAllAction->setEnabled(false); - connect(m_saveAllAction, &QAction::triggered, []() { + connect(m_saveAllAction, &QAction::triggered, [] { DocumentManager::saveAllModifiedDocumentsSilently(); }); } diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index eb3d9b1e32..4a7cdd3d13 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -451,7 +451,7 @@ void EditorManagerPrivate::init() // Save Action ActionManager::registerAction(m_saveAction, Constants::SAVE, editManagerContext); - connect(m_saveAction, &QAction::triggered, m_instance, []() { EditorManager::saveDocument(); }); + connect(m_saveAction, &QAction::triggered, m_instance, [] { EditorManager::saveDocument(); }); // Save As Action ActionManager::registerAction(m_saveAsAction, Constants::SAVEAS, editManagerContext); @@ -494,7 +494,7 @@ void EditorManagerPrivate::init() mfile->addAction(cmd, Constants::G_FILE_CLOSE); cmd->setAttribute(Command::CA_UpdateText); connect(m_closeOtherDocumentsAction, &QAction::triggered, - m_instance, []() { EditorManager::closeOtherDocuments(); }); + m_instance, [] { EditorManager::closeOtherDocuments(); }); // Close All Others Except Visible Action cmd = ActionManager::registerAction(m_closeAllEditorsExceptVisibleAction, Constants::CLOSEALLEXCEPTVISIBLE, editManagerContext, true); @@ -563,7 +563,7 @@ void EditorManagerPrivate::init() connect(m_openTerminalAction, &QAction::triggered, this, &EditorManagerPrivate::openTerminal); connect(m_findInDirectoryAction, &QAction::triggered, this, &EditorManagerPrivate::findInDirectory); - connect(m_filePropertiesAction, &QAction::triggered, this, []() { + connect(m_filePropertiesAction, &QAction::triggered, this, [] { if (!d->m_contextMenuEntry || d->m_contextMenuEntry->filePath().isEmpty()) return; DocumentManager::showFilePropertiesDialog(d->m_contextMenuEntry->filePath()); @@ -608,7 +608,7 @@ void EditorManagerPrivate::init() cmd = ActionManager::registerAction(m_splitAction, Constants::SPLIT, editManagerContext); cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+E,2") : tr("Ctrl+E,2"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); - connect(m_splitAction, &QAction::triggered, this, []() { split(Qt::Vertical); }); + connect(m_splitAction, &QAction::triggered, this, [] { split(Qt::Vertical); }); m_splitSideBySideAction = new QAction(Utils::Icons::SPLIT_VERTICAL.icon(), tr("Split Side by Side"), this); @@ -622,7 +622,7 @@ void EditorManagerPrivate::init() cmd->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+E,4") : tr("Ctrl+E,4"))); mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT); connect(m_splitNewWindowAction, &QAction::triggered, - this, []() { splitNewWindow(currentEditorView()); }); + this, [] { splitNewWindow(currentEditorView()); }); m_removeCurrentSplitAction = new QAction(tr("Remove Current Split"), this); cmd = ActionManager::registerAction(m_removeCurrentSplitAction, Constants::REMOVE_CURRENT_SPLIT, editManagerContext); @@ -718,7 +718,7 @@ void EditorManagerPrivate::extensionsInitialized() { // Do not ask for files to save. // MainWindow::closeEvent has already done that. - ICore::addPreCloseListener([]() -> bool { return EditorManager::closeAllEditors(false); }); + ICore::addPreCloseListener([] { return EditorManager::closeAllEditors(false); }); } EditorManagerPrivate *EditorManagerPrivate::instance() @@ -894,7 +894,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const FilePath &file auto menu = new QMenu(button); for (EditorType *factory : std::as_const(factories)) { QAction *action = menu->addAction(factory->displayName()); - connect(action, &QAction::triggered, &msgbox, [&selectedFactory, factory, &msgbox]() { + connect(action, &QAction::triggered, &msgbox, [&selectedFactory, factory, &msgbox] { selectedFactory = factory; msgbox.done(QMessageBox::Open); }); @@ -2967,18 +2967,13 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const FilePath &filePath) // is inside of a qrc file itself, and the qrc editor opens the Open with menu, // crashes happen, because the editor instance is deleted by openEditorWith // while the menu is still being processed. - connect( - action, - &QAction::triggered, - d, - [filePath, editorId]() { - EditorType *type = EditorType::editorTypeForId(editorId); - if (type && type->asExternalEditor()) - EditorManager::openExternalEditor(filePath, editorId); - else - EditorManagerPrivate::openEditorWith(filePath, editorId); - }, - Qt::QueuedConnection); + connect(action, &QAction::triggered, d, [filePath, editorId] { + EditorType *type = EditorType::editorTypeForId(editorId); + if (type && type->asExternalEditor()) + EditorManager::openExternalEditor(filePath, editorId); + else + EditorManagerPrivate::openEditorWith(filePath, editorId); + }, Qt::QueuedConnection); } } menu->setEnabled(anyMatches); diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 643f44498f..a15110e47b 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -167,7 +167,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) : // this signal is disconnected for standalone toolbars and replaced with // a private slot connection connect(d->m_editorList, &QComboBox::activated, this, &EditorToolBar::listSelectionActivated); - connect(d->m_editorList, &QComboBox::customContextMenuRequested, [this](QPoint p) { + connect(d->m_editorList, &QComboBox::customContextMenuRequested, this, [this](QPoint p) { QMenu menu; fillListContextMenu(&menu); menu.exec(d->m_editorList->mapToGlobal(p)); diff --git a/src/plugins/coreplugin/find/findtoolwindow.cpp b/src/plugins/coreplugin/find/findtoolwindow.cpp index c6f8ca896f..5437cdd8f6 100644 --- a/src/plugins/coreplugin/find/findtoolwindow.cpp +++ b/src/plugins/coreplugin/find/findtoolwindow.cpp @@ -237,7 +237,7 @@ void FindToolWindow::setFindFilters(const QList<IFindFilter *> &filters) names << filter->displayName(); m_configWidgets.append(filter->createConfigWidget()); connect(filter, &IFindFilter::displayNameChanged, - this, [this, filter]() { updateFindFilterName(filter); }); + this, [this, filter] { updateFindFilterName(filter); }); } m_filterList->addItems(names); if (m_filters.size() > 0) diff --git a/src/plugins/coreplugin/foldernavigationwidget.cpp b/src/plugins/coreplugin/foldernavigationwidget.cpp index 55c70541d4..7b90bdb5ab 100644 --- a/src/plugins/coreplugin/foldernavigationwidget.cpp +++ b/src/plugins/coreplugin/foldernavigationwidget.cpp @@ -347,13 +347,11 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent) : QWidget(parent const QModelIndex sourceIndex = m_sortProxyModel->mapToSource(index); const auto filePath = Utils::FilePath::fromString( m_fileSystemModel->filePath(sourceIndex)); - // QTimer::singleShot only posts directly onto the event loop if you use the SLOT("...") - // notation, so using a singleShot with a lambda would flicker - // QTimer::singleShot(0, this, [this, filePath]() { setCrumblePath(filePath); }); QMetaObject::invokeMethod(this, [this, filePath] { setCrumblePath(filePath); }, Qt::QueuedConnection); }); - connect(m_crumbLabel, &Utils::FileCrumbLabel::pathClicked, [this](const Utils::FilePath &path) { + connect(m_crumbLabel, &Utils::FileCrumbLabel::pathClicked, + this, [this](const Utils::FilePath &path) { const QModelIndex rootIndex = m_sortProxyModel->mapToSource(m_listView->rootIndex()); const QModelIndex fileIndex = m_fileSystemModel->index(path.toString()); if (!isChildOf(fileIndex, rootIndex)) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 6d8a35b62c..ccb36f67d2 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -196,13 +196,15 @@ ICore::ICore(MainWindow *mainwindow) // Save settings once after all plugins are initialized: connect(PluginManager::instance(), &PluginManager::initializationDone, this, [] { ICore::saveSettings(ICore::InitializationDone); }); - connect(PluginManager::instance(), &PluginManager::testsFinished, [this] (int failedTests) { + connect(PluginManager::instance(), &PluginManager::testsFinished, + this, [this](int failedTests) { emit coreAboutToClose(); if (failedTests != 0) qWarning("Test run was not successful: %d test(s) failed.", failedTests); QCoreApplication::exit(failedTests); }); - connect(PluginManager::instance(), &PluginManager::scenarioFinished, [this] (int exitCode) { + connect(PluginManager::instance(), &PluginManager::scenarioFinished, + this, [this](int exitCode) { emit coreAboutToClose(); QCoreApplication::exit(exitCode); }); diff --git a/src/plugins/coreplugin/iwizardfactory.cpp b/src/plugins/coreplugin/iwizardfactory.cpp index 8a98593f80..036886bdeb 100644 --- a/src/plugins/coreplugin/iwizardfactory.cpp +++ b/src/plugins/coreplugin/iwizardfactory.cpp @@ -192,7 +192,7 @@ QList<IWizardFactory*> IWizardFactory::allWizardFactories() newFactory->m_action = new QAction(newFactory->displayName(), newFactory); ActionManager::registerAction(newFactory->m_action, actionId(newFactory)); - connect(newFactory->m_action, &QAction::triggered, newFactory, [newFactory]() { + connect(newFactory->m_action, &QAction::triggered, newFactory, [newFactory] { if (!ICore::isNewItemDialogRunning()) { FilePath path = newFactory->runPath({}); newFactory->runWizard(path, ICore::dialogParent(), Id(), QVariantMap()); @@ -253,15 +253,15 @@ Wizard *IWizardFactory::runWizard(const FilePath &path, QWidget *parent, Id plat s_currentWizard = wizard; // Connect while wizard exists: if (m_action) - connect(m_action, &QAction::triggered, wizard, [wizard]() { ICore::raiseWindow(wizard); }); + connect(m_action, &QAction::triggered, wizard, [wizard] { ICore::raiseWindow(wizard); }); connect(s_inspectWizardAction, &QAction::triggered, - wizard, [wizard]() { wizard->showVariables(); }); + wizard, [wizard] { wizard->showVariables(); }); connect(wizard, &Utils::Wizard::finished, this, [wizard](int result) { if (result != QDialog::Accepted) s_reopenData.clear(); wizard->deleteLater(); }); - connect(wizard, &QObject::destroyed, this, []() { + connect(wizard, &QObject::destroyed, this, [] { s_isWizardRunning = false; s_currentWizard = nullptr; s_inspectWizardAction->setEnabled(false); @@ -405,7 +405,7 @@ void IWizardFactory::initialize() connect(resetAction, &QAction::triggered, &IWizardFactory::clearWizardFactories); connect(ICore::instance(), &ICore::newItemDialogStateChanged, resetAction, - [resetAction]() { resetAction->setEnabled(!ICore::isNewItemDialogRunning()); }); + [resetAction] { resetAction->setEnabled(!ICore::isNewItemDialogRunning()); }); s_inspectWizardAction = new QAction(tr("Inspect Wizard State"), ActionManager::instance()); ActionManager::registerAction(s_inspectWizardAction, "Wizard.Inspect"); diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 6b0cec28da..2f2136f732 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -611,7 +611,7 @@ LocatorWidget::LocatorWidget(Locator *locator) m_fileLineEdit->setButtonMenu(Utils::FancyLineEdit::Left, m_filterMenu); - connect(m_refreshAction, &QAction::triggered, locator, [locator]() { + connect(m_refreshAction, &QAction::triggered, locator, [locator] { locator->refresh(Locator::filters()); }); connect(m_configureAction, &QAction::triggered, this, &LocatorWidget::showConfigureDialog); diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp index 61931479a1..f7ac895061 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp @@ -68,14 +68,16 @@ SpotlightIterator::SpotlightIterator(const QStringList &command) m_process->setCommand({Environment::systemEnvironment().searchInPath(command.first()), command.mid(1)}); m_process->setEnvironment(Utils::Environment::systemEnvironment()); - QObject::connect(m_process.get(), &QtcProcess::done, [this, cmd = command.first()] { + QObject::connect(m_process.get(), &QtcProcess::done, + m_process.get(), [this, cmd = command.first()] { if (m_process->result() != ProcessResult::FinishedWithSuccess) { MessageManager::writeFlashing(SpotlightLocatorFilter::tr( "Locator: Error occurred when running \"%1\".").arg(cmd)); } scheduleKillProcess(); }); - QObject::connect(m_process.get(), &QtcProcess::readyReadStandardOutput, [this] { + QObject::connect(m_process.get(), &QtcProcess::readyReadStandardOutput, + m_process.get(), [this] { QString output = QString::fromUtf8(m_process->readAllStandardOutput()); output.replace("\r\n", "\n"); const QStringList items = output.split('\n'); diff --git a/src/plugins/coreplugin/loggingviewer.cpp b/src/plugins/coreplugin/loggingviewer.cpp index ec4e60941b..d0f9190dfd 100644 --- a/src/plugins/coreplugin/loggingviewer.cpp +++ b/src/plugins/coreplugin/loggingviewer.cpp @@ -480,7 +480,7 @@ LoggingViewManagerWidget::LoggingViewManagerWidget(QWidget *parent) m_logModel->destroyItem(m_logModel->itemForIndex(m_logModel->index(0, 0))); m_logModel->appendItem(LogEntry{timestamp, type, category, msg}); }, Qt::QueuedConnection); - connect(m_logModel, &QAbstractItemModel::rowsInserted, this, [this, autoScroll]() { + connect(m_logModel, &QAbstractItemModel::rowsInserted, this, [this, autoScroll] { if (autoScroll->isChecked()) m_logView->scrollToBottom(); }, Qt::QueuedConnection); @@ -516,7 +516,7 @@ LoggingViewManagerWidget::LoggingViewManagerWidget(QWidget *parent) connect(m_categoryView, &Utils::BaseTreeView::customContextMenuRequested, this, &LoggingViewManagerWidget::showLogCategoryContextMenu); connect(clean, &QToolButton::clicked, m_logModel, &Utils::ListModel<LogEntry>::clear); - connect(stop, &QToolButton::clicked, this, [this, stop]() { + connect(stop, &QToolButton::clicked, this, [this, stop] { if (m_manager->isEnabled()) { m_manager->setEnabled(false); stop->setIcon(Utils::Icons::RUN_SMALL.icon()); @@ -591,7 +591,7 @@ void LoggingViewManagerWidget::saveLoggingsToFile() const { // should we just let it continue without temporarily disabling? const bool enabled = m_manager->isEnabled(); - Utils::ExecuteOnDestruction exec([this, enabled]() { m_manager->setEnabled(enabled); }); + Utils::ExecuteOnDestruction exec([this, enabled] { m_manager->setEnabled(enabled); }); if (enabled) m_manager->setEnabled(false); const Utils::FilePath fp = Utils::FileUtils::getSaveFilePath(ICore::dialogParent(), @@ -719,7 +719,7 @@ void LoggingViewer::showLoggingView() { ActionManager::command(Constants::LOGGER)->action()->setEnabled(false); auto widget = new LoggingViewManagerWidget(ICore::dialogParent()); - QObject::connect(widget, &QDialog::finished, widget, [widget] () { + QObject::connect(widget, &QDialog::finished, widget, [widget] { ActionManager::command(Constants::LOGGER)->action()->setEnabled(true); // explicitly disable manager again widget->deleteLater(); diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 576490f8ec..98509845ca 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -567,7 +567,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(m_newAction, Constants::NEW); cmd->setDefaultKeySequence(QKeySequence("Ctrl+Shift+N")); mfile->addAction(cmd, Constants::G_FILE_NEW); - connect(m_newAction, &QAction::triggered, this, []() { + connect(m_newAction, &QAction::triggered, this, [] { if (!ICore::isNewItemDialogRunning()) { ICore::showNewItemDialog( tr("New Project", "Title of dialog"), @@ -584,7 +584,7 @@ void MainWindow::registerDefaultActions() cmd = ActionManager::registerAction(action, Constants::NEW_FILE); cmd->setDefaultKeySequence(QKeySequence::New); mfile->addAction(cmd, Constants::G_FILE_NEW); - connect(action, &QAction::triggered, this, []() { + connect(action, &QAction::triggered, this, [] { if (!ICore::isNewItemDialogRunning()) { ICore::showNewItemDialog(tr("New File", "Title of dialog"), Utils::filtered(Core::IWizardFactory::allWizardFactories(), @@ -1527,7 +1527,7 @@ void MainWindow::changeLog() connect(versionCombo, &QComboBox::currentIndexChanged, textEdit, showLog); showLog(versionCombo->currentIndex()); - connect(showInExplorer, &QPushButton::clicked, [versionCombo, versionedFiles] { + connect(showInExplorer, &QPushButton::clicked, this, [versionCombo, versionedFiles] { const int index = versionCombo->currentIndex(); if (index >= 0 && index < versionedFiles.size()) FileUtils::showInGraphicalShell(ICore::dialogParent(), versionedFiles.at(index).second); diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index f17830445d..83041271e6 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -226,12 +226,13 @@ void ModeManagerPrivate::appendMode(IMode *mode) }); Id id = mode->id(); - QObject::connect(action, &QAction::triggered, [this, id] { + QObject::connect(action, &QAction::triggered, m_instance, [this, id] { ModeManager::activateMode(id); ICore::raiseWindow(m_modeStack); }); - QObject::connect(mode, &IMode::enabledStateChanged, [this, mode] { enabledStateChanged(mode); }); + QObject::connect(mode, &IMode::enabledStateChanged, + m_instance, [this, mode] { enabledStateChanged(mode); }); } void ModeManager::removeMode(IMode *mode) diff --git a/src/plugins/coreplugin/navigationsubwidget.cpp b/src/plugins/coreplugin/navigationsubwidget.cpp index 9f8db2e597..870cbce524 100644 --- a/src/plugins/coreplugin/navigationsubwidget.cpp +++ b/src/plugins/coreplugin/navigationsubwidget.cpp @@ -134,7 +134,7 @@ void NavigationSubWidget::populateSplitMenu() command->keySequence().toString( QKeySequence::NativeText)); QAction *action = m_splitMenu->addAction(displayName); - connect(action, &QAction::triggered, this, [this, i]() { emit splitMe(i); }); + connect(action, &QAction::triggered, this, [this, i] { emit splitMe(i); }); } } diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 9a76f1d5fe..7f7c7bc908 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -230,7 +230,7 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> &fac if (!ActionManager::command(actionId)) { QAction *action = new QAction(tr("Activate %1 View").arg(factory->displayName()), this); d->m_actionMap.insert(action, id); - connect(action, &QAction::triggered, this, [this, action]() { + connect(action, &QAction::triggered, this, [this, action] { NavigationWidget::activateSubWidget(d->m_actionMap[action], Side::Left); }); Command *cmd = ActionManager::registerAction(action, actionId, navicontext); diff --git a/src/plugins/coreplugin/statusbarmanager.cpp b/src/plugins/coreplugin/statusbarmanager.cpp index 79ef861dd0..acfd4ebca1 100644 --- a/src/plugins/coreplugin/statusbarmanager.cpp +++ b/src/plugins/coreplugin/statusbarmanager.cpp @@ -80,14 +80,14 @@ static void createStatusBarManager() statusContext->setWidget(bar); ICore::addContextObject(statusContext); - QObject::connect(ICore::instance(), &ICore::saveSettingsRequested, [] { + QObject::connect(ICore::instance(), &ICore::saveSettingsRequested, ICore::instance(), [] { QSettings *s = ICore::settings(); s->beginGroup(QLatin1String(kSettingsGroup)); s->setValue(QLatin1String(kLeftSplitWidthKey), m_splitter->sizes().at(0)); s->endGroup(); }); - QObject::connect(ICore::instance(), &ICore::coreAboutToClose, [statusContext] { + QObject::connect(ICore::instance(), &ICore::coreAboutToClose, statusContext, [statusContext] { delete statusContext; // This is the catch-all on rampdown. Individual items may // have been removed earlier by destroyStatusBarWidget(). diff --git a/src/plugins/coreplugin/systemsettings.cpp b/src/plugins/coreplugin/systemsettings.cpp index 49f685d693..d619161532 100644 --- a/src/plugins/coreplugin/systemsettings.cpp +++ b/src/plugins/coreplugin/systemsettings.cpp @@ -238,7 +238,7 @@ public: if (ICore::settings()->value(showCrashButtonKey).toBool()) { auto crashButton = new QPushButton("CRASH!!!"); crashButton->show(); - connect(crashButton, &QPushButton::clicked, []() { + connect(crashButton, &QPushButton::clicked, [] { // do a real crash volatile int* a = reinterpret_cast<volatile int *>(NULL); *a = 1; }); diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index 856d5e7aca..acd8518227 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -267,7 +267,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const FilePath &inpu .arg(versionControl->displayName()), Utils::InfoBarEntry::GlobalSuppression::Enabled); d->m_unconfiguredVcs = versionControl; - info.addCustomButton(ICore::msgShowOptionsDialog(), []() { + info.addCustomButton(ICore::msgShowOptionsDialog(), [] { QTC_ASSERT(d->m_unconfiguredVcs, return); ICore::showOptionsDialog(d->m_unconfiguredVcs->id()); }); diff --git a/src/plugins/coreplugin/windowsupport.cpp b/src/plugins/coreplugin/windowsupport.cpp index 56a9eaafa1..1b6abde436 100644 --- a/src/plugins/coreplugin/windowsupport.cpp +++ b/src/plugins/coreplugin/windowsupport.cpp @@ -156,14 +156,16 @@ void WindowList::addWindow(QWidget *window) m_windowActionIds.append(id); auto action = new QAction(window->windowTitle()); m_windowActions.append(action); - QObject::connect(action, &QAction::triggered, [action, this]() { activateWindow(action); }); + QObject::connect(action, &QAction::triggered, + action, [action, this] { activateWindow(action); }); action->setCheckable(true); action->setChecked(false); Command *cmd = ActionManager::registerAction(action, id); cmd->setAttribute(Command::CA_UpdateText); ActionManager::actionContainer(Constants::M_WINDOW)->addAction(cmd, Constants::G_WINDOW_LIST); action->setVisible(window->isVisible() || window->isMinimized()); // minimized windows are hidden but should be shown - QObject::connect(window, &QWidget::windowTitleChanged, [window, this]() { updateTitle(window); }); + QObject::connect(window, &QWidget::windowTitleChanged, + window, [window, this] { updateTitle(window); }); if (m_dockMenu) m_dockMenu->addAction(action); if (window->isActiveWindow()) |