TextEditor: Pass context object to lambda connections

Remove some unneeded lambda () brackets.
Glue lambda brackets with parameters brackets.

Change-Id: I66da839573a1633104f689834740bc2953f5868f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-12-08 00:29:41 +01:00
parent 1cdf29a1e6
commit 131ecdd3ec
3 changed files with 17 additions and 18 deletions

View File

@@ -12,7 +12,7 @@ namespace TextEditor {
AsyncProcessor::AsyncProcessor() AsyncProcessor::AsyncProcessor()
{ {
QObject::connect(&m_watcher, &QFutureWatcher<IAssistProposal *>::finished, [this]() { QObject::connect(&m_watcher, &QFutureWatcher<IAssistProposal *>::finished, &m_watcher, [this] {
setAsyncProposalAvailable(m_watcher.result()); setAsyncProposalAvailable(m_watcher.result());
}); });
} }
@@ -21,7 +21,7 @@ IAssistProposal *AsyncProcessor::perform()
{ {
IAssistProposal *result = immediateProposal(); IAssistProposal *result = immediateProposal();
interface()->prepareForAsyncUse(); interface()->prepareForAsyncUse();
m_watcher.setFuture(Utils::runAsync([this]() { m_watcher.setFuture(Utils::runAsync([this] {
interface()->recreateTextDocument(); interface()->recreateTextDocument();
return performAsync(); return performAsync();
})); }));

View File

@@ -55,12 +55,13 @@ public:
fontSettingsPageLineSpacing = fontSettingsPageLineSpacingLink(); fontSettingsPageLineSpacing = fontSettingsPageLineSpacingLink();
if (fontSettingsPageLineSpacing) { if (fontSettingsPageLineSpacing) {
connect(fontSettingsPageLineSpacing, QOverload<int>::of(&QSpinBox::valueChanged), connect(fontSettingsPageLineSpacing, &QSpinBox::valueChanged,
[=](const int &value) { this, [this](const int &value) {
if (value != 100) if (value != 100)
enableTextWrapping->setChecked(false); enableTextWrapping->setChecked(false);
enableTextWrapping->setEnabled(value == 100); enableTextWrapping->setEnabled(value == 100);
enableTextWrappingHintLabel->setVisible(value != 100); } ); enableTextWrappingHintLabel->setVisible(value != 100);
});
if (fontSettingsPageLineSpacing->value() != 100) if (fontSettingsPageLineSpacing->value() != 100)
enableTextWrapping->setChecked(false); enableTextWrapping->setChecked(false);
@@ -69,7 +70,7 @@ public:
enableTextWrappingHintLabel->setVisible(fontSettingsPageLineSpacing->value() != 100); enableTextWrappingHintLabel->setVisible(fontSettingsPageLineSpacing->value() != 100);
} }
connect(enableTextWrappingHintLabel, &QLabel::linkActivated, []() { connect(enableTextWrappingHintLabel, &QLabel::linkActivated, [] {
Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_FONT_SETTINGS); } ); Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_FONT_SETTINGS); } );

View File

@@ -104,7 +104,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
QAction *completionAction = new QAction(tr("Trigger Completion"), this); QAction *completionAction = new QAction(tr("Trigger Completion"), this);
Command *command = ActionManager::registerAction(completionAction, Constants::COMPLETE_THIS, context); Command *command = ActionManager::registerAction(completionAction, Constants::COMPLETE_THIS, context);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space"))); command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space")));
connect(completionAction, &QAction::triggered, []() { connect(completionAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(Completion); editor->editorWidget()->invokeAssist(Completion);
}); });
@@ -118,7 +118,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
command = ActionManager::registerAction(functionHintAction, Constants::FUNCTION_HINT, context); command = ActionManager::registerAction(functionHintAction, Constants::FUNCTION_HINT, context);
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+D") command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+D")
: tr("Ctrl+Shift+D"))); : tr("Ctrl+Shift+D")));
connect(functionHintAction, &QAction::triggered, []() { connect(functionHintAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(FunctionHint); editor->editorWidget()->invokeAssist(FunctionHint);
}); });
@@ -127,7 +127,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
QAction *quickFixAction = new QAction(tr("Trigger Refactoring Action"), this); QAction *quickFixAction = new QAction(tr("Trigger Refactoring Action"), this);
Command *quickFixCommand = ActionManager::registerAction(quickFixAction, Constants::QUICKFIX_THIS, context); Command *quickFixCommand = ActionManager::registerAction(quickFixAction, Constants::QUICKFIX_THIS, context);
quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return"))); quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
connect(quickFixAction, &QAction::triggered, []() { connect(quickFixAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->invokeAssist(QuickFix); editor->editorWidget()->invokeAssist(QuickFix);
}); });
@@ -136,7 +136,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
ActionManager::registerAction(showContextMenuAction, ActionManager::registerAction(showContextMenuAction,
Constants::SHOWCONTEXTMENU, Constants::SHOWCONTEXTMENU,
context); context);
connect(showContextMenuAction, &QAction::triggered, []() { connect(showContextMenuAction, &QAction::triggered, this, [] {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor()) if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
editor->editorWidget()->showContextMenu(); editor->editorWidget()->showContextMenu();
}); });
@@ -154,11 +154,10 @@ void TextEditorPluginPrivate::extensionsInitialized()
{ {
connect(FolderNavigationWidgetFactory::instance(), connect(FolderNavigationWidgetFactory::instance(),
&FolderNavigationWidgetFactory::aboutToShowContextMenu, &FolderNavigationWidgetFactory::aboutToShowContextMenu,
this, this, [](QMenu *menu, const FilePath &filePath, bool isDir) {
[](QMenu *menu, const FilePath &filePath, bool isDir) {
if (!isDir && Core::DiffService::instance()) { if (!isDir && Core::DiffService::instance()) {
menu->addAction(TextEditor::TextDocument::createDiffAgainstCurrentFileAction( menu->addAction(TextEditor::TextDocument::createDiffAgainstCurrentFileAction(
menu, [filePath]() { return filePath; })); menu, [filePath] { return filePath; }));
} }
}); });
@@ -231,8 +230,7 @@ void TextEditorPlugin::extensionsInitialized()
}); });
expander->registerVariable(kCurrentDocumentWordUnderCursor, expander->registerVariable(kCurrentDocumentWordUnderCursor,
tr("Word under the current document's text cursor."), tr("Word under the current document's text cursor."), [] {
[]() {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor(); BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
if (!editor) if (!editor)
return QString(); return QString();