From 88103453f25d4ecda171ae1a0aeef96a81edf189 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 4 Dec 2019 13:10:38 +0100 Subject: [PATCH] QmlDesigner: Add option forceFreeType to qmlproject This option enforces the usage of FreeType even on Windows for the form editor and live preview. This can be useful when developing for Linux devices. The option can be eanbled by adding 'forceFreeType: true' to the .qmlproject file. Task-number: QDS-1143 Change-Id: I7e749e95584e23202536596ee4f7cdaa09d3a371 Reviewed-by: Tim Jenssen --- .../designercore/instances/puppetcreator.cpp | 16 +++++++++++++++- .../fileformat/qmlprojectfileformat.cpp | 4 ++++ .../fileformat/qmlprojectitem.cpp | 5 +++++ .../fileformat/qmlprojectitem.h | 4 ++++ src/plugins/qmlprojectmanager/qmlproject.cpp | 9 +++++++++ src/plugins/qmlprojectmanager/qmlproject.h | 1 + .../qmlprojectmanager/qmlprojectconstants.h | 1 + .../qmlprojectrunconfiguration.cpp | 5 +++++ 8 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index e40db1872e8..10cdb9135fa 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -218,7 +218,21 @@ QProcess *PuppetCreator::puppetProcess(const QString &puppetPath, QObject::connect(puppetProcess, SIGNAL(readyRead()), handlerObject, outputSlot); } puppetProcess->setWorkingDirectory(workingDirectory); - puppetProcess->start(puppetPath, {socketToken, puppetMode, "-graphicssystem raster"}); + + bool forceFreeType = false; + if (Utils::HostOsInfo::isWindowsHost() && m_currentProject && m_currentProject->activeTarget()) { + const QVariant customData = m_currentProject->activeTarget() + ->additionalData("CustomForceFreeType"); + + if (customData.isValid()) + forceFreeType = customData.toBool(); + } + + QString forceFreeTypeOption; + if (forceFreeType) + forceFreeTypeOption = "-platform windows:fontengine=freetype"; + + puppetProcess->start(puppetPath, {socketToken, puppetMode, "-graphicssystem raster", forceFreeTypeOption }); #ifndef QMLDESIGNER_TEST QString debugPuppet = m_designerSettings.value(DesignerSettingsKey:: diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp index 2b3cfa9bdc9..f62c7c1294e 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp @@ -93,6 +93,10 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi if (fileSelectorsProperty.isValid()) projectItem->setFileSelectors(fileSelectorsProperty.toStringList()); + const QVariant forceFreeTypeProperty = rootNode->property("forceFreeType"); + if (forceFreeTypeProperty.isValid()) + projectItem->setForceFreeType(forceFreeTypeProperty.toBool()); + const QVariant targetDirectoryPropery = rootNode->property("targetDirectory"); if (targetDirectoryPropery.isValid()) projectItem->setTargetDirectory(targetDirectoryPropery.toString()); diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp index 91d8eff591e..b36938b9f22 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.cpp @@ -97,6 +97,11 @@ bool QmlProjectItem::matchesFile(const QString &filePath) const }); } +void QmlProjectItem::setForceFreeType(bool b) +{ + m_forceFreeType = b; +} + Utils::EnvironmentItems QmlProjectItem::environment() const { return m_environment; diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h index 29b2e88d99c..5245e3872cf 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h @@ -60,6 +60,9 @@ public: QStringList files() const; bool matchesFile(const QString &filePath) const; + bool forceFreeType() const { return m_forceFreeType; }; + void setForceFreeType(bool); + QString mainFile() const { return m_mainFile; } void setMainFile(const QString &mainFilePath) { m_mainFile = mainFilePath; } @@ -79,6 +82,7 @@ protected: QString m_mainFile; Utils::EnvironmentItems m_environment; QVector m_content; // content property + bool m_forceFreeType = false; }; } // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index d3d96c20cee..5da4acf3172 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -229,6 +229,13 @@ QStringList QmlProject::customFileSelectors() const return {}; } +bool QmlProject::forceFreeType() const +{ + if (m_projectItem) + return m_projectItem.data()->forceFreeType(); + return false; +} + bool QmlProject::addFiles(const QStringList &filePaths) { QStringList toAdd; @@ -259,6 +266,8 @@ QVariant QmlProject::additionalData(Id id, const Target *) const { if (id == Constants::customFileSelectorsData) return customFileSelectors(); + if (id == Constants::customForceFreeTypeData) + return forceFreeType(); return {}; } diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 9b09cbd5281..6433333278b 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -70,6 +70,7 @@ public: Utils::EnvironmentItems environment() const; QStringList customImportPaths() const; QStringList customFileSelectors() const; + bool forceFreeType() const; bool addFiles(const QStringList &filePaths); diff --git a/src/plugins/qmlprojectmanager/qmlprojectconstants.h b/src/plugins/qmlprojectmanager/qmlprojectconstants.h index eb2ddcddb1d..ecf39bc32ca 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectconstants.h +++ b/src/plugins/qmlprojectmanager/qmlprojectconstants.h @@ -32,6 +32,7 @@ namespace Constants { const char * const QMLPROJECT_MIMETYPE = QmlJSTools::Constants::QMLPROJECT_MIMETYPE; const char customFileSelectorsData[] = "CustomFileSelectorsData"; +const char customForceFreeTypeData[] = "CustomForceFreeType"; } // namespace Constants } // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 6e67361d113..066c28f4557 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -394,6 +394,11 @@ QString QmlProjectRunConfiguration::commandLineArguments() const Utils::QtcProcess::addArg(&args, fileSelector, osType); } + if (Utils::HostOsInfo::isWindowsHost() && project->forceFreeType()) { + Utils::QtcProcess::addArg(&args, "-platform", osType); + Utils::QtcProcess::addArg(&args, "windows:fontengine=freetype", osType); + } + const QString main = project->targetFile(Utils::FilePath::fromString(mainScript()), currentTarget).toString(); if (!main.isEmpty())