forked from qt-creator/qt-creator
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 411100b037
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 <hjk@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -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<TextEditor::BaseTextEditor>(
|
||||
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));
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,6 @@ public:
|
||||
|
||||
private:
|
||||
QPointer<TextEditorWidget> m_widget;
|
||||
Core::IContext *m_textEditorContext;
|
||||
bool m_errorState = false;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user