forked from qt-creator/qt-creator
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: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -187,7 +187,8 @@ static bool documentIsAlreadyOpen(DesignDocument *designDocument, Core::IEditor
|
|||||||
{
|
{
|
||||||
return designDocument
|
return designDocument
|
||||||
&& editor == designDocument->editor()
|
&& editor == designDocument->editor()
|
||||||
&& isDesignerMode(newMode);
|
&& isDesignerMode(newMode)
|
||||||
|
&& designDocument->fileName() == editor->document()->filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldAssertInException()
|
static bool shouldAssertInException()
|
||||||
@@ -440,15 +441,13 @@ void QmlDesignerPlugin::integrateIntoQtCreator(QWidget *modeWidget)
|
|||||||
&Core::ModeManager::currentModeChanged,
|
&Core::ModeManager::currentModeChanged,
|
||||||
[this](Utils::Id newMode, Utils::Id oldMode) {
|
[this](Utils::Id newMode, Utils::Id oldMode) {
|
||||||
Core::IEditor *currentEditor = Core::EditorManager::currentEditor();
|
Core::IEditor *currentEditor = Core::EditorManager::currentEditor();
|
||||||
if (d && currentEditor && checkIfEditorIsQtQuick(currentEditor)
|
if (isDesignerMode(newMode) && checkIfEditorIsQtQuick(currentEditor)
|
||||||
&& !documentIsAlreadyOpen(currentDesignDocument(), currentEditor, newMode)) {
|
&& !documentIsAlreadyOpen(currentDesignDocument(), currentEditor, newMode)) {
|
||||||
if (isDesignerMode(newMode)) {
|
|
||||||
showDesigner();
|
showDesigner();
|
||||||
} else if (currentDesignDocument()
|
} else if (currentDesignDocument()
|
||||||
|| (!isDesignerMode(newMode) && isDesignerMode(oldMode))) {
|
|| (!isDesignerMode(newMode) && isDesignerMode(oldMode))) {
|
||||||
hideDesigner();
|
hideDesigner();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user