forked from qt-creator/qt-creator
QmlDesigner: Fix indenting in embedded text editor
We have to set the duplicated editor as the current editor. We avoid triggering a document change by using a flag. Change-Id: I22410ec2f3b24695b397525811940c8303e0ed87 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
Tim Jenssen
parent
cd01c82827
commit
c168ba9f11
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
#include <rewriterview.h>
|
#include <rewriterview.h>
|
||||||
|
|
||||||
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
#include <theming.h>
|
#include <theming.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -68,6 +70,8 @@ void TextEditorWidget::setTextEditor(TextEditor::BaseTextEditor *textEditor)
|
|||||||
layout()->addWidget(m_statusBar);
|
layout()->addWidget(m_statusBar);
|
||||||
setFocusProxy(textEditor->editorWidget());
|
setFocusProxy(textEditor->editorWidget());
|
||||||
|
|
||||||
|
QmlDesignerPlugin::instance()->emitCurrentTextEditorChanged(textEditor);
|
||||||
|
|
||||||
connect(textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged,
|
connect(textEditor->editorWidget(), &QPlainTextEdit::cursorPositionChanged,
|
||||||
&m_updateSelectionTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
&m_updateSelectionTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
textEditor->editorWidget()->installEventFilter(this);
|
textEditor->editorWidget()->installEventFilter(this);
|
||||||
|
@@ -82,6 +82,7 @@ public:
|
|||||||
|
|
||||||
DesignerSettings settings;
|
DesignerSettings settings;
|
||||||
Internal::DesignModeContext *context = nullptr;
|
Internal::DesignModeContext *context = nullptr;
|
||||||
|
bool blockEditorChange = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlDesignerPlugin *QmlDesignerPlugin::m_instance = nullptr;
|
QmlDesignerPlugin *QmlDesignerPlugin::m_instance = nullptr;
|
||||||
@@ -345,6 +346,9 @@ void QmlDesignerPlugin::hideDesigner()
|
|||||||
|
|
||||||
void QmlDesignerPlugin::changeEditor()
|
void QmlDesignerPlugin::changeEditor()
|
||||||
{
|
{
|
||||||
|
if (d->blockEditorChange)
|
||||||
|
return;
|
||||||
|
|
||||||
if (d->documentManager.hasCurrentDesignDocument()) {
|
if (d->documentManager.hasCurrentDesignDocument()) {
|
||||||
deactivateAutoSynchronization();
|
deactivateAutoSynchronization();
|
||||||
d->mainWidget->saveSettings();
|
d->mainWidget->saveSettings();
|
||||||
@@ -472,6 +476,13 @@ void QmlDesignerPlugin::switchToTextModeDeferred()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlDesignerPlugin::emitCurrentTextEditorChanged(Core::IEditor *editor)
|
||||||
|
{
|
||||||
|
d->blockEditorChange = true;
|
||||||
|
Core::EditorManager::instance()->currentEditorChanged(editor);
|
||||||
|
d->blockEditorChange = false;
|
||||||
|
}
|
||||||
|
|
||||||
QmlDesignerPlugin *QmlDesignerPlugin::instance()
|
QmlDesignerPlugin *QmlDesignerPlugin::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return m_instance;
|
||||||
|
@@ -83,6 +83,7 @@ public:
|
|||||||
Internal::DesignModeWidget *mainWidget() const;
|
Internal::DesignModeWidget *mainWidget() const;
|
||||||
|
|
||||||
void switchToTextModeDeferred();
|
void switchToTextModeDeferred();
|
||||||
|
void emitCurrentTextEditorChanged(Core::IEditor *editor);
|
||||||
|
|
||||||
private: // functions
|
private: // functions
|
||||||
void integrateIntoQtCreator(QWidget *modeWidget);
|
void integrateIntoQtCreator(QWidget *modeWidget);
|
||||||
|
Reference in New Issue
Block a user