forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/10.0' into qds/dev
bigger conflicts resolved at: src/plugins/qmldesigner/CMakeLists.txt src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp Change-Id: I08e2a109d8e37cbd77225129854e9e633725bfc7
This commit is contained in:
@@ -1,16 +1,12 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmlprojectrunconfiguration.h"
|
||||
#include "qmlmainfileaspect.h"
|
||||
#include "qmlmultilanguageaspect.h"
|
||||
#include "qmlproject.h"
|
||||
#include "qmlprojectmanagerconstants.h"
|
||||
|
||||
#include <qmlpuppetpaths.h>
|
||||
|
||||
// getting the qmlpuppet path from setings
|
||||
#include <app/app_version.h>
|
||||
#include "qmlprojectmanagertr.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
@@ -29,6 +25,7 @@
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmldesignerbase/qmldesignerbaseplugin.h>
|
||||
#include <qmldesignerbase/utils/qmlpuppetpaths.h>
|
||||
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtsupportconstants.h>
|
||||
@@ -47,16 +44,12 @@ using namespace ProjectExplorer;
|
||||
using namespace QtSupport;
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlProjectManager {
|
||||
class QmlMultiLanguageAspect;
|
||||
namespace Internal {
|
||||
namespace QmlProjectManager::Internal {
|
||||
|
||||
// QmlProjectRunConfiguration
|
||||
|
||||
class QmlProjectRunConfiguration final : public RunConfiguration
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QmlProjectManager::QmlProjectRunConfiguration)
|
||||
|
||||
public:
|
||||
QmlProjectRunConfiguration(Target *target, Id id);
|
||||
|
||||
@@ -64,9 +57,8 @@ private:
|
||||
QString disabledReason() const final;
|
||||
bool isEnabled() const final;
|
||||
|
||||
QString mainScript() const;
|
||||
FilePath mainScript() const;
|
||||
FilePath qmlRuntimeFilePath() const;
|
||||
QString commandLineArguments() const;
|
||||
void createQtVersionAspect();
|
||||
|
||||
StringAspect *m_qmlViewerAspect = nullptr;
|
||||
@@ -80,7 +72,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
: RunConfiguration(target, id)
|
||||
{
|
||||
m_qmlViewerAspect = addAspect<StringAspect>();
|
||||
m_qmlViewerAspect->setLabelText(tr("QML Viewer:"));
|
||||
m_qmlViewerAspect->setLabelText(Tr::tr("Override device QML viewer:"));
|
||||
m_qmlViewerAspect->setPlaceHolderText(qmlRuntimeFilePath().toUserOutput());
|
||||
m_qmlViewerAspect->setDisplayStyle(StringAspect::PathChooserDisplay);
|
||||
m_qmlViewerAspect->setHistoryCompleter("QmlProjectManager.viewer.history");
|
||||
@@ -89,8 +81,44 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
auto argumentAspect = addAspect<ArgumentsAspect>(macroExpander());
|
||||
argumentAspect->setSettingsKey(Constants::QML_VIEWER_ARGUMENTS_KEY);
|
||||
|
||||
setCommandLineGetter([this] {
|
||||
return CommandLine(qmlRuntimeFilePath(), commandLineArguments(), CommandLine::Raw);
|
||||
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);
|
||||
|
||||
// arguments from .qmlproject file
|
||||
const QmlBuildSystem *bs = qobject_cast<QmlBuildSystem *>(target->buildSystem());
|
||||
const QStringList importPaths = QmlBuildSystem::makeAbsolute(bs->targetDirectory(),
|
||||
bs->customImportPaths());
|
||||
for (const QString &importPath : importPaths) {
|
||||
cmd.addArg("-I");
|
||||
cmd.addArg(importPath);
|
||||
}
|
||||
|
||||
for (const QString &fileSelector : bs->customFileSelectors()) {
|
||||
cmd.addArg("-S");
|
||||
cmd.addArg(fileSelector);
|
||||
}
|
||||
|
||||
if (qmlRuntime.osType() == OsTypeWindows && bs->forceFreeType()) {
|
||||
cmd.addArg("-platform");
|
||||
cmd.addArg("windows:fontengine=freetype");
|
||||
}
|
||||
|
||||
if (bs->qt6Project() && bs->widgetApp()) {
|
||||
cmd.addArg("--apptype");
|
||||
cmd.addArg("widget");
|
||||
}
|
||||
|
||||
const FilePath main = bs->targetFile(mainScript());
|
||||
if (!main.isEmpty())
|
||||
cmd.addArg(main.nativePath());
|
||||
|
||||
return cmd;
|
||||
});
|
||||
|
||||
m_qmlMainFileAspect = addAspect<QmlMainFileAspect>(target);
|
||||
@@ -129,67 +157,68 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
|
||||
|
||||
const Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(target->kit());
|
||||
if (deviceTypeId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
envAspect->addPreferredBaseEnvironment(tr("System Environment"), [envModifier] {
|
||||
envAspect->addPreferredBaseEnvironment(Tr::tr("System Environment"), [envModifier] {
|
||||
return envModifier(Environment::systemEnvironment());
|
||||
});
|
||||
}
|
||||
|
||||
envAspect->addSupportedBaseEnvironment(tr("Clean Environment"), [envModifier] {
|
||||
envAspect->addSupportedBaseEnvironment(Tr::tr("Clean Environment"), [envModifier] {
|
||||
Environment environment;
|
||||
return envModifier(environment);
|
||||
});
|
||||
|
||||
if (HostOsInfo::isAnyUnixHost())
|
||||
addAspect<X11ForwardingAspect>(macroExpander());
|
||||
|
||||
setRunnableModifier([this](Runnable &r) {
|
||||
const QmlBuildSystem *bs = static_cast<QmlBuildSystem *>(activeBuildSystem());
|
||||
r.workingDirectory = bs->targetDirectory();
|
||||
if (const auto * const forwardingAspect = aspect<X11ForwardingAspect>())
|
||||
r.extraData.insert("Ssh.X11ForwardToDisplay", forwardingAspect->display());
|
||||
});
|
||||
|
||||
setDisplayName(tr("QML Utility", "QMLRunConfiguration display name."));
|
||||
setDisplayName(Tr::tr("QML Utility", "QMLRunConfiguration display name."));
|
||||
update();
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (mainScript().isEmpty())
|
||||
return tr("No script file to execute.");
|
||||
return Tr::tr("No script file to execute.");
|
||||
|
||||
const FilePath viewer = qmlRuntimeFilePath();
|
||||
if (DeviceTypeKitAspect::deviceTypeId(kit())
|
||||
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
|
||||
&& !viewer.exists()) {
|
||||
return tr("No QML utility found.");
|
||||
return Tr::tr("No QML utility found.");
|
||||
}
|
||||
if (viewer.isEmpty())
|
||||
return tr("No QML utility specified for target device.");
|
||||
return Tr::tr("No QML utility specified for target device.");
|
||||
return RunConfiguration::disabledReason();
|
||||
}
|
||||
|
||||
FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
{
|
||||
usePuppetAsQmlRuntime = false;
|
||||
// Give precedence to the manual override.
|
||||
// Give precedence to the manual override in the run configuration.
|
||||
const FilePath qmlViewer = m_qmlViewerAspect->filePath();
|
||||
if (!qmlViewer.isEmpty())
|
||||
return qmlViewer;
|
||||
|
||||
Kit *kit = target()->kit();
|
||||
IDevice::ConstPtr dev = DeviceKitAspect::device(kit);
|
||||
if (!dev.isNull()) {
|
||||
|
||||
// We might not have a full Qt version for building, but the device
|
||||
// might know what is good for running.
|
||||
if (IDevice::ConstPtr dev = DeviceKitAspect::device(kit)) {
|
||||
const FilePath qmlRuntime = dev->qmlRunCommand();
|
||||
if (!qmlRuntime.isEmpty())
|
||||
return qmlRuntime;
|
||||
}
|
||||
|
||||
// If not given explicitly by device, try to pick it from $PATH.
|
||||
QtVersion *version = QtKitAspect::qtVersion(kit);
|
||||
if (!version) // No Qt version in Kit. Don't try to run QML runtime.
|
||||
return {};
|
||||
|
||||
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(kit);
|
||||
if (deviceType == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) {
|
||||
// If not given explicitly by Qt Version, try to pick it from $PATH.
|
||||
const bool isDesktop = version->type() == QtSupport::Constants::DESKTOPQT;
|
||||
|
||||
// The Qt version might know. That's the "build" Qt version,
|
||||
// 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());
|
||||
@@ -198,60 +227,14 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
|
||||
return puppetPath;
|
||||
}
|
||||
}
|
||||
|
||||
return isDesktop ? version->qmlRuntimeFilePath() : "qmlscene";
|
||||
const FilePath qmlRuntime = version->qmlRuntimeFilePath();
|
||||
if (!qmlRuntime.isEmpty())
|
||||
return qmlRuntime;
|
||||
}
|
||||
|
||||
if (dev.isNull()) // No device set. We don't know where a QML utility is.
|
||||
return {};
|
||||
|
||||
const FilePath qmlRuntime = dev->qmlRunCommand();
|
||||
// If not given explicitly by device, try to pick it from $PATH.
|
||||
return qmlRuntime.isEmpty() ? "qml" : qmlRuntime;
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::commandLineArguments() const
|
||||
{
|
||||
QString args;
|
||||
if (usePuppetAsQmlRuntime)
|
||||
ProcessArgs::addArg(&args, "--qml-runtime");
|
||||
|
||||
// arguments in .user file
|
||||
if (!aspect<ArgumentsAspect>()->arguments().isEmpty())
|
||||
ProcessArgs::addArg(&args, aspect<ArgumentsAspect>()->arguments());
|
||||
const IDevice::ConstPtr device = DeviceKitAspect::device(kit());
|
||||
const OsType osType = device ? device->osType() : HostOsInfo::hostOs();
|
||||
|
||||
// arguments from .qmlproject file
|
||||
const QmlBuildSystem *bs = qobject_cast<QmlBuildSystem *>(target()->buildSystem());
|
||||
const QStringList importPaths = QmlBuildSystem::makeAbsolute(bs->targetDirectory(),
|
||||
bs->customImportPaths());
|
||||
for (const QString &importPath : importPaths) {
|
||||
ProcessArgs::addArg(&args, "-I", osType);
|
||||
ProcessArgs::addArg(&args, importPath, osType);
|
||||
}
|
||||
|
||||
for (const QString &fileSelector : bs->customFileSelectors()) {
|
||||
ProcessArgs::addArg(&args, "-S", osType);
|
||||
ProcessArgs::addArg(&args, fileSelector, osType);
|
||||
}
|
||||
|
||||
if (HostOsInfo::isWindowsHost() && bs->forceFreeType()) {
|
||||
ProcessArgs::addArg(&args, "-platform", osType);
|
||||
ProcessArgs::addArg(&args, "windows:fontengine=freetype", osType);
|
||||
}
|
||||
|
||||
if (bs->qt6Project() && bs->widgetApp()) {
|
||||
ProcessArgs::addArg(&args, "--apptype", osType);
|
||||
ProcessArgs::addArg(&args, "widget", osType);
|
||||
}
|
||||
|
||||
const QString main = bs->targetFile(FilePath::fromString(mainScript())).toString();
|
||||
if (!main.isEmpty())
|
||||
ProcessArgs::addArg(&args, main, osType);
|
||||
|
||||
|
||||
return args;
|
||||
// If not given explicitly by run device, nor Qt, try to pick
|
||||
// it from $PATH on the run device.
|
||||
return "qml";
|
||||
}
|
||||
|
||||
void QmlProjectRunConfiguration::createQtVersionAspect()
|
||||
@@ -261,7 +244,7 @@ void QmlProjectRunConfiguration::createQtVersionAspect()
|
||||
|
||||
m_qtversionAspect = addAspect<SelectionAspect>();
|
||||
m_qtversionAspect->setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
||||
m_qtversionAspect->setLabelText(tr("Qt Version:"));
|
||||
m_qtversionAspect->setLabelText(Tr::tr("Qt Version:"));
|
||||
m_qtversionAspect->setSettingsKey("QmlProjectManager.kit");
|
||||
|
||||
Kit *kit = target()->kit();
|
||||
@@ -272,11 +255,11 @@ void QmlProjectRunConfiguration::createQtVersionAspect()
|
||||
const bool isQt6Project = buildSystem && buildSystem->qt6Project();
|
||||
|
||||
if (isQt6Project) {
|
||||
m_qtversionAspect->addOption(tr("Qt 6"));
|
||||
m_qtversionAspect->addOption(Tr::tr("Qt 6"));
|
||||
m_qtversionAspect->setReadOnly(true);
|
||||
} else { /* Only if this is not a Qt 6 project changing kits makes sense */
|
||||
m_qtversionAspect->addOption(tr("Qt 5"));
|
||||
m_qtversionAspect->addOption(tr("Qt 6"));
|
||||
m_qtversionAspect->addOption(Tr::tr("Qt 5"));
|
||||
m_qtversionAspect->addOption(Tr::tr("Qt 6"));
|
||||
|
||||
const int valueForVersion = version->qtVersion().majorVersion() == 6 ? 1 : 0;
|
||||
|
||||
@@ -324,7 +307,7 @@ bool QmlProjectRunConfiguration::isEnabled() const
|
||||
&& activeBuildSystem()->hasParsingData();
|
||||
}
|
||||
|
||||
QString QmlProjectRunConfiguration::mainScript() const
|
||||
FilePath QmlProjectRunConfiguration::mainScript() const
|
||||
{
|
||||
return m_qmlMainFileAspect->mainScript();
|
||||
}
|
||||
@@ -332,12 +315,11 @@ QString QmlProjectRunConfiguration::mainScript() const
|
||||
// QmlProjectRunConfigurationFactory
|
||||
|
||||
QmlProjectRunConfigurationFactory::QmlProjectRunConfigurationFactory()
|
||||
: FixedRunConfigurationFactory(QmlProjectRunConfiguration::tr("QML Runtime"), false)
|
||||
: FixedRunConfigurationFactory(Tr::tr("QML Runtime"), false)
|
||||
{
|
||||
registerRunConfiguration<QmlProjectRunConfiguration>
|
||||
("QmlProjectManager.QmlRunConfiguration.Qml");
|
||||
addSupportedProjectType(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProjectManager
|
||||
} // QmlProjectManager::Internal
|
||||
|
||||
Reference in New Issue
Block a user