aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/shortcutmanager.cpp
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2017-01-19 12:09:09 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2017-01-19 12:34:49 +0000
commitcba001eff828a654255a869cef025b58bbf6ddce (patch)
tree3fcd9ca3f89ac0dd2f2df15b7fb96fdf572b803e /src/plugins/qmldesigner/shortcutmanager.cpp
parenteeb0b8fd21dba8421bd50b475a6442c27b63a1a6 (diff)
QmlDesigner: Do not move cursor when reformating
When saving a .ui.qml file the complete file is reformated. Without this patch the cursor is moved to the bottom. The cursor is still moved, but they line is kept. Since we reformat the complete file this should be fine. Change-Id: Ia1ef003e2e6ca7497dcad7e0e8044ffb99c80ea3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/shortcutmanager.cpp')
-rw-r--r--src/plugins/qmldesigner/shortcutmanager.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp
index bb907d9a6c..873a427441 100644
--- a/src/plugins/qmldesigner/shortcutmanager.cpp
+++ b/src/plugins/qmldesigner/shortcutmanager.cpp
@@ -143,19 +143,8 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
//Save
Core::ActionManager::registerAction(&m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext);
connect(&m_saveAction, &QAction::triggered, em, [em] {
- DesignerSettings settings = QmlDesignerPlugin::instance()->settings();
- /* Reformat document if we have a .ui.qml file */
- if (settings.value(DesignerSettingsKey::REFORMAT_UI_QML_FILES).toBool()
- && em->currentDocument()->filePath().toString().endsWith(".ui.qml"))
- if (QmlJSEditor::QmlJSEditorDocument *document
- = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(em->currentDocument())) {
- const QString &newText = QmlJS::reformat(document->semanticInfo().document);
- QTextCursor tc(document->document());
- tc.movePosition(QTextCursor::Start);
- tc.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
- tc.insertText(newText);
- }
- em->saveDocument();
+ QmlDesignerPlugin::instance()->viewManager().reformatFileUsingTextEditorView();
+ em->saveDocument();
});