From db8dbe25e0528d5e845be5c5f1ca44ec0a923f14 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 24 Feb 2022 16:55:19 +0100 Subject: [PATCH] QmlDesigner: Add a wizard for a ui.qml .qml file pair Task-number: QDS-5963 Change-Id: I16ee8361779f11ca2f24f35877869f3e83279d10 Reviewed-by: Thomas Hartmann --- .../files/qtuiquickform/file.qml.tpl | 5 + .../files/qtuiquickform/fileForm.ui.qml.tpl | 33 +++++ .../files/qtuiquickform/file_ui.png | Bin 0 -> 1084 bytes .../files/qtuiquickform/file_ui@2.png | Bin 0 -> 1879 bytes .../files/qtuiquickform/wizard.json | 132 ++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file.qml.tpl create mode 100644 share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/fileForm.ui.qml.tpl create mode 100644 share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui.png create mode 100644 share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui@2.png create mode 100644 share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/wizard.json diff --git a/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file.qml.tpl new file mode 100644 index 00000000000..7bd94416c44 --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file.qml.tpl @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +%{FormClass} { + button.onClicked: console.log("Button Pressed") +} diff --git a/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/fileForm.ui.qml.tpl b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/fileForm.ui.qml.tpl new file mode 100644 index 00000000000..1fcbbe97566 --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/fileForm.ui.qml.tpl @@ -0,0 +1,33 @@ +/* +This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only. +It is supposed to be strictly declarative and only uses a subset of QML. If you edit +this file manually, you might introduce QML code that is not supported by Qt Design Studio. +Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files. +*/ + +import QtQuick 2.15 +@if %{UseQtQuickControls2} +import QtQuick.Controls 2.15 +@endif +@if %{UseImport} +import %{ApplicationImport} +@endif + +%{RootItem} { +@if %{UseImport} + width: Constants.width + height: Constants.height +@else + width: 1024 + height: 768 +@endif + + property alias button: button + + Button { + id: button + x: 64 + y: 64 + text: qsTr("Button") + } +} diff --git a/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui.png b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui.png new file mode 100644 index 0000000000000000000000000000000000000000..473a8430fe5642bbcd20f571c3815d8eb7e3fd66 GIT binary patch literal 1084 zcmeAS@N?(olHy`uVBq!ia0y~yU}$7uU`XI#28pCSbY);*YzXiPab;j&C@(Lc4+d}s zm`7!z91M^R1q&dohH#PH02hG>!nqJbN=ix~3^K^XganALn5d}e$jF$esD$|V174rA35=B_$?8q{2f(Q<9VC&z~O_5|WydGJpR3;NalU;NY;3 zknr&Eyu7@Ef`a0rqT=G>l9H0r($cch(z3F$^78V!y1MS}?!Lahi4!JFnlx$7oH=vn z&Yd@J-u(IV&%5eoGB7Y?l?3?(GcYnTF>`S7@(Tz`NGqu68W@>aSlW4c2ZTk(CnTk1 z6cm<}R#rDOHZ`}lwzYS3cK1%0GIjclnRAyeTe)iWx@|l595{6N$k_{*Z#;PN^x3=j zA3lBm{^RE_5cmxOfByXW^Y`!HfB*i?^_$bgz`(@l>EalYaqsQTo8gxoL>fM>*HDUb z4Y(s7z@fKeVUW2?m?_th*aJ%yn!1?GjNaX;zsr7firD$g^PbPT=DvUXOm%( z)}`zA^7fwXVhDGNb$qocP%NcqlS1+oR>{RWCnQoGmj{Z?F+bIG*)6i*k_NX@!z2a% z1fRESc>7Q5hlRa(`sc)%O$9}2zYWf9 zG8W!h#PaZQdc5kreS0fJrYTm~{&Iel_wwgzBbLYWRsZet(VeDq;%uG2!-g;KoKH5j zMtUxK(UgWvn?x16$h<9^pK=mPhK+^IV?^S^ID%BdArV9(Li%kbB+Aly|! zDTup3`Qi49oO2F<&_C6K3J$R*-x*A9iQHlGa4!}=;5WO8VS(1KKXR-V3Bd}P4Xf*q z$uh`>vF>J&S~gw&h*m?~>ZW3bH{32RDGIzBGS93^Si;tD%XY2$tnL4!#N@;TcfPBP zGd-Yq{%_gO4ZO8U(FS+J=9X{&H9IL*p=kNujcf^bul>E7 zUl+f7hxMxkQ}-4>`0cEJ_dm0G0h9U)frHCcW@*JvsIJoQocH9~jmX);A(I}6ykfY* zxPm!=J%j7q0-YTbg2Z%~1K1bvImj+hesP9*1&7{R_wWru4OR@L3?QZUjO?F<7Mk;X SjAUS7VDNPHb6Mw<&;$S}j|k@g literal 0 HcmV?d00001 diff --git a/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui@2.png b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/file_ui@2.png new file mode 100644 index 0000000000000000000000000000000000000000..9cf67e875bdc95b48100b8a1ed489e75749d9f94 GIT binary patch literal 1879 zcmeAS@N?(olHy`uVBq!ia0y~yU}R!oU^u|R%)r2K7?A#>quWColK(NYcuaQ6K9^Wh5M42Ue8gp0!&1qB5VS+HSHk3&Qt zBwQu3`4A~mNr+LUrKNC<>FMckHbgciCI-TQTNfN092y)P77`K`8X6uN8W9#25gr~H z9v&GH5fu>;9TgQF9UT)D6%!pD6B82~9UT`F6CWEJ9~YOHkdU01n39x~nw*@Lnwp-L zmY$xTk)EEJk&&61nU$HDot2f7ot=}Dlbe&1mz$fHmzSTPUyz?)P*6}SJ7L0vDU&BpojP^e)Tz^_PoFVk z#;jSh=FFKhckbMI^XAQ;Kc9i=)?o$)hPIL*zhDMNMkZz!Ha0GPacLPj1w~~QHFYg* zU3~)+QwvLL8%Jk1cTYdRfZ&kO(6FfJn1sZXjLh7E;?nYp>bi!;=8o>Z{{9IQCrzF@ zZTj@tbLK5rv}noF<;z#BUb|uArcK+n@7sUi=&|D`PMtY-<;I-{kDfex{`&3v4<9~$ z{POktkDtGO|Nism&)1i=W_1srdfJXj9Llr$ZzzQ|d_n!xdgHGqSO#et)V#egG@L#RRF z#qQIr>KuX$3NLowWmV@874R3(Q<#_VeEUL6ojD2g?uU@l?B^Q6ar#i7A*6sE#JO@G3e*_o>jjzm70`a9oc(G{KBt)nO{p|RanBO{4(Zain_lx zY`T)7#maTZoE=_AzsgWyiC=mDvD1h4psj)ecS2sx-y!g4`ITM{j=Hc{|91$y$iLEm zQQ(N1gSqLr~FK*jNxpXT|L)%?ca#Y z-}4PV{=WXi7^0X-XaYlTLV0Cv)a)dmzmBXtj#mD&AC>;iPy`u;WGXt7)z3gFzo{{Z zb5Ey!)bELPE=3&2W~-`R`)jo~ie($luR>>;tt93TzZom%g*08g$J*$xQ`#C{uQN3vp4&Ke&C+>~1=mdWTCjVj=3D0bT=Om^aqjWA zeZJT2=_aLMJN@YoWcwGKT{b5#I(+>crRfRI#rbLLPp!#1zM$uJ$kQUulKDMz=T1u# z(VllUV^{V;7WtIexvvd>UjBOWu7A_F z<`bOfnRI74@bijFENB(Zc`KxJA+fuJY45t?1rEPWqih=QUC?(}kg}Ie;X+lJ_Wabf zY40veuHc0{ zD|%m9f1kyl!+NNZg%qq!$Gr-)%vN@FDfo3ZJ-GfpdFpLJfev1TdPirkhn!xrB}kdY z;0H zg&dS;+&{ypj+|HQm>gL0e{(z#sQJ;t?Ds&w!AU@Y!AU@+!BIei!BIe`!C}LWrObW; tY6|leLL6)ycQlkV*|4+-KT-a`Fu94}{9$XcGy?+zgQu&X%Q~loCICI9PY(b9 literal 0 HcmV?d00001 diff --git a/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/wizard.json b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/wizard.json new file mode 100644 index 00000000000..26c628f4b31 --- /dev/null +++ b/share/qtcreator/qmldesigner/studio_templates/files/qtuiquickform/wizard.json @@ -0,0 +1,132 @@ +{ + "version": 1, + "supportedProjectTypes": [ ], + "id": "Q.QtStudio.QmlUIForm.2", + "category": "B.StudioQtQuickFiles", + "trDescription": "Creates a UI file (.ui.qml) along with a matching QML file for implementation purposes.", + "trDisplayName": "QtQuick UI Form", + "trDisplayCategory": "Qt Quick Files", + "icon": "file_ui.png", + "platformIndependent": true, + + "enabled": "%{JS: value('Plugins').indexOf('QmlJSEditor') >= 0}", + "options" : [ + { "key": "QmlFile", "value": "%{Class}.%{JS: Util.preferredSuffix('text/x-qml')}" }, + { "key": "UiFile", "value": "%{FormClass}.%{JS: Util.preferredSuffix('application/x-qt.ui+qml')}" }, + { "key": "ApplicationImport", "value": "%{QmlProjectName} 1.0" }, + { "key": "RootItem", "value": "%{JS: %{RootItemCB}.RootItem}" }, + { "key": "UseImportDefault", "value": "%{JS: false}" }, + { "key": "UseQtQuickControls2Default", "value": "%{JS: true}" } + ], + "pages" : + [ + { + "trDisplayName": "Define Class", + "trShortTitle": "Details", + "typeId": "Fields", + "data" : + [ + { + "name": "Class", + "trDisplayName": "Component name:", + "mandatory": true, + "type": "LineEdit", + "data": { + "validator": "(?:[A-Z_][a-zA-Z_0-9]*|)", + "fixup": "%{JS: '%{INPUT}'.charAt(0).toUpperCase() + '%{INPUT}'.slice(1) }" + } + }, + { + "name": "Sp1", + "type": "Spacer", + "data": { "factor": 2 } + }, + { + "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": "%{Class}Form" + } + }, + { + "name": "TargetPath", + "type": "PathChooser", + "trDisplayName": "Path:", + "mandatory": true, + "data": + { + "kind": "directory", + "basePath": "%{InitialPath}", + "path": "%{InitialPath}" + } + }, + { + "name": "RootItemCB", + "trDisplayName": "Root Item:", + "type": "ComboBox", + "data": + { + "index": 0, + "items": + [ + { + "trKey": "Item", + "value": + "({ + 'RootItem': 'Item' + })" + }, + { + "trKey": "Rectangle", + "value": + "({ + 'RootItem': 'Rectangle' + })" + } + ] + } + }, + { + "name": "UseImport", + "trDisplayName": "Use Application Import", + "type": "CheckBox", + "data": + { + "checked": "%{UseImportDefault}" + } + }, + { + "name": "UseQtQuickControls2", + "trDisplayName": "Use QtQuick Controls 2", + "type": "CheckBox", + "data": + { + "checked": "%{UseQtQuickControls2Default}" + } + } + ] + } + ], + "generators" : + [ + { + "typeId": "File", + "data": [ + { + "source": "file.qml.tpl", + "target": "%{TargetPath}/%{QmlFile}", + "openInEditor": true + }, + { + "source": "fileForm.ui.qml.tpl", + "target": "%{TargetPath}/%{UiFile}", + "openInEditor": true + } + ] + } + ] +}