From a555bc380190ce7f7d341cf4290d064980d4e4c4 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 9 Jul 2024 12:00:22 +0200 Subject: [PATCH] QmlDesigner: Remove special completion action It was necessary to override the existing completion action, because that would always work on the current editor in the editor manager instead of on the text editor in Design mode. (Though instead of changing the context for the TextEditorView, the code could just have registered a context for the text editor widget itself for that purpose.) Since 411100b0378202dc617acaa236f4730eb4cc43b2 the text editor widgets have their own individual contexts and actions, without the detour via the editor manager, so this workaround is no longer needed. Change-Id: I7e2b18dd7b953a56b5f2c99152d2eeabdb76f726 Reviewed-by: hjk Reviewed-by: Thomas Hartmann --- .../components/texteditor/texteditorview.cpp | 35 +++---------------- .../components/texteditor/texteditorview.h | 1 - 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp b/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp index 27d77509599..b4eaea77ac3 100644 --- a/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp +++ b/src/plugins/qmldesigner/components/texteditor/texteditorview.cpp @@ -45,35 +45,15 @@ using namespace Core; namespace QmlDesigner { -const char TEXTEDITOR_CONTEXT_ID[] = "QmlDesigner.TextEditorContext"; - TextEditorView::TextEditorView(ExternalDependenciesInterface &externalDependencies) : AbstractView{externalDependencies} , m_widget(new TextEditorWidget(this)) - , m_textEditorContext(new Core::IContext(m_widget)) { - m_textEditorContext->setWidget(m_widget); - m_textEditorContext->setContext(Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU)); - m_textEditorContext->setContextHelpProvider([this](const IContext::HelpCallback &callback) { - m_widget->contextHelp(callback); - }); - Core::ICore::addContextObject(m_textEditorContext); - - Core::Context context(TEXTEDITOR_CONTEXT_ID); - - /* - * We have to register our own active auto completion shortcut, because the original short cut will - * use the cursor position of the original editor in the editor manager. - */ - - QAction *completionAction = new QAction(tr("Trigger Completion"), this); - Core::Command *command = Core::ActionManager::registerAction(completionAction, TextEditor::Constants::COMPLETE_THIS, context); - command->setDefaultKeySequence(QKeySequence(Core::useMacShortcuts ? tr("Meta+Space") : tr("Ctrl+Space"))); - - connect(completionAction, &QAction::triggered, this, [this] { - if (m_widget->textEditor()) - m_widget->textEditor()->editorWidget()->invokeAssist(TextEditor::Completion); - }); + IContext::attach(m_widget, + Context(Constants::C_QMLTEXTEDITOR, Constants::C_QT_QUICK_TOOLS_MENU), + [this](const IContext::HelpCallback &callback) { + m_widget->contextHelp(callback); + }); } TextEditorView::~TextEditorView() @@ -91,11 +71,6 @@ void TextEditorView::modelAttached(Model *model) auto textEditor = Utils::UniqueObjectLatePtr( QmlDesignerPlugin::instance()->currentDesignDocument()->textEditor()->duplicate()); - // Set the context of the text editor, but we add another special context to override shortcuts. - Core::Context context = textEditor->context(); - context.prepend(TEXTEDITOR_CONTEXT_ID); - m_textEditorContext->setContext(context); - m_widget->setTextEditor(std::move(textEditor)); } diff --git a/src/plugins/qmldesigner/components/texteditor/texteditorview.h b/src/plugins/qmldesigner/components/texteditor/texteditorview.h index b1a02b926e8..8f6d4100f1f 100644 --- a/src/plugins/qmldesigner/components/texteditor/texteditorview.h +++ b/src/plugins/qmldesigner/components/texteditor/texteditorview.h @@ -77,7 +77,6 @@ public: private: QPointer m_widget; - Core::IContext *m_textEditorContext; bool m_errorState = false; };