2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2010-01-12 16:56:36 +01:00
|
|
|
#include "qmlprojectmanager_global.h"
|
2016-01-08 11:31:06 +01:00
|
|
|
|
2019-10-22 14:55:51 +02:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2009-05-04 12:19:22 +02:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
|
2018-01-29 13:38:41 +01:00
|
|
|
#include <utils/environment.h>
|
|
|
|
|
|
2012-09-24 13:48:18 +02:00
|
|
|
#include <QPointer>
|
2009-05-04 12:19:22 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
namespace QmlProjectManager {
|
2009-12-16 16:39:39 +01:00
|
|
|
|
2019-10-22 14:55:51 +02:00
|
|
|
class QmlProject;
|
2010-02-16 13:39:13 +01:00
|
|
|
class QmlProjectItem;
|
2009-12-16 16:39:39 +01:00
|
|
|
|
2019-12-10 16:25:41 +01:00
|
|
|
class QMLPROJECTMANAGER_EXPORT QmlBuildSystem : public ProjectExplorer::BuildSystem
|
2019-10-22 14:55:51 +02:00
|
|
|
{
|
2010-01-12 16:56:36 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
2019-10-22 14:55:51 +02:00
|
|
|
public:
|
2019-10-25 09:55:32 +02:00
|
|
|
explicit QmlBuildSystem(ProjectExplorer::Target *target);
|
|
|
|
|
~QmlBuildSystem();
|
|
|
|
|
|
|
|
|
|
void triggerParsing() final;
|
2019-10-22 14:55:51 +02:00
|
|
|
|
|
|
|
|
bool supportsAction(ProjectExplorer::Node *context,
|
|
|
|
|
ProjectExplorer::ProjectAction action,
|
|
|
|
|
const ProjectExplorer::Node *node) const override;
|
|
|
|
|
bool addFiles(ProjectExplorer::Node *context,
|
2021-07-14 16:49:42 +02:00
|
|
|
const Utils::FilePaths &filePaths, Utils::FilePaths *notAdded = nullptr) override;
|
2019-10-22 14:55:51 +02:00
|
|
|
bool deleteFiles(ProjectExplorer::Node *context,
|
2021-07-14 16:49:42 +02:00
|
|
|
const Utils::FilePaths &filePaths) override;
|
2019-10-22 14:55:51 +02:00
|
|
|
bool renameFile(ProjectExplorer::Node *context,
|
2021-06-11 14:34:34 +02:00
|
|
|
const Utils::FilePath &oldFilePath, const Utils::FilePath &newFilePath) override;
|
2021-09-09 11:28:28 +02:00
|
|
|
QString name() const override { return QLatin1String("qml"); }
|
2019-10-22 14:55:51 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
QmlProject *qmlProject() const;
|
2019-10-22 14:55:51 +02:00
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
QVariant additionalData(Utils::Id id) const override;
|
2010-01-12 16:56:36 +01:00
|
|
|
|
2010-01-19 13:53:48 +01:00
|
|
|
enum RefreshOption {
|
|
|
|
|
ProjectFile = 0x01,
|
|
|
|
|
Files = 0x02,
|
|
|
|
|
Configuration = 0x04,
|
|
|
|
|
Everything = ProjectFile | Files | Configuration
|
2010-01-12 16:56:36 +01:00
|
|
|
};
|
2010-01-19 13:53:48 +01:00
|
|
|
Q_DECLARE_FLAGS(RefreshOptions,RefreshOption)
|
2010-01-12 16:56:36 +01:00
|
|
|
|
|
|
|
|
void refresh(RefreshOptions options);
|
|
|
|
|
|
2019-05-28 13:49:26 +02:00
|
|
|
Utils::FilePath canonicalProjectDir() const;
|
2010-12-03 17:04:29 +01:00
|
|
|
QString mainFile() const;
|
2022-05-10 14:23:51 +02:00
|
|
|
QString mainUiFile() const;
|
2021-03-22 21:15:11 +01:00
|
|
|
Utils::FilePath mainFilePath() const;
|
2022-05-10 14:23:51 +02:00
|
|
|
Utils::FilePath mainUiFilePath() const;
|
|
|
|
|
|
|
|
|
|
bool setMainFileInProjectFile(const Utils::FilePath &newMainFilePath);
|
|
|
|
|
bool setMainUiFileInProjectFile(const Utils::FilePath &newMainUiFilePath);
|
|
|
|
|
bool setMainUiFileInMainFile(const Utils::FilePath &newMainUiFilePath);
|
2021-03-22 21:15:11 +01:00
|
|
|
|
2020-02-20 14:51:45 +01:00
|
|
|
bool qtForMCUs() const;
|
2021-07-27 14:18:39 +02:00
|
|
|
bool qt6Project() const;
|
2019-01-18 20:38:48 +01:00
|
|
|
void setMainFile(const QString &mainFilePath);
|
2019-10-25 09:55:32 +02:00
|
|
|
Utils::FilePath targetDirectory() const;
|
|
|
|
|
Utils::FilePath targetFile(const Utils::FilePath &sourceFile) const;
|
2018-01-29 13:38:41 +01:00
|
|
|
|
2019-05-07 16:51:22 +02:00
|
|
|
Utils::EnvironmentItems environment() const;
|
2012-12-03 15:28:34 +01:00
|
|
|
QStringList customImportPaths() const;
|
2019-04-08 17:02:20 +02:00
|
|
|
QStringList customFileSelectors() const;
|
2022-01-19 08:24:14 +02:00
|
|
|
bool multilanguageSupport() const;
|
2021-10-11 14:58:11 +02:00
|
|
|
QStringList supportedLanguages() const;
|
2021-11-03 16:47:04 +02:00
|
|
|
void setSupportedLanguages(QStringList languages);
|
2021-10-13 15:50:23 +03:00
|
|
|
QString primaryLanguage() const;
|
2021-11-03 16:47:04 +02:00
|
|
|
void setPrimaryLanguage(QString language);
|
2019-12-04 13:10:38 +01:00
|
|
|
bool forceFreeType() const;
|
2021-12-07 15:04:04 +02:00
|
|
|
bool widgetApp() const;
|
2022-04-01 14:32:20 +03:00
|
|
|
QStringList shaderToolArgs() const;
|
|
|
|
|
QStringList shaderToolFiles() const;
|
2022-06-13 13:23:12 +02:00
|
|
|
QStringList importPaths() const;
|
|
|
|
|
QStringList files() const;
|
2010-01-12 16:56:36 +01:00
|
|
|
|
2010-02-17 11:20:35 +01:00
|
|
|
bool addFiles(const QStringList &filePaths);
|
|
|
|
|
|
2010-01-19 13:53:48 +01:00
|
|
|
void refreshProjectFile();
|
2011-09-15 13:05:36 +02:00
|
|
|
|
2021-03-22 21:15:11 +01:00
|
|
|
static Utils::FilePath activeMainFilePath();
|
2019-05-28 13:49:26 +02:00
|
|
|
static QStringList makeAbsolute(const Utils::FilePath &path, const QStringList &relativePaths);
|
2019-04-08 17:02:20 +02:00
|
|
|
|
2017-03-01 14:26:46 +01:00
|
|
|
void generateProjectTree();
|
2019-10-25 09:55:32 +02:00
|
|
|
void updateDeploymentData();
|
2010-05-18 13:40:35 +02:00
|
|
|
void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed);
|
2017-11-28 15:57:15 +01:00
|
|
|
void refreshTargetDirectory();
|
2013-05-02 15:29:33 +02:00
|
|
|
void onActiveTargetChanged(ProjectExplorer::Target *target);
|
2013-11-06 12:59:04 +01:00
|
|
|
void onKitChanged();
|
2010-01-19 13:53:48 +01:00
|
|
|
|
2010-01-18 16:32:14 +01:00
|
|
|
// plain format
|
2010-01-12 16:56:36 +01:00
|
|
|
void parseProject(RefreshOptions options);
|
|
|
|
|
|
2022-06-13 13:23:12 +02:00
|
|
|
signals:
|
|
|
|
|
void projectChanged();
|
|
|
|
|
|
2020-03-03 12:30:28 +01:00
|
|
|
private:
|
2022-05-10 14:23:51 +02:00
|
|
|
bool setFileSettingInProjectFile(const QString &setting,
|
|
|
|
|
const Utils::FilePath &mainFilePath,
|
|
|
|
|
const QString &oldFile);
|
|
|
|
|
|
2021-12-16 11:39:52 +01:00
|
|
|
std::unique_ptr<QmlProjectItem> m_projectItem;
|
|
|
|
|
Utils::FilePath m_canonicalProjectDir;
|
2020-03-03 12:30:28 +01:00
|
|
|
bool m_blockFilesUpdate = false;
|
|
|
|
|
friend class FilesUpdateBlocker;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FilesUpdateBlocker {
|
|
|
|
|
public:
|
|
|
|
|
FilesUpdateBlocker(QmlBuildSystem* bs): m_bs(bs) {
|
|
|
|
|
if (m_bs)
|
|
|
|
|
m_bs->m_blockFilesUpdate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~FilesUpdateBlocker() {
|
|
|
|
|
if (m_bs) {
|
|
|
|
|
m_bs->m_blockFilesUpdate = false;
|
|
|
|
|
m_bs->refresh(QmlBuildSystem::Everything);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
QPointer<QmlBuildSystem> m_bs;
|
2010-01-12 16:56:36 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit QmlProject(const Utils::FilePath &filename);
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Tasks projectIssues(const ProjectExplorer::Kit *k) const final;
|
|
|
|
|
|
2022-02-04 16:59:04 +01:00
|
|
|
static bool isQtDesignStudio();
|
2022-02-22 16:33:53 +01:00
|
|
|
static bool isQtDesignStudioStartedFromQtC();
|
2022-02-04 16:59:04 +01:00
|
|
|
|
2022-02-07 10:06:16 +01:00
|
|
|
bool isEditModePreferred() const override;
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
protected:
|
|
|
|
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
2022-02-03 19:44:07 +01:00
|
|
|
Utils::FilePaths getUiQmlFilesForFolder(const Utils::FilePath &folder);
|
|
|
|
|
|
2021-09-07 14:45:32 +02:00
|
|
|
QMetaObject::Connection m_openFileConnection;
|
2019-10-25 09:55:32 +02:00
|
|
|
};
|
|
|
|
|
|
2009-05-04 12:19:22 +02:00
|
|
|
} // namespace QmlProjectManager
|
|
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(QmlProjectManager::QmlBuildSystem::RefreshOptions)
|