forked from qt-creator/qt-creator
QmlProject: Search in content for .ui.qml files first
Change-Id: I1cf8a0bc83c24a0207e68a12a9a441cc7432a013 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -95,6 +95,15 @@ static int preferedQtTarget(Target *target)
|
||||
|
||||
const char openInQDSAppSetting[] = "OpenInQDSApp";
|
||||
|
||||
Utils::FilePaths QmlProject::getUiQmlFilesForFolder(const Utils::FilePath &folder)
|
||||
{
|
||||
const Utils::FilePaths uiFiles = files([&](const ProjectExplorer::Node *node) {
|
||||
return node->filePath().completeSuffix() == "ui.qml"
|
||||
&& node->filePath().parentDir() == folder;
|
||||
});
|
||||
return uiFiles;
|
||||
}
|
||||
|
||||
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
||||
{
|
||||
@@ -124,24 +133,32 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
QTimer::singleShot(0, this, lambda);
|
||||
}
|
||||
} else {
|
||||
m_openFileConnection = connect(
|
||||
this, &QmlProject::anyParsingFinished, this, [this](Target *target, bool success) {
|
||||
m_openFileConnection
|
||||
= connect(this,
|
||||
&QmlProject::anyParsingFinished,
|
||||
this,
|
||||
[this](Target *target, bool success) {
|
||||
if (m_openFileConnection)
|
||||
disconnect(m_openFileConnection);
|
||||
|
||||
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;
|
||||
});
|
||||
const Utils::FilePath &folder = projectDirectory() + "/content";
|
||||
|
||||
Utils::FilePaths uiFiles = getUiQmlFilesForFolder(projectDirectory()
|
||||
+ "/content");
|
||||
if (uiFiles.isEmpty())
|
||||
uiFiles = getUiQmlFilesForFolder(projectDirectory());
|
||||
|
||||
if (!uiFiles.isEmpty()) {
|
||||
Utils::FilePath currentFile;
|
||||
if (auto cd = Core::EditorManager::currentDocument())
|
||||
currentFile = cd->filePath();
|
||||
|
||||
if (currentFile.isEmpty() || !isKnownFile(currentFile))
|
||||
Core::EditorManager::openEditor(uiFiles.first(), Utils::Id());
|
||||
QTimer::singleShot(1000, [uiFiles]() {
|
||||
Core::EditorManager::openEditor(uiFiles.first(),
|
||||
Utils::Id());
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -151,6 +151,8 @@ protected:
|
||||
|
||||
private:
|
||||
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
||||
Utils::FilePaths getUiQmlFilesForFolder(const Utils::FilePath &folder);
|
||||
|
||||
QMetaObject::Connection m_openFileConnection;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user