McuSupport: add template for qmlproject-based projects

Adds a new option for creating qmlproject-based MCU projects
in the "New Project" wizard. The generated qmlproject file
contains all the supported properties and nodes, prefilled
with their default values, for easy tweaking by users without
requiring to dive into the documentation.

No extra fonts, translations or images are generated, but
empty placeholder nodes for them are found in the qmlproject file,
for the user to fill in.
One custom module with a simple Text item is generated, in
order to demonstrate how to use the modules feature.

The required QmlProjectExporter version for building the project
is the one packaged with Qt for MCUs 2.3.0.

Task-number: QTCREATORBUG-26042
Change-Id: I4569306f2f6e7b9370dfa65cacd0b65c2e4fcb06
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Piotr Mućko <piotr.mucko@qt.io>
Reviewed-by: Dawid Śliwa <dawid.sliwa@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Christiaan Janssen
2022-06-24 13:10:18 +02:00
parent b364cfde23
commit 75b5d1baf1
9 changed files with 267 additions and 25 deletions

View File

@@ -7,8 +7,13 @@
<file>wizards/icon.png</file> <file>wizards/icon.png</file>
<file>wizards/icon@2x.png</file> <file>wizards/icon@2x.png</file>
<file>wizards/application/CMakeLists.txt</file> <file>wizards/application/CMakeLists.txt</file>
<file>wizards/application/project.qmlproject.tpl</file>
<file>wizards/application/main.qml.tpl</file> <file>wizards/application/main.qml.tpl</file>
<file>wizards/application/wizard.json</file> <file>wizards/application/wizard.json</file>
<file>wizards/qmlproject/CMakeLists.txt</file>
<file>wizards/qmlproject/main.qml.tpl</file>
<file>wizards/qmlproject/project.qmlproject.tpl</file>
<file>wizards/qmlproject/module.qmlproject.tpl</file>
<file>wizards/qmlproject/component.qml.tpl</file>
<file>wizards/qmlproject/wizard.json</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -1,19 +0,0 @@
/* File generated by Qt Creator */
import QmlProject 1.1
Project {
mainFile: "%{MainQmlFile}"
qtForMCUs: true
/* Include .qml, .js, and image files from current directory and subdirectories */
QmlFiles {
directory: "."
}
JavaScriptFiles {
directory: "."
}
ImageFiles {
directory: "."
}
}

View File

@@ -49,11 +49,6 @@
"source": "CMakeLists.txt", "source": "CMakeLists.txt",
"openAsProject": true "openAsProject": true
}, },
{
"source": "project.qmlproject.tpl",
"target": "%{ProjectDirectory}/%{ProjectName}.qmlproject",
"openInEditor": false
},
{ {
"source": "main.qml.tpl", "source": "main.qml.tpl",
"target": "%{ProjectDirectory}/%{MainQmlFile}", "target": "%{ProjectDirectory}/%{MainQmlFile}",

View File

@@ -0,0 +1,9 @@
cmake_minimum_required (VERSION 3.15)
project(%{ProjectName} VERSION 0.0.1 LANGUAGES C CXX ASM ASM_MASM)
find_package(Qul)
qul_add_target(%{ProjectName} QML_PROJECT %{QmlProjectFile})
app_target_setup_os(%{ProjectName})
app_target_default_entrypoint(%{ProjectName} %{RootItemName})

View File

@@ -0,0 +1,7 @@
import QtQuick 2.0
Text {
color: "salmon"
text: "Hello World!"
font.pixelSize: 14
}

View File

@@ -0,0 +1,11 @@
import QtQuick 2.0
import CustomModule
Rectangle {
width: 480
height: 272
CustomComponent {
anchors.centerIn: parent
}
}

View File

@@ -0,0 +1,12 @@
import QmlProject 1.3
Project {
MCU.Module {
uri: "CustomModule"
generateQmltypes: true
}
QmlFiles {
files: ["%{QmlComponent}"]
}
}

View File

@@ -0,0 +1,139 @@
import QmlProject 1.3
Project {
// importPaths: ["."] // optional extra import paths
// projectRootPath: "." // optional root path relative to qmlproject file path
/* Global configuration */
MCU.Config {
controlsStyle: "QtQuick.Controls.StyleDefault"
debugBytecode: false
debugLineDirectives: false
binaryAssetOptions: "Automatic"
// platformImageAlignment: 1 // undefined by default
platformPixelWidthAlignment: 1
platformAlphaPixelFormat: "ARGB8888"
platformOpaquePixelFormat: "XRGB8888"
platformAlphaCompressedLosslessResourcePixelFormat: "ARGB8888RLE"
platformOpaqueCompressedLosslessResourcePixelFormat: "RGB888RLE"
// maxResourceCacheSize: 102400 // undefined by default
// global defaults for image properties
resourceAlphaOptions: "ForTransformations"
resourceRlePremultipliedAlpha: true
resourceImagePixelFormat: "Automatic"
resourceCachePolicy: "OnStartup"
resourceCompression: false
resourceStorageSection: "QulResourceData"
resourceRuntimeAllocationType: 3
resourceOptimizeForRotation: false
resourceOptimizeForScale: false
// default font engine selection
fontEngine: "Static" // alternative option: "Spark"
// font defaults for both engines
defaultFontFamily: "DejaVu Sans"
defaultFontQuality: "VeryHigh"
glyphsCachePolicy: "OnStartup"
glyphsStorageSection: "QulFontResourceData"
glyphsRuntimeAllocationType: 3
// font defaults for "Static"
autoGenerateGlyphs: true
complexTextRendering: true
fontFilesCachePolicy: "OnStartup"
fontFilesStorageSection: "QulFontResourceData"
fontFilesRuntimeAllocationType: 3
// font properties for "Spark"
fontCachePriming: true
fontCacheSize: 104800
fontHeapSize: -1
fontHeapPrealloc: true
fontCachePrealloc: true
fontVectorOutlinesDrawing: false
maxParagraphSize: 100
}
/* QML files */
// optional root property for adding one single qml file
// mainFile: "%{MainQmlFile}"
QmlFiles {
files: ["%{MainQmlFile}"]
MCU.copyQmlFiles: false
}
/* Images */
ImageFiles {
// files: [""] // uncomment and add image files
MCU.base: "images" // example base "images".
MCU.prefix: "pics" // example prefix "pics".
MCU.resourceAlphaOptions: "ForTransformations"
MCU.resourceRlePremultipliedAlpha: true
MCU.resourceImagePixelFormat: "Automatic"
MCU.resourceCachePolicy: "OnStartup"
MCU.resourceCompression: false
MCU.resourceStorageSection: "QulResourceData"
MCU.resourceRuntimeAllocationType: 3
MCU.resourceOptimizeForRotation: false
MCU.resourceOptimizeForScale: false
}
/* Modules */
ModuleFiles {
files: ["%{ModuleFile}"]
// qulModules: [ // Uncomment for adding Qul modules
// "Qul::Controls",
// "Qul::ControlsTemplates",
// "Qul::Shapes",
// "Qul::Timeline"
// ]
}
/* Interfaces */
InterfaceFiles {
// files: [""] // uncomment for adding header files
MCU.qmlImports: ["QtQuick"]
}
/* Translations */
TranslationFiles {
// files: [""] // Uncomment for adding translation files with .ts extension
MCU.omitSourceLanguage: false
}
FontFiles {
// files: [""] // Uncomment for adding font files (.ttf, .otf, .pfa, .ttc, .pfb)
MCU.addDefaultFonts: true
}
FontConfiguration {
// font engine selection overriddes default
MCU.fontEngine: "Static" // or "Spark"
// properties shared between both engines
MCU.defaultFontFamily: "DejaVu Sans"
MCU.defaultFontQuality: "VeryHigh"
MCU.glyphsCachePolicy: "OnStartup"
MCU.glyphsStorageSection: "QulFontResourceData"
MCU.glyphsRuntimeAllocationType: 3
// properties for Static engine
MCU.autoGenerateGlyphs: true
MCU.complexTextRendering: true
MCU.fontFilesCachePolicy: "OnStartup"
MCU.fontFilesStorageSection: "QulFontResourceData"
MCU.fontFilesRuntimeAllocationType: 3
// monotype for Spark engine
MCU.fontCachePriming: true
MCU.fontCacheSize: 104800
MCU.fontHeapSize: -1
MCU.fontHeapPrealloc: true
MCU.fontCachePrealloc: true
MCU.fontVectorOutlinesDrawing: false
MCU.maxParagraphSize: 100
}
}

View File

@@ -0,0 +1,83 @@
{
"version": 1,
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject" ],
"id": "M.McuSupportQmlprojectApplication",
"category": "D.ApplicationMCU",
"trDescription": "Creates an Mcu Support application with an empty UI, based on qmlproject (Technical Preview).",
"trDisplayName": "Qt for MCUs QmlProject Application (Technical Preview)",
"trDisplayCategory": "QmlProject Application (Qt for MCU)",
"icon": "../icon.png",
"iconKind": "Themed",
"enabled": true,
"options":
[
{ "key": "MainQmlFile", "value": "%{ProjectName}.qml" },
{ "key": "QmlProjectFile", "value": "%{ProjectName}.qmlproject" },
{ "key": "RootItemName", "value": "%{ProjectName}" },
{ "key": "CMakeFile", "value": "%{ProjectDirectory}/CMakeLists.txt" },
{ "key": "ModuleFile", "value": "CustomModule.qmlproject"},
{ "key": "QmlComponent", "value": "CustomComponent.qml"}
],
"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project"
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"enabled": "%{JS: !value('IsSubproject')}",
"data": {
"projectFilePath": "%{CMakeFile}"
}
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "CMakeLists.txt",
"openAsProject": true
},
{
"source": "project.qmlproject.tpl",
"target": "%{ProjectDirectory}/%{QmlProjectFile}",
"openInEditor": true
},
{
"source": "main.qml.tpl",
"target": "%{ProjectDirectory}/%{MainQmlFile}",
"openInEditor": true
},
{
"source": "component.qml.tpl",
"target": "%{ProjectDirectory}/%{QmlComponent}",
"openInEditor": true
},
{
"source": "module.qmlproject.tpl",
"target": "%{ProjectDirectory}/%{ModuleFile}",
"openInEditor": true
},
{
"source": "%{IDE:ResourcePath}/templates/wizards/projects/git.ignore",
"target": ".gitignore",
"condition": "%{JS: !value('IsSubproject') && value('VersionControl') === 'G.Git'}"
}
]
}
]
}