diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2023-07-04 20:35:24 +0200 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2023-07-04 20:36:03 +0200 |
commit | d9910058a394330a404239ca38d95d909f15c68e (patch) | |
tree | 22437614d76a7dfe8aabcf7bdfe4c8c46f48fee9 /src/plugins/studiowelcome | |
parent | ae7e72cca51e309b50056fa095f3e913906f367c (diff) | |
parent | 7fada70e8f77fdccf7efc931421cf456561e097a (diff) |
Merge remote-tracking branch 'origin/qds/dev'
Change-Id: I91d9877ef6637d21e1106d6d363275295e6b55a3
Diffstat (limited to 'src/plugins/studiowelcome')
-rw-r--r-- | src/plugins/studiowelcome/studiowelcomeplugin.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index 7769f5f470..f2123cd2b2 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -102,30 +102,20 @@ static StudioWelcomePlugin *s_pluginInstance = nullptr; static Utils::FilePath getMainUiFileWithFallback() { - auto project = ProjectExplorer::ProjectManager::startupProject(); + const auto project = ProjectExplorer::ProjectManager::startupProject(); if (!project) return {}; if (!project->activeTarget()) return {}; - auto qmlBuildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>( + const auto qmlBuildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>( project->activeTarget()->buildSystem()); if (!qmlBuildSystem) return {}; - auto mainUiFile = qmlBuildSystem->mainUiFilePath(); - if (mainUiFile.exists()) - return mainUiFile; - - const Utils::FilePaths uiFiles = project->files([&](const ProjectExplorer::Node *node) { - return node->filePath().completeSuffix() == "ui.qml"; - }); - if (!uiFiles.isEmpty()) - return uiFiles.first(); - - return {}; + return qmlBuildSystem->getStartupQmlFileWithFallback(); } std::unique_ptr<QSettings> makeUserFeedbackSettings() @@ -254,14 +244,16 @@ public: return; m_blockOpenRecent = true; - const FilePath projectFile = FilePath::fromVariant(data(index(row, 0), ProjectModel::FilePathRole)); + const FilePath projectFile = FilePath::fromVariant( + data(index(row, 0), ProjectModel::FilePathRole)); if (projectFile.exists()) { const ProjectExplorerPlugin::OpenProjectResult result = ProjectExplorer::ProjectExplorerPlugin::openProject(projectFile); if (!result && !result.alreadyOpen().isEmpty()) { - const auto mainUiFile = getMainUiFileWithFallback(); - if (mainUiFile.exists()) - Core::EditorManager::openEditor(mainUiFile, Utils::Id()); + const auto fileToOpen = getMainUiFileWithFallback(); + if (!fileToOpen.isEmpty() && fileToOpen.exists() && !fileToOpen.isDir()) { + Core::EditorManager::openEditor(fileToOpen, Utils::Id()); + } }; } @@ -413,20 +405,25 @@ static QString tags(const FilePath &projectFilePath) const QByteArray data = reader.data(); - bool mcu = data.contains("qtForMCUs: true"); + const bool isQt6 = data.contains("qt6Project: true"); + const bool isMcu = data.contains("qtForMCUs: true"); - if (data.contains("qt6Project: true")) + if (isQt6) ret.append("Qt 6"); - else if (mcu) - ret.append("Qt For MCU"); else ret.append("Qt 5"); + if (isMcu) + ret.append("Qt For MCU"); + return ret.join(","); } QVariant ProjectModel::data(const QModelIndex &index, int role) const { + if (index.row() >= ProjectExplorer::ProjectExplorerPlugin::recentProjects().count()) + return {}; + const ProjectExplorer::RecentProjectsEntry data = ProjectExplorer::ProjectExplorerPlugin::recentProjects().at(index.row()); switch (role) { |