forked from qt-creator/qt-creator
QmlDesigner: Integrate Editor into Connections
Task-number: QDS-10530 Change-Id: I579c5e5d55b2136b96e32a448315dda8e720f2fb Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
3a7f41b78c
commit
26ac6c2606
@@ -6,6 +6,7 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/coreplugintr.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <plaintexteditmodifier.h>
|
||||
#include <qmljseditor/qmljsautocompleter.h>
|
||||
#include <qmljseditor/qmljscompletionassist.h>
|
||||
#include <qmljseditor/qmljseditor.h>
|
||||
@@ -46,7 +47,7 @@ BindingEditorWidget::BindingEditorWidget()
|
||||
? tr("Meta+Space")
|
||||
: tr("Ctrl+Space")));
|
||||
|
||||
connect(m_completionAction, &QAction::triggered, [this]() {
|
||||
connect(m_completionAction, &QAction::triggered, this, [this]() {
|
||||
invokeAssist(TextEditor::Completion);
|
||||
});
|
||||
}
|
||||
@@ -68,8 +69,17 @@ void BindingEditorWidget::unregisterAutoCompletion()
|
||||
bool BindingEditorWidget::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
if ((keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) && !keyEvent->modifiers()) {
|
||||
const QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
const bool returnPressed = (keyEvent->key() == Qt::Key_Return)
|
||||
|| (keyEvent->key() == Qt::Key_Enter);
|
||||
const Qt::KeyboardModifiers mods = keyEvent->modifiers();
|
||||
constexpr Qt::KeyboardModifier submitModifier = Qt::ControlModifier;
|
||||
const bool submitModed = mods.testFlag(submitModifier);
|
||||
|
||||
if (!m_isMultiline && (returnPressed && !mods)) {
|
||||
emit returnKeyClicked();
|
||||
return true;
|
||||
} else if (m_isMultiline && (returnPressed && submitModed)) {
|
||||
emit returnKeyClicked();
|
||||
return true;
|
||||
}
|
||||
@@ -81,8 +91,22 @@ std::unique_ptr<TextEditor::AssistInterface> BindingEditorWidget::createAssistIn
|
||||
[[maybe_unused]] TextEditor::AssistKind assistKind, TextEditor::AssistReason assistReason) const
|
||||
{
|
||||
return std::make_unique<QmlJSEditor::QmlJSCompletionAssistInterface>(
|
||||
textCursor(), Utils::FilePath(),
|
||||
assistReason, qmljsdocument->semanticInfo());
|
||||
textCursor(), Utils::FilePath(), assistReason, qmljsdocument->semanticInfo());
|
||||
}
|
||||
|
||||
void BindingEditorWidget::setEditorTextWithIndentation(const QString &text)
|
||||
{
|
||||
auto *doc = document();
|
||||
doc->setPlainText(text);
|
||||
|
||||
//we don't need to indent an empty text
|
||||
//but is also needed for safer text.length()-1 below
|
||||
if (text.isEmpty())
|
||||
return;
|
||||
|
||||
auto modifier = std::make_unique<IndentingTextEditModifier>(
|
||||
doc, QTextCursor{doc});
|
||||
modifier->indent(0, text.length()-1);
|
||||
}
|
||||
|
||||
BindingDocument::BindingDocument()
|
||||
|
||||
Reference in New Issue
Block a user