forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/qds/dev'
Conflicts: src/libs/utils/filepath.cpp src/plugins/qmldesigner/qmldesignerexternaldependencies.cpp src/plugins/qmlprojectmanager/cmakegen/generatecmakelists.cpp tests/unit/unittest/CMakeLists.txt Change-Id: I017a6075db41a5233487ac855ffe23de2b2bb0ee
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
add_qtc_plugin(QmlProjectManager
|
||||
CONDITION TARGET Qt::QuickWidgets
|
||||
PROPERTIES COMPILE_WARNING_AS_ERROR ON
|
||||
PLUGIN_CLASS QmlProjectPlugin
|
||||
DEPENDS QmlJS Qt::QuickWidgets
|
||||
PLUGIN_DEPENDS Core ProjectExplorer QtSupport
|
||||
PLUGIN_DEPENDS Core ProjectExplorer QtSupport QmlDesignerBase
|
||||
SOURCES
|
||||
fileformat/filefilteritems.cpp fileformat/filefilteritems.h
|
||||
fileformat/qmlprojectfileformat.cpp fileformat/qmlprojectfileformat.h
|
||||
|
||||
@@ -60,6 +60,16 @@ enum ProjectDirectoryError {
|
||||
|
||||
const QString MENU_ITEM_GENERATE = Tr::tr("Generate CMake Build Files...");
|
||||
|
||||
const QmlBuildSystem *getBuildSystem()
|
||||
{
|
||||
auto project = ProjectExplorer::ProjectManager::startupProject();
|
||||
if (project && project->activeTarget() && project->activeTarget()->buildSystem()) {
|
||||
return qobject_cast<QmlProjectManager::QmlBuildSystem *>(
|
||||
project->activeTarget()->buildSystem());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void generateMenuEntry(QObject *parent)
|
||||
{
|
||||
Core::ActionContainer *menu = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
|
||||
@@ -83,9 +93,8 @@ void generateMenuEntry(QObject *parent)
|
||||
QObject::connect(ProjectExplorer::ProjectManager::instance(),
|
||||
&ProjectExplorer::ProjectManager::startupProjectChanged,
|
||||
[action]() {
|
||||
auto qmlProject = qobject_cast<QmlProject *>(
|
||||
ProjectExplorer::ProjectManager::startupProject());
|
||||
action->setEnabled(qmlProject != nullptr);
|
||||
if (auto buildSystem = getBuildSystem())
|
||||
action->setEnabled(!buildSystem->qtForMCUs());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -247,17 +256,15 @@ const QString projectEnvironmentVariable(const QString &key)
|
||||
{
|
||||
QString value = {};
|
||||
|
||||
auto *target = ProjectExplorer::ProjectManager::startupProject()->activeTarget();
|
||||
if (target && target->buildSystem()) {
|
||||
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
|
||||
if (buildSystem) {
|
||||
auto envItems = buildSystem->environment();
|
||||
auto confEnv = std::find_if(envItems.begin(), envItems.end(),
|
||||
[key](NameValueItem &item){return item.name == key;});
|
||||
if (confEnv != envItems.end())
|
||||
value = confEnv->value;
|
||||
}
|
||||
if (auto buildSystem = getBuildSystem()) {
|
||||
auto envItems = buildSystem->environment();
|
||||
auto confEnv = std::find_if(envItems.begin(), envItems.end(), [key](NameValueItem &item) {
|
||||
return item.name == key;
|
||||
});
|
||||
if (confEnv != envItems.end())
|
||||
value = confEnv->value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -532,7 +539,6 @@ bool CmakeFileGenerator::includeFile(const FilePath &filePath)
|
||||
return !isFileBlacklisted(filePath.fileName());
|
||||
}
|
||||
|
||||
|
||||
bool CmakeFileGenerator::generateEntryPointFiles(const FilePath &dir)
|
||||
{
|
||||
const QString qtcontrolsConf = GenerateCmake::projectEnvironmentVariable(ENV_VARIABLE_CONTROLCONF);
|
||||
@@ -571,22 +577,19 @@ bool CmakeFileGenerator::generateMainCpp(const FilePath &dir)
|
||||
|
||||
bool envHeaderOk = true;
|
||||
QString environment;
|
||||
auto *target = ProjectExplorer::ProjectManager::startupProject()->activeTarget();
|
||||
if (target && target->buildSystem()) {
|
||||
auto buildSystem = qobject_cast<QmlProjectManager::QmlBuildSystem *>(target->buildSystem());
|
||||
if (buildSystem) {
|
||||
for (EnvironmentItem &envItem : buildSystem->environment()) {
|
||||
QString key = envItem.name;
|
||||
QString value = envItem.value;
|
||||
if (isFileResource(value))
|
||||
value.prepend(":/");
|
||||
environment.append(QString(ENV_HEADER_VARIABLE_LINE).arg(key).arg(value));
|
||||
}
|
||||
QString envHeaderContent = GenerateCmake::readTemplate(ENV_HEADER_TEMPLATE_PATH)
|
||||
.arg(environment);
|
||||
FilePath envHeaderPath = srcDir.pathAppended(FILENAME_ENV_HEADER);
|
||||
envHeaderOk = m_fileQueue.queueFile(envHeaderPath, envHeaderContent);
|
||||
|
||||
if (auto buildSystem = getBuildSystem()) {
|
||||
for (EnvironmentItem &envItem : buildSystem->environment()) {
|
||||
QString key = envItem.name;
|
||||
QString value = envItem.value;
|
||||
if (isFileResource(value))
|
||||
value.prepend(":/");
|
||||
environment.append(QString(ENV_HEADER_VARIABLE_LINE).arg(key).arg(value));
|
||||
}
|
||||
QString envHeaderContent = GenerateCmake::readTemplate(ENV_HEADER_TEMPLATE_PATH)
|
||||
.arg(environment);
|
||||
FilePath envHeaderPath = srcDir.pathAppended(FILENAME_ENV_HEADER);
|
||||
envHeaderOk = m_fileQueue.queueFile(envHeaderPath, envHeaderContent);
|
||||
}
|
||||
|
||||
return cppOk && pluginHeaderOk && envHeaderOk;
|
||||
@@ -609,6 +612,8 @@ bool CmakeFileGenerator::isFileResource(const QString &relativeFilePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //GenerateCmake
|
||||
} //QmlProjectManager
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace QmlProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
const char INSTALL_QDS_URL[] = "https://www.qt.io/product/ui-design-tools";
|
||||
const char OBJECT_NAME_LANDING_PAGE[] = "QQuickWidgetQDSLandingPage";
|
||||
|
||||
QdsLandingPageWidget::QdsLandingPageWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -50,6 +51,7 @@ QQuickWidget *QdsLandingPageWidget::widget()
|
||||
QdsLandingPageTheme::setupTheme(m_widget->engine());
|
||||
|
||||
m_widget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
m_widget->setObjectName(OBJECT_NAME_LANDING_PAGE);
|
||||
m_widget->engine()->addImportPath(landingPath + "/imports");
|
||||
m_widget->engine()->addImportPath(resourcePath);
|
||||
m_widget->engine()->addImportPath("qrc:/studiofonts");
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "qmlprojectmanagertr.h"
|
||||
#include "qmlprojectnodes.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -17,6 +18,7 @@
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <projectexplorer/deploymentdata.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
@@ -75,15 +77,20 @@ static bool allowOnlySingleProject()
|
||||
return !settings->value(qdsAllowMultipleProjects, false).toBool();
|
||||
}
|
||||
|
||||
Utils::FilePaths QmlProject::getUiQmlFilesForFolder(const Utils::FilePath &folder)
|
||||
Utils::FilePaths QmlProject::collectUiQmlFilesForFolder(const Utils::FilePath &folder) const
|
||||
{
|
||||
const Utils::FilePaths uiFiles = files([&](const ProjectExplorer::Node *node) {
|
||||
return node->filePath().completeSuffix() == "ui.qml"
|
||||
&& node->filePath().parentDir() == folder;
|
||||
&& node->filePath().parentDir() == folder;
|
||||
});
|
||||
return uiFiles;
|
||||
}
|
||||
|
||||
FilePaths QmlProject::collectQmlFiles() const
|
||||
{
|
||||
return files([](const Node *node) { return node->filePath().suffix() == "qml"; });
|
||||
}
|
||||
|
||||
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
||||
{
|
||||
@@ -125,10 +132,13 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
Utils::Id());
|
||||
});
|
||||
} else {
|
||||
Utils::FilePaths uiFiles = getUiQmlFilesForFolder(projectDirectory()
|
||||
/ "content");
|
||||
Utils::FilePaths uiFiles = collectUiQmlFilesForFolder(
|
||||
projectDirectory().pathAppended("content"));
|
||||
if (uiFiles.isEmpty())
|
||||
uiFiles = getUiQmlFilesForFolder(projectDirectory());
|
||||
uiFiles = collectUiQmlFilesForFolder(projectDirectory());
|
||||
|
||||
if (uiFiles.isEmpty())
|
||||
uiFiles = collectQmlFiles();
|
||||
|
||||
if (!uiFiles.isEmpty()) {
|
||||
Utils::FilePath currentFile;
|
||||
@@ -139,6 +149,8 @@ QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
QTimer::singleShot(1000, [uiFiles]() {
|
||||
Core::EditorManager::openEditor(uiFiles.first(),
|
||||
Utils::Id());
|
||||
Core::ModeManager::activateMode(
|
||||
Core::Constants::MODE_DESIGN);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -346,12 +358,22 @@ FilePath QmlBuildSystem::mainUiFile() const
|
||||
|
||||
FilePath QmlBuildSystem::mainFilePath() const
|
||||
{
|
||||
return projectDirectory().resolvePath(mainFile());
|
||||
const auto mainFileString = mainFile();
|
||||
|
||||
if (mainFileString.isEmpty())
|
||||
return {};
|
||||
|
||||
return projectDirectory().resolvePath(mainFileString);
|
||||
}
|
||||
|
||||
FilePath QmlBuildSystem::mainUiFilePath() const
|
||||
{
|
||||
return projectDirectory().resolvePath(mainUiFile());
|
||||
const auto mainUiFileString = mainUiFile();
|
||||
|
||||
if (mainUiFileString.isEmpty())
|
||||
return {};
|
||||
|
||||
return projectDirectory().resolvePath(mainUiFileString);
|
||||
}
|
||||
|
||||
bool QmlBuildSystem::setMainFileInProjectFile(const FilePath &newMainFilePath)
|
||||
|
||||
@@ -150,7 +150,8 @@ protected:
|
||||
|
||||
private:
|
||||
ProjectExplorer::DeploymentKnowledge deploymentKnowledge() const override;
|
||||
Utils::FilePaths getUiQmlFilesForFolder(const Utils::FilePath &folder);
|
||||
Utils::FilePaths collectUiQmlFilesForFolder(const Utils::FilePath &folder) const;
|
||||
Utils::FilePaths collectQmlFiles() const;
|
||||
|
||||
QMetaObject::Connection m_openFileConnection;
|
||||
};
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmldesignerbase/qmldesignerbaseplugin.h>
|
||||
#include <qmldesignerbase/utils/qmlpuppetpaths.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
|
||||
@@ -62,6 +65,7 @@ private:
|
||||
QmlMainFileAspect *m_qmlMainFileAspect = nullptr;
|
||||
QmlMultiLanguageAspect *m_multiLanguageAspect = nullptr;
|
||||
SelectionAspect *m_qtversionAspect = nullptr;
|
||||
mutable bool usePuppetAsQmlRuntime = false;
|
||||
};
|
||||
|
||||
QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
@@ -80,6 +84,8 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
setCommandLineGetter([this, target] {
|
||||
const FilePath qmlRuntime = qmlRuntimeFilePath();
|
||||
CommandLine cmd(qmlRuntime);
|
||||
if (usePuppetAsQmlRuntime)
|
||||
cmd.addArg("--qml-runtime");
|
||||
|
||||
// arguments in .user file
|
||||
cmd.addArgs(aspect<ArgumentsAspect>()->arguments(), CommandLine::Raw);
|
||||
@@ -193,6 +199,7 @@ QString QmlProjectRunConfiguration::disabledReason() const
|
||||
|
||||
FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
{
|
||||
usePuppetAsQmlRuntime = false;
|
||||
// Give precedence to the manual override in the run configuration.
|
||||
const FilePath qmlViewer = m_qmlViewerAspect->filePath();
|
||||
if (!qmlViewer.isEmpty())
|
||||
@@ -212,6 +219,14 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
// i.e. not necessarily something the device can use, but the
|
||||
// device had its chance above.
|
||||
if (QtVersion *version = QtKitAspect::qtVersion(kit)) {
|
||||
if (version->qtVersion().majorVersion() > 5) {
|
||||
auto [workingDirectoryPath, puppetPath] = QmlDesigner::QmlPuppetPaths::qmlPuppetPaths(
|
||||
target(), QmlDesigner::QmlDesignerBasePlugin::settings());
|
||||
if (!puppetPath.isEmpty()) {
|
||||
usePuppetAsQmlRuntime = true;
|
||||
return puppetPath;
|
||||
}
|
||||
}
|
||||
const FilePath qmlRuntime = version->qmlRuntimeFilePath();
|
||||
if (!qmlRuntime.isEmpty())
|
||||
return qmlRuntime;
|
||||
|
||||
Reference in New Issue
Block a user