forked from qt-creator/qt-creator
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:
@@ -12,7 +12,7 @@ namespace TextEditor {
|
||||
|
||||
AsyncProcessor::AsyncProcessor()
|
||||
{
|
||||
QObject::connect(&m_watcher, &QFutureWatcher<IAssistProposal *>::finished, [this]() {
|
||||
QObject::connect(&m_watcher, &QFutureWatcher<IAssistProposal *>::finished, &m_watcher, [this] {
|
||||
setAsyncProposalAvailable(m_watcher.result());
|
||||
});
|
||||
}
|
||||
@@ -21,7 +21,7 @@ IAssistProposal *AsyncProcessor::perform()
|
||||
{
|
||||
IAssistProposal *result = immediateProposal();
|
||||
interface()->prepareForAsyncUse();
|
||||
m_watcher.setFuture(Utils::runAsync([this]() {
|
||||
m_watcher.setFuture(Utils::runAsync([this] {
|
||||
interface()->recreateTextDocument();
|
||||
return performAsync();
|
||||
}));
|
||||
|
||||
@@ -55,12 +55,13 @@ public:
|
||||
fontSettingsPageLineSpacing = fontSettingsPageLineSpacingLink();
|
||||
|
||||
if (fontSettingsPageLineSpacing) {
|
||||
connect(fontSettingsPageLineSpacing, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
[=](const int &value) {
|
||||
if (value != 100)
|
||||
enableTextWrapping->setChecked(false);
|
||||
enableTextWrapping->setEnabled(value == 100);
|
||||
enableTextWrappingHintLabel->setVisible(value != 100); } );
|
||||
connect(fontSettingsPageLineSpacing, &QSpinBox::valueChanged,
|
||||
this, [this](const int &value) {
|
||||
if (value != 100)
|
||||
enableTextWrapping->setChecked(false);
|
||||
enableTextWrapping->setEnabled(value == 100);
|
||||
enableTextWrappingHintLabel->setVisible(value != 100);
|
||||
});
|
||||
|
||||
if (fontSettingsPageLineSpacing->value() != 100)
|
||||
enableTextWrapping->setChecked(false);
|
||||
@@ -69,7 +70,7 @@ public:
|
||||
enableTextWrappingHintLabel->setVisible(fontSettingsPageLineSpacing->value() != 100);
|
||||
}
|
||||
|
||||
connect(enableTextWrappingHintLabel, &QLabel::linkActivated, []() {
|
||||
connect(enableTextWrappingHintLabel, &QLabel::linkActivated, [] {
|
||||
Core::ICore::showOptionsDialog(Constants::TEXT_EDITOR_FONT_SETTINGS); } );
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
QAction *completionAction = new QAction(tr("Trigger Completion"), this);
|
||||
Command *command = ActionManager::registerAction(completionAction, Constants::COMPLETE_THIS, context);
|
||||
command->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space")));
|
||||
connect(completionAction, &QAction::triggered, []() {
|
||||
connect(completionAction, &QAction::triggered, this, [] {
|
||||
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
|
||||
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->setDefaultKeySequence(QKeySequence(useMacShortcuts ? tr("Meta+Shift+D")
|
||||
: tr("Ctrl+Shift+D")));
|
||||
connect(functionHintAction, &QAction::triggered, []() {
|
||||
connect(functionHintAction, &QAction::triggered, this, [] {
|
||||
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
|
||||
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);
|
||||
Command *quickFixCommand = ActionManager::registerAction(quickFixAction, Constants::QUICKFIX_THIS, context);
|
||||
quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
|
||||
connect(quickFixAction, &QAction::triggered, []() {
|
||||
connect(quickFixAction, &QAction::triggered, this, [] {
|
||||
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
|
||||
editor->editorWidget()->invokeAssist(QuickFix);
|
||||
});
|
||||
@@ -136,7 +136,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
ActionManager::registerAction(showContextMenuAction,
|
||||
Constants::SHOWCONTEXTMENU,
|
||||
context);
|
||||
connect(showContextMenuAction, &QAction::triggered, []() {
|
||||
connect(showContextMenuAction, &QAction::triggered, this, [] {
|
||||
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
|
||||
editor->editorWidget()->showContextMenu();
|
||||
});
|
||||
@@ -154,11 +154,10 @@ void TextEditorPluginPrivate::extensionsInitialized()
|
||||
{
|
||||
connect(FolderNavigationWidgetFactory::instance(),
|
||||
&FolderNavigationWidgetFactory::aboutToShowContextMenu,
|
||||
this,
|
||||
[](QMenu *menu, const FilePath &filePath, bool isDir) {
|
||||
this, [](QMenu *menu, const FilePath &filePath, bool isDir) {
|
||||
if (!isDir && Core::DiffService::instance()) {
|
||||
menu->addAction(TextEditor::TextDocument::createDiffAgainstCurrentFileAction(
|
||||
menu, [filePath]() { return filePath; }));
|
||||
menu, [filePath] { return filePath; }));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -231,8 +230,7 @@ void TextEditorPlugin::extensionsInitialized()
|
||||
});
|
||||
|
||||
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();
|
||||
if (!editor)
|
||||
return QString();
|
||||
|
||||
Reference in New Issue
Block a user