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";
|
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)
|
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||||
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
||||||
{
|
{
|
||||||
@@ -124,24 +133,32 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
|||||||
QTimer::singleShot(0, this, lambda);
|
QTimer::singleShot(0, this, lambda);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_openFileConnection = connect(
|
m_openFileConnection
|
||||||
this, &QmlProject::anyParsingFinished, this, [this](Target *target, bool success) {
|
= connect(this,
|
||||||
|
&QmlProject::anyParsingFinished,
|
||||||
|
this,
|
||||||
|
[this](Target *target, bool success) {
|
||||||
if (m_openFileConnection)
|
if (m_openFileConnection)
|
||||||
disconnect(m_openFileConnection);
|
disconnect(m_openFileConnection);
|
||||||
|
|
||||||
if (target && success) {
|
if (target && success) {
|
||||||
const Utils::FilePath &folder = projectDirectory();
|
const Utils::FilePath &folder = projectDirectory() + "/content";
|
||||||
const Utils::FilePaths &uiFiles = files([&](const ProjectExplorer::Node *node) {
|
|
||||||
return node->filePath().completeSuffix() == "ui.qml"
|
Utils::FilePaths uiFiles = getUiQmlFilesForFolder(projectDirectory()
|
||||||
&& node->filePath().parentDir() == folder;
|
+ "/content");
|
||||||
});
|
if (uiFiles.isEmpty())
|
||||||
|
uiFiles = getUiQmlFilesForFolder(projectDirectory());
|
||||||
|
|
||||||
if (!uiFiles.isEmpty()) {
|
if (!uiFiles.isEmpty()) {
|
||||||
Utils::FilePath currentFile;
|
Utils::FilePath currentFile;
|
||||||
if (auto cd = Core::EditorManager::currentDocument())
|
if (auto cd = Core::EditorManager::currentDocument())
|
||||||
currentFile = cd->filePath();
|
currentFile = cd->filePath();
|
||||||
|
|
||||||
if (currentFile.isEmpty() || !isKnownFile(currentFile))
|
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:
|
private:
|
||||||
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
||||||
|
Utils::FilePaths getUiQmlFilesForFolder(const Utils::FilePath &folder);
|
||||||
|
|
||||||
QMetaObject::Connection m_openFileConnection;
|
QMetaObject::Connection m_openFileConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user