summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Kianian <ali.kianian@qt.io>2023-05-02 15:49:52 +0300
committerTim Jenssen <tim.jenssen@qt.io>2023-05-03 14:11:48 +0000
commitcf804bcdb8dde8541ac85acb9ea4c6cbcbe3def2 (patch)
tree8224abfc0b12034476bcf6c322193dafdf9c76a1
parenta39ad9f7545d68d0117e62faccd278e41e46cce2 (diff)
downloadqt-creator-cf804bcdb8dde8541ac85acb9ea4c6cbcbe3def2.tar.gz
QmlDesigner: Assign the correct context to QmlDesigner
The context would be updated when switching between different modes. Some wrong conditions had caused to prevent this update before. Before this change: QmlDesignerPlugin ignores hiding the designer when the new editor is raised by the editor manager because it hides the designer only when the current designer is QtQuick. So, the previously opened document is kept by the document manager, since hideDesigner is not called. Then, when the user decides to go back to the designer mode, the QtQuick editor is opened, but the previous document is opened, so the QmlDesignerPlugin will not call showDesigner (Even if a different file is opened now). With this change: QmlDesignerPlugin calls hideDesigner when a non-QtQuick editor is raised by the editor manager. It compares the file paths of the editor and the design document. So, if they are different, it will try to open and show it again. Task-number: QDS-9686 Change-Id: I6b962f22a1f3863128ac6a40780fdceeecaec040 Reviewed-by: Ali Kianian <ali.kianian@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index b7d7000be4..254c0ea512 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -186,8 +186,9 @@ static bool isDesignerMode(Utils::Id mode)
static bool documentIsAlreadyOpen(DesignDocument *designDocument, Core::IEditor *editor, Utils::Id newMode)
{
return designDocument
- && editor == designDocument->editor()
- && isDesignerMode(newMode);
+ && editor == designDocument->editor()
+ && isDesignerMode(newMode)
+ && designDocument->fileName() == editor->document()->filePath();
}
static bool shouldAssertInException()
@@ -440,14 +441,12 @@ void QmlDesignerPlugin::integrateIntoQtCreator(QWidget *modeWidget)
&Core::ModeManager::currentModeChanged,
[this](Utils::Id newMode, Utils::Id oldMode) {
Core::IEditor *currentEditor = Core::EditorManager::currentEditor();
- if (d && currentEditor && checkIfEditorIsQtQuick(currentEditor)
+ if (isDesignerMode(newMode) && checkIfEditorIsQtQuick(currentEditor)
&& !documentIsAlreadyOpen(currentDesignDocument(), currentEditor, newMode)) {
- if (isDesignerMode(newMode)) {
- showDesigner();
- } else if (currentDesignDocument()
- || (!isDesignerMode(newMode) && isDesignerMode(oldMode))) {
- hideDesigner();
- }
+ showDesigner();
+ } else if (currentDesignDocument()
+ || (!isDesignerMode(newMode) && isDesignerMode(oldMode))) {
+ hideDesigner();
}
});
}