What is a standard (Qt) way to create single ui.qml file? - qt

In Qt app example, they use single *.ui.qml form files. I understand everything but I was used to creating 2 files, for example, Contact.qml and ContactForm.ui.qml, instead of one ContactForm.ui.qml. Now if I want to create such a single form file, I have/see two options:
While creating standard QML file (Qt Quick 2), I give name and whole .ui.qml extension.
I create QtQuick Ui File (which creates 2 files) and delete one (business logic) file.
For me, both options seem to be workarounds, not the Qt way. Could you show me the Qt way?

(Casually, you can open not only .ui.qml but any qml file in design mode if you follow the roles see this post).
The list of wizards seen when adding new in Creator, are the standard wizards that Qt probably thinks are sufficient and suitable with a general perspective.
Qt offers a solution though ... you can add your own custom wizard to the list of standard wizards in Qt Creator, following Qt documentation Adding New Custom Wizards creation procedure, so you can add more to existing wizards.
Specifically for .ui.qml only (without the qml file) creation, the section Adding JSON-Based Wizards in the above documentation works just fine, for example:
Start Creator from command line with verbose option:
Qt_base\Tools\QtCreator\bin>qtcreator.exe -customwizard-verbose
In Tools, Options, Keyboard ... filter by Factory.Reset and fill up a new short cut, if one does not exist, for example Ctrl+Alt+F10
In folder C:\Qt\Tools\QtCreator\share\qtcreator\templates\wizards\classes ... copy the wizard folder used to create .ui.qml qtquickui and rename it to any name.
Now and most important, inside the new folder, edit the wizard json file to customize your new wizard ..
(1) Give new id following roles described in the link
(2) under options remove the option for adding qml file along with the form.
(3) under pages, remove the field that prompts for qml file name.
(4) in section "name": "FormClass", modify "trText": "%{Class}Form" to "trText": "Form"
(5) under generators , remove the qml file generator and keep the .ui.qml file generator.
After editing is completed, you can now activate the new wizard, to do that press the short cut created above (Ctrl+Alt+F10) and that's all! you should now see your new wizard when you go Add new under Qt section ...
Here is modified version of wizard.json
{
"version": 1,
"supportedProjectTypes": [ ],
"id": "S.QtQuickUi",
"category": "R.Qt",
"trDescription": "Creates a Qt Quick Designer UI form along with a matching QML file for implementation purposes. You can add the form and file to an existing Qt Quick Project.",
"trDisplayName": "QtQuick UI File Only",
"trDisplayCategory": "Qt",
"iconText": "ui.qml",
"featuresRequired": [ "QtSupport.Wizards.FeatureQtQuick.UiFiles" ],
"enabled": "%{JS: [ %{Plugins} ].indexOf('QmlJSEditor') >= 0}",
"options" : [
{ "key": "UiFile", "value": "%{FormClass}.%{JS: Util.preferredSuffix('application/x-qt.ui+qml')}" }
],
"pages" :
[
{
"trDisplayName": "Define Class",
"trShortTitle": "Details",
"typeId": "Fields",
"data" :
[
{
"name": "FormClass",
"trDisplayName": "Component form name:",
"mandatory": true,
"type": "LineEdit",
"data": {
"validator": "(?:[A-Z_][a-zA-Z_0-9]*|)",
"fixup": "%{JS: '%{INPUT}'.charAt(0).toUpperCase() + '%{INPUT}'.slice(1) }",
"trText": "Form"
}
},
{
"name": "TargetPath",
"type": "PathChooser",
"trDisplayName": "Path:",
"mandatory": true,
"data":
{
"kind": "existingDirectory",
"basePath": "%{InitialPath}",
"path": "%{InitialPath}"
}
}
]
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators" :
[
{
"typeId": "File",
"data": [
{
"source": "fileForm.ui.qml.tpl",
"target": "%{TargetPath}/%{UiFile}",
"openInEditor": true
}
]
}
]
}

This just seems like a missing feature in Creator. Go with option #1 since it's less work, and report a suggestion/bug that there should be a way to create standalone .ui.qml files.

Related

Using reference funtion in an ARM template parameter file

Is there anyway to use the reference funtion in an ARM parameter file? I understand the following can be used to retrieve the intrumentation key of an app insights instance but this doesnt seem to work in a parameter file.
"[reference('microsoft.insights/components/web-app-name-01', '2015-05-01').InstrumentationKey]"
I currently set a long list of environment variables using an array from a parameter file and need to include the dynamic app insights instrumentation key to that list of variables.
Unfortunately, no.
Reference function only works at runtime. It can't be used in the parameters or variables sections because both are resolved during the initial parsing phase of the template.
Here is an excerpt from the docs and also how to use reference correctly:
You can't use the reference function in the variables section of the template. The reference function derives its value from the resource's runtime state. However, variables are resolved during the initial parsing of the template. Construct values that need the reference function directly in the resources or outputs section of the template.
Not in a param file... it's possible to simulate what you want by nested a deployment if that's an option. So your param file can contain the resourceId of the insights resource and then a nested deployment can make the reference call - but TBH, probably easier to fetch the key as a pipeline step (or similar).
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"insightsResourceId": {
"type": "string",
"defaultValue": "'microsoft.insights/components/web-app-name-01'"
}
},
"resources": [
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Resources/deployments",
"name": "nestedDeployment",
"properties": {
"mode": "Incremental",
"parameters": {
"instrumentationKey": {
"value": "[reference(parameters('insightsResourceId'), '2015-05-01').InstrumentationKey]"
}
},
"template": {
// original template goes here
}
}
}
]
}
Way 1
Use the reference function in your parameter file for resources that are already deployed in another template. For that you have to pass the ApiVersion parameter. Refer MsDoc. which follows:
"value": "[reference(resourceId(variables('<AppInsightsResourceGroup>'),'Microsoft.Insights/components', variables('<ApplicationInsightsName>')), '2015-05-01', 'Full').properties.InstrumentationKey]"
You need to change the property that you are referencing from '.InstrumentationKey' to '.properties.InstrumentationKey'.
Refer to Kwill answer for more information.
Way 2
Get the Content of parameter file in PowerShell variable/Object using
$ParameterObject = Get-Content ./ParameterFileName.json
Update the Parameter file values using
#Assign the parameter values using
$ParameterObject.parameters.<KeyName>.value = "your dynamic value"
Pass $parameterObject to -TemplateParameterObject parameter
Refer here
Way 3
You have to Add/Modify the parameter file values using (PowerShell/ Dev lang (like Python, c#,...) ). After changing the parameter file try to deploy it.

How do I change the name of a dotnet new template when creating new projects?

I've created a dotnet template for use with dotnet new. When creating new projects from this template, it works fine however the assembly and namespace name is still "Template", rather than the new project.
I've tried creating a new project and manually setting the name with the --name flag and --output flag, but to no avail.
I suspect there's a variable I can use somewhere, perhaps in the template.json file?
Thanks,
You have to set template then use option params like -n param and give name.
For example,
dotnet new web -n myBestName
you can see more about cli
source click here
You need to set sourceName in your template.json file.
You can refer to this page to find the purpose of each field.
"sourceName": {
"description": "The name in the source tree to replace with the name the user specifies",
"type": "string"
},
http://json.schemastore.org/template
A basic example of template.json file would look like this. Notice the sourceName
{
"$schema": "http://json.schemastore.org/template",
"author": "Me",
"classifications": [ "web api", "asp.net core", "C#" ],
"identity": "WebApi.Template",
"name": "WebApi.Template",
"shortName": "WebApiTemplate",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "WebApi.Template",
"preferNameDirectory" : true
}
If you use template.json similar to above, you can give your component name in cli command either with dotnet new YourTemplateName -n YourComponentName or running just dotnet new YourTemplateName inside the folder named with your component name.

Script paths into Azure Data Factory DataLakeAnalytics u-sql pipeline

I'm trying to publish a data factory solution with this ADF DataLakeAnalyticsU-SQL pipeline activity following the azure step by step doc (https://learn.microsoft.com/en-us/azure/data-factory/data-factory-usql-activity).
{
"type": "DataLakeAnalyticsU-SQL",
"typeProperties": {
"scriptPath": "\\scripts\\111_risk_index.usql",
"scriptLinkedService": "PremiumAzureDataLakeStoreLinkedService",
"degreeOfParallelism": 3,
"priority": 100,
"parameters": {
"in": "/DF_INPUT/Consodata_Prelios_consegna_230617.txt",
"out": "/DF_OUTPUT/111_Analytics.txt"
}
},
"inputs": [
{
"name": "PremiumDataLakeStoreLocation"
}
],
"outputs": [
{
"name": "PremiumDataLakeStoreLocation"
}
],
"policy": {
"timeout": "06:00:00",
"concurrency": 1,
"executionPriorityOrder": "NewestFirst",
"retry": 1
},
"scheduler": {
"frequency": "Minute",
"interval": 15
},
"name": "ConsodataFilesProcessing",
"linkedServiceName": "PremiumAzureDataLakeAnalyticsLinkedService"
}
During publishing got this error:
25/07/2017 18:51:59- Publishing Project 'Premium.DataFactory'....
25/07/2017 18:51:59- Validating 6 json files
25/07/2017 18:52:15- Publishing Project 'Premium.DataFactory' to Data
Factory 'premium-df'
25/07/2017 18:52:15- Value cannot be null.
Parameter name: value
Trying to figure up what could be wrong with the project it came up that the issues reside into the activity options "typeProperties" as shown above, specifically for scriptPath and scriptLinkedService attributes. The doc says:
scriptPath: Path to folder that contains the U-SQL script. Name of the file
is case-sensitive.
scriptLinkedService: Linked service that links the storage that contains the
script to the data factory
Publishing the project without them (using hard-coded script) it will complete successfully. The problem is that I can't either figure out what exactly put into them. I tried with several combinations paths. The only thing I know is that the script file must be referenced locally into the solution as a dependency.
The script linked service needs to be Blob Storage, not Data Lake Storage.
Ignore the publishing error, its misleading.
Have a linked service in your solution to an Azure Storage Account, referred to in the 'scriptLinkedService' attribute. Then in the 'scriptPath' attribute reference the blob container + path.
For example:
"typeProperties": {
"scriptPath": "datafactorysupportingfiles/CreateDimensions - Daily.usql",
"scriptLinkedService": "BlobStore",
"degreeOfParallelism": 2,
"priority": 7
},
Hope this helps.
Ps. Double check for case sensitivity on attribute names. It can also throw unhelpful errors.

output directory structure in assemble

I am creating a static site using grunt.js and assemble. I have a data.json file used for building pages using assemble:
{
"articles": [
{
"author": "Brian",
"headline": "A Generation on the Hook 1",
"body": "cars, and start businesses by means of debt",
"slug" : "n-hook1",
"publish_on": "2014-10-10T04:00:00+00:00",
"url": "http://example.com/2014/oct/08/n-hook1/",
},
{
"author": "Brian",
"headline": "A Generation on the Hook 2",
"body": "As millions go to college, buy homes,",
"slug" : "n-hook2",
"publish_on": "2014-10-12T04:00:00+00:00",
"url": "http://example.com/2014/oct/08/n-hook2/",
},
],
}
I would like the output to be created in the following directories like this: 2014/oct/08/n-hook1/index.html. How can I create the directories in assemble?
Is this even possible with assemble.io? If there is something better, let me know. I am new to the js world and would like some direction. I did see this question but this seems to involve placing the files in different directories. Maybe I have to write a helper? If so, I am not sure where to start.
I like assemble because pages that are generated a completely upt o the client side rendering, and I just present the json data. Not sure if there is something better.
The grunt-assemble-permalinks plugin was the solution, it does what I need.

How can I add IgnorePath for yuidoc

While generating document form yuidoc I want to ignore downloaded javascript libraries inside lib folder of my project. How can I place that into ignore list
I tried
"ignorePaths": [ "./lib" ],
"ignorePaths": [ "./lib/*.js" ],
"ignorePaths": [ "lib" ]
still it's compiles my javascript library files.
Instead, try using the exclude option as discussed here https://github.com/yui/yuidoc/issues/5
"exclude" : ["lib"]
I'm adding an answer with a little more detail since I ran into this problem yesterday and it could be helpful to someone else.
As #slolife mentioned, you should be using "exclude".
The value for "exclude" needs to be a String of comma separated directories (not Array). This can be done via your JSON config file as one of the "options" or as a command-line argument.
Single Directory Examples
JSON Config File
{
"name": "My Project",
"options": {
"exclude": "lib"
}
}
Command-line
yuidoc . -x "lib"
Multiple Directories Examples
NOTE: NO spaces between directories in the list
JSON Config File
{
"name": "My Project",
"options": {
"exclude": "lib,lib2"
}
}
Command-line
yuidoc . -x "lib","lib2"
Reference: http://yui.github.io/yuidoc/args/index.html

Resources