Commit 8ae18a9c authored by Alessandro Portale's avatar Alessandro Portale

ProjectManager: Qt Quick application templates via json wizard

Using the new .json wizard engine allows us to get rid of much old
custom wizard logic. As additional benefit for the end user of
Qt Creator, the .qml.ui split is now optional.

Change-Id: I4b5ebcc35a585fad6ebc2e994711ca23e3300717
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent caaf460c
TEMPLATE = app
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
# QML_IMPORT_PATH #
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
import QtQuick 2.1
import QtQuick.Window 2.0
Window {
visible: true
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="BY"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.2.1"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick 2.1</displayname>
<description>Creates a deployable Qt Quick 2 application using the QtQuick 2.1 import. Requires Qt 5.1 or newer.</description>
</template>
TEMPLATE = app
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
# QML_IMPORT_PATH #
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
import QtQuick 2.2
import QtQuick.Window 2.1
Window {
visible: true
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="BX"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.2.2"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick 2.2</displayname>
<description>Creates a deployable Qt Quick 2 application using the QtQuick 2.2 import. Requires Qt 5.2 or newer.</description>
</template>
TEMPLATE = app
QT += qml quick
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
# QML_IMPORT_PATH #
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="BW"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.2.3"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick 2.3</displayname>
<description>Creates a deployable Qt Quick 2 application using the QtQuick 2.3 import. Requires Qt 5.3 or newer.</description>
</template>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
import QtQuick 2.4
import QtQuick.Window 2.2
Window {
visible: true
MainForm {
anchors.fill: parent
mouseArea.onClicked: {
Qt.quit();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="BV"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.2.4, QtSupport.Wizards.FeatureQtQuick.UiFiles"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick 2.4</displayname>
<description>Creates a deployable Qt Quick 2 application that contains a .ui.qml file using the QtQuick 2.4 import. Requires Qt 5.4 or newer.</description>
</template>
import QtQuick 2.1
import QtQuick.Controls 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
Label {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="AZ"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.Controls.1.0"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick Controls 1.0</displayname>
<description>Creates a deployable Qt Quick 2 application using Qt Quick Controls. Requires Qt 5.1 or newer.</description>
</template>
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
import QtQuick 2.2
import QtQuick.Controls 1.1
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
Label {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="AY"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.Controls.1.1"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick Controls 1.1</displayname>
<description>Creates a deployable Qt Quick 2 application using Qt Quick Controls. Requires Qt 5.2 or newer.</description>
</template>
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
import QtQuick 2.3
import QtQuick.Controls 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
Label {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="AX"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.Controls.1.2"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick Controls 1.2</displayname>
<description>Creates a deployable Qt Quick 2 application using Qt Quick Controls. Requires Qt 5.3 or newer.</description>
</template>
TEMPLATE = app
QT += qml quick widgets
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
<?xml version="1.0" encoding="UTF-8"?>
<template openeditor="main.qml" priority="AW"
featuresRequired="QtSupport.Wizards.FeatureQtQuick.Controls.1.3, QtSupport.Wizards.FeatureQtQuick.UiFiles"
qrcdeployment="qrcdeployment.pri">
<displayname>Qt Quick Controls 1.3</displayname>
<description>Creates a deployable Qt Quick 2 application that contains a .ui.qml file and uses Qt Quick Controls. This project requires that you have installed Qt Quick Controls for your Qt version. Requires Qt 5.4 or newer.</description>
</template>
......@@ -3,13 +3,12 @@ TEMPLATE = app
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
SOURCES += %{MainCppFileName}
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
# QML_IMPORT_PATH #
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
include(deployment.pri)
#include <QGuiApplication>
#include <QQmlApplicationEngine>
%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([], ["QGui/QGuiApplication", "QQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
......
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick %{QtQuickVersion}
import QtQuick.Window %{QtQuickWindowVersion}
Window {
visible: true
width: 360
height: 360
@if %{QmlUISplit}
MainForm {
anchors.fill: parent
mouseArea.onClicked: {
Qt.quit();
}
}
@else
MouseArea {
anchors.fill: parent
onClicked: {
......@@ -17,4 +23,5 @@ Window {
text: qsTr("Hello World")
anchors.centerIn: parent
}
@endif
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
@if %{QmlUISplit}
<file>MainForm.ui.qml</file>
@endif
</qresource>
</RCC>
{
"version": 1,
"kind": "project",
"id": "U.QtQuickApplication",
"category": "F.Application",
"trDescription": "Creates a deployable Qt Quick 2 application.",
"trDisplayName": "Qt Quick Application",
"trDisplayCategory": "Application",
"icon": "../../../global/guiapplication.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQtQuick.2.4", "Plugin.QmakeProjectManager", "QtSupport.Wizards.FeatureQt" ],
"options":
[
{ "key": "ProFileName", "value": "%{JS: Util.fileName('%{ProjectDirectory}/%{ProjectName}', 'pro')}" },
{ "key": "MainCppFileName", "value": "%{JS: 'main.' + Util.preferredSuffix('text/x-c++src')}" },
{ "key": "QtQuickVersion", "value": "%{JS: %{QtVersion}.qtQuickVersion}" },
{ "key": "QtQuickWindowVersion", "value": "%{JS: %{QtVersion}.qtQuickWindowVersion}" }
],
"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project",
"data": { "trDescription": "Creates a deployable Qt Quick 2 application." }
},
{
"trDisplayName": "Define Project Details",
"trShortTitle": "Details",
"typeId": "Fields",
"data":
[
{
"name": "QtVersion",
"trDisplayName": "Minimal required Qt version:",
"type": "ComboBox",
"data":
{
"items":
[
{
"trKey": "Qt 5.5",
"value":
"{
'qtQuickVersion': '2.5',
'qtQuickWindowVersion': '2.2'
}"
},
{
"trKey": "Qt 5.4",
"value":
"{
'qtQuickVersion': '2.4',
'qtQuickWindowVersion': '2.2'
}"
},
{
"trKey": "Qt 5.3",
"value":
"{
'qtQuickVersion': '2.3',
'qtQuickWindowVersion': '2.2'
}"
}
]
}
},