QmlProject: Open the first .ui.qml file in QDS

Open the first .ui.qml file of a .qmlproject to not
confuse users.

Task-number: QDS-4986
Change-Id: I56c77c2101fd549cb7b96ea7d273bb4f5234693a
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Thomas Hartmann
2021-09-03 14:58:42 +02:00
parent 1a3da3a06d
commit 1393aa8505

View File

@@ -34,6 +34,7 @@
#include <coreplugin/documentmanager.h> #include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/documentmodel.h> #include <coreplugin/editormanager/documentmodel.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icontext.h> #include <coreplugin/icontext.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -142,6 +143,18 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
QTimer::singleShot(0, this, lambda); QTimer::singleShot(0, this, lambda);
} }
} else {
connect(this, &QmlProject::anyParsingFinished, this, [this](Target *target, bool success) {
if (target && success) {
const Utils::FilePath &folder = projectDirectory();
const Utils::FilePaths &uiFiles = files([&](const ProjectExplorer::Node *node) {
return node->filePath().completeSuffix() == "ui.qml"
&& node->filePath().parentDir() == folder;
});
if (!uiFiles.isEmpty())
Core::EditorManager::openEditor(uiFiles.first(), Utils::Id());
}
});
} }
} }