QmlProject: Allow setting main qml file and main ui.qml file

The .qmlproject file already has the "mainFile" setting which indicates
which qml file is run. This patch adds a main ui.qml file that indicates
which ui.qml file is opened in the design mode if the .qmlproject is opened.

The patch also adds two context menu actions that allow setting the main qml
and main.ui.qml files without having to edit the .qmlproject file by hand.

Changing the main ui.qml file also checks if the current ui.qml file is
used as in the main qml file and if it is, then we switch the component there.

For now the actions are only available in QDS.

Task-number: QDS-6882
Change-Id: I1c6e19c039036dc635161fa6e06173356dc509aa
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Thomas Hartmann
2022-05-10 14:23:51 +02:00
parent 5e31fae6d9
commit de7a7b6ac8
5 changed files with 274 additions and 49 deletions

View File

@@ -77,7 +77,13 @@ public:
Utils::FilePath canonicalProjectDir() const;
QString mainFile() const;
QString mainUiFile() const;
Utils::FilePath mainFilePath() const;
Utils::FilePath mainUiFilePath() const;
bool setMainFileInProjectFile(const Utils::FilePath &newMainFilePath);
bool setMainUiFileInProjectFile(const Utils::FilePath &newMainUiFilePath);
bool setMainUiFileInMainFile(const Utils::FilePath &newMainUiFilePath);
bool qtForMCUs() const;
bool qt6Project() const;
@@ -116,6 +122,10 @@ public:
void parseProject(RefreshOptions options);
private:
bool setFileSettingInProjectFile(const QString &setting,
const Utils::FilePath &mainFilePath,
const QString &oldFile);
std::unique_ptr<QmlProjectItem> m_projectItem;
Utils::FilePath m_canonicalProjectDir;
bool m_blockFilesUpdate = false;