diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2023-01-23 22:58:50 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2023-01-25 11:44:34 +0000 |
commit | 43b853298296d617babb5f8b60d3c54603fef422 (patch) | |
tree | 85f88d87fe41ca6994b0f41689ad51048bb867bc /src/plugins/qmlprojectmanager | |
parent | c1380bee4ca8842c9245f457f36186913fc8724b (diff) | |
download | qt-creator-43b853298296d617babb5f8b60d3c54603fef422.tar.gz |
QmlDesigner: get qmlPuppetPath by duplicating settings
This should be a temporary solution. Read settings
at two different code locations is error prone.
Idea is to introduce a general QmlDesignerUtilsLib which can handle that.
Change-Id: Ic670d2c63f134ba8f1b1455d000b7c2f372b1d61
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/plugins/qmlprojectmanager')
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index ba2ba9717f..f88d6d24d9 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -7,6 +7,9 @@ #include "qmlmainfileaspect.h" #include "qmlmultilanguageaspect.h" +// getting the qmlpuppet path from setings +#include <app/app_version.h> + #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/ieditor.h> #include <coreplugin/icore.h> @@ -40,6 +43,51 @@ using namespace ProjectExplorer; using namespace QtSupport; using namespace Utils; +namespace { +Utils::FilePath qmlPuppetPath(const Utils::FilePath puppetDirectoryPath) +{ + return puppetDirectoryPath.pathAppended(QString{"qml2puppet-"} + + Core::Constants::IDE_VERSION_LONG).withExecutableSuffix(); +} + +Utils::FilePath qmlPuppetPathFromSettings() +{ + const char PUPPET_DEFAULT_DIRECTORY[] = "PuppetDefaultDirectory"; + const char QML_SETTINGS_GROUP[] = "QML"; + const char QML_DESIGNER_SETTINGS_GROUP[] = "Designer"; + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(QLatin1String(QML_SETTINGS_GROUP)); + settings->beginGroup(QLatin1String(QML_DESIGNER_SETTINGS_GROUP)); + + auto puppetFallbackDirectory = Utils::FilePath::fromString( + settings->value(PUPPET_DEFAULT_DIRECTORY).toString()); + + settings->endGroup(); + settings->endGroup(); + + if (!puppetFallbackDirectory.isEmpty() && puppetFallbackDirectory.exists()) + return qmlPuppetPath(puppetFallbackDirectory); + + return {}; +} + +Utils::FilePath puppetAsQmlRuntime(QtVersion *version) +{ + if (version->qtVersion() >= QVersionNumber(6, 4, 0)) { + Utils::FilePath qmlPuppetFilePath = qmlPuppetPathFromSettings(); + if (qmlPuppetFilePath.isExecutableFile()) + return qmlPuppetFilePath; + else { + qmlPuppetFilePath = qmlPuppetPath(version->binPath()); + if (qmlPuppetFilePath.isExecutableFile()) + return qmlPuppetFilePath; + } + } + return {}; +} + +} // namespace + namespace QmlProjectManager { class QmlMultiLanguageAspect; namespace Internal { @@ -66,6 +114,7 @@ private: QmlMainFileAspect *m_qmlMainFileAspect = nullptr; QmlMultiLanguageAspect *m_multiLanguageAspect = nullptr; SelectionAspect *m_qtversionAspect = nullptr; + mutable bool usePuppetAsQmlRuntime = false; }; QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) @@ -158,6 +207,7 @@ QString QmlProjectRunConfiguration::disabledReason() const FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const { + usePuppetAsQmlRuntime = false; // Give precedence to the manual override. const FilePath qmlViewer = m_qmlViewerAspect->filePath(); if (!qmlViewer.isEmpty()) @@ -180,6 +230,13 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const 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; + + Utils::FilePath puppetAsQmlRuntimePath = puppetAsQmlRuntime(version); + if (!puppetAsQmlRuntimePath.isEmpty()) { + usePuppetAsQmlRuntime = true; + return puppetAsQmlRuntimePath; + } + return isDesktop ? version->qmlRuntimeFilePath() : "qmlscene"; } @@ -193,8 +250,13 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const QString QmlProjectRunConfiguration::commandLineArguments() const { + QString args; + if (usePuppetAsQmlRuntime) + ProcessArgs::addArg(&args, "--qml-runtime"); + // arguments in .user file - QString args = aspect<ArgumentsAspect>()->arguments(); + 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(); |