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: Tobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Alessandro Portale
2015-05-12 14:21:38 +02:00
parent caaf460cdf
commit 8ae18a9ca8
60 changed files with 333 additions and 1946 deletions

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,20 +0,0 @@
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
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,20 +0,0 @@
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
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,20 +0,0 @@
import QtQuick 2.3
import QtQuick.Window 2.2
Window {
visible: true
width: 360
height: 360
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,13 +0,0 @@
import QtQuick 2.4
import QtQuick.Window 2.2
Window {
visible: true
MainForm {
anchors.fill: parent
mouseArea.onClicked: {
Qt.quit();
}
}
}

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,28 +0,0 @@
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
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,28 +0,0 @@
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
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,28 +0,0 @@
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
}
}

View File

@@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,14 +0,0 @@
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)

View File

@@ -1,12 +0,0 @@
#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();
}

View File

@@ -1,7 +0,0 @@
<?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>

View File

@@ -1,4 +1,4 @@
import QtQuick 2.4
import QtQuick %{QtQuickVersion}
Rectangle {
property alias mouseArea: mouseArea

View File

@@ -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)

View File

@@ -1,6 +1,5 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([], ["QGui/QGuiApplication", "QQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);

View File

@@ -0,0 +1,27 @@
import QtQuick %{QtQuickVersion}
import QtQuick.Window %{QtQuickWindowVersion}
Window {
visible: true
@if %{QmlUISplit}
MainForm {
anchors.fill: parent
mouseArea.onClicked: {
Qt.quit();
}
}
@else
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
}
@endif
}

View File

@@ -1,6 +1,8 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
@if %{QmlUISplit}
<file>MainForm.ui.qml</file>
@endif
</qresource>
</RCC>

View File

@@ -0,0 +1,132 @@
{
"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'
}"
}
]
}
},
{
"name": "QmlUISplit",
"trDisplayName": "With ui.qml file",
"type": "CheckBox",
"data":
{
"checkedValue": true,
"uncheckedValue": false,
"checked": false
}
}
]
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"data": { "projectFilePath": "%{ProFileName}" }
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "app.pro",
"target": "%{ProFileName}",
"openAsProject": true
},
{
"source": "main.cpp",
"target": "%{MainCppFileName}"
},
{
"source": "main.qml",
"openInEditor": true
},
{
"source": "MainForm.ui.qml",
"condition": "%{QmlUISplit}"
},
{
"source": "qml.qrc"
},
{
"source": "../../../../shared/qrcdeployment.pri",
"target": "%{ProjectDirectory}/deployment.pri"
},
{
"source": "../git.ignore",
"target": "%{ProjectDirectory}/.gitignore",
"condition": "%{JS: !%{IsSubproject} && '%{VersionControl}' === 'G.Git'}"
}
]
}
]
}

View File

@@ -1,14 +1,13 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtQuick %{QtQuickVersion}
import QtQuick.Controls %{QtQuickControlsVersion}
import QtQuick.Layouts %{QtQuickLayoutsVersion}
Item {
width: 640
height: 480
property alias button3: button3
property alias button2: button2
property alias button1: button1
property alias button2: button2
RowLayout {
anchors.centerIn: parent
@@ -22,10 +21,5 @@ Item {
id: button2
text: qsTr("Press Me 2")
}
Button {
id: button3
text: qsTr("Press Me 3")
}
}
}

View File

@@ -2,7 +2,7 @@ TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp
SOURCES += %{MainCppFileName}
RESOURCES += qml.qrc
@@ -10,4 +10,4 @@ RESOURCES += qml.qrc
QML_IMPORT_PATH =
# Default rules for deployment.
include(../../shared/qrcdeployment.pri)
include(deployment.pri)

View File

@@ -1,6 +1,5 @@
#include <QApplication>
#include <QQmlApplicationEngine>
%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([], ["QWidgets/QApplication", "QQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);

View File

@@ -1,33 +1,34 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick %{QtQuickVersion}
import QtQuick.Controls %{QtQuickControlsVersion}
@if %{QmlUISplit}
import QtQuick.Dialogs %{QtQuickDialogsVersion}
@endif
ApplicationWindow {
title: qsTr("Hello World")
visible: true
width: 640
height: 480
visible: true
title: qsTr("Hello World")
menuBar: MenuBar {
Menu {
title: qsTr("&File")
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: messageDialog.show(qsTr("Open action triggered"));
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("E&xit")
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
}
@if %{QmlUISplit}
MainForm {
anchors.fill: parent
button1.onClicked: messageDialog.show(qsTr("Button 1 pressed"))
button2.onClicked: messageDialog.show(qsTr("Button 2 pressed"))
button3.onClicked: messageDialog.show(qsTr("Button 3 pressed"))
}
MessageDialog {
@@ -39,4 +40,10 @@ ApplicationWindow {
messageDialog.open();
}
}
@else
Label {
text: qsTr("Hello World")
anchors.centerIn: parent
}
@endif
}

View File

@@ -1,6 +1,8 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
@if %{QmlUISplit}
<file>MainForm.ui.qml</file>
@endif
</qresource>
</RCC>

View File

@@ -0,0 +1,140 @@
{
"version": 1,
"kind": "project",
"id": "U.QtQuickControlsApplication",
"category": "F.Application",
"trDescription": "Creates a deployable Qt Quick 2 application using Qt Quick Controls.",
"trDisplayName": "Qt Quick Controls Application",
"trDisplayCategory": "Application",
"icon": "../../../global/guiapplication.png",
"featuresRequired": [ "QtSupport.Wizards.FeatureQtQuick.Controls.1.3", "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": "QtQuickControlsVersion", "value": "%{JS: %{QtVersion}.qtQuickControlsVersion}" },
{ "key": "QtQuickDialogsVersion", "value": "%{JS: %{QtVersion}.qtQuickDialogsVersion}" },
{ "key": "QtQuickLayoutsVersion", "value": "%{JS: %{QtVersion}.qtQuickLayoutsVersion}" }
],
"pages":
[
{
"trDisplayName": "Project Location",
"trShortTitle": "Location",
"typeId": "Project",
"data": { "trDescription": "Creates a deployable Qt Quick 2 application using Qt Quick Controls." }
},
{
"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',
'qtQuickControlsVersion': '1.3',
'qtQuickDialogsVersion': '1.2',
'qtQuickLayoutsVersion': '1.2'
}"
},
{
"trKey": "Qt 5.4",
"value":
"{
'qtQuickVersion': '2.4',
'qtQuickControlsVersion': '1.2',
'qtQuickDialogsVersion': '1.2',
'qtQuickLayoutsVersion': '1.1'
}"
},
{
"trKey": "Qt 5.3",
"value":
"{
'qtQuickVersion': '2.3',
'qtQuickControlsVersion': '1.2',
'qtQuickDialogsVersion': '1.2',
'qtQuickLayoutsVersion': '1.1'
}"
}
]
}
},
{
"name": "QmlUISplit",
"trDisplayName": "With ui.qml file",
"type": "CheckBox",
"data":
{
"checkedValue": true,
"uncheckedValue": false,
"checked": true
}
}
]
},
{
"trDisplayName": "Kit Selection",
"trShortTitle": "Kits",
"typeId": "Kits",
"data": { "projectFilePath": "%{ProFileName}" }
},
{
"trDisplayName": "Project Management",
"trShortTitle": "Summary",
"typeId": "Summary"
}
],
"generators":
[
{
"typeId": "File",
"data":
[
{
"source": "app.pro",
"target": "%{ProFileName}",
"openAsProject": true
},
{
"source": "main.cpp",
"target": "%{MainCppFileName}"
},
{
"source": "main.qml",
"openInEditor": true
},
{
"source": "MainForm.ui.qml",
"condition": "%{QmlUISplit}"
},
{
"source": "qml.qrc"
},
{
"source": "../../../../shared/qrcdeployment.pri",
"target": "%{ProjectDirectory}/deployment.pri"
},
{
"source": "../git.ignore",
"target": "%{ProjectDirectory}/.gitignore",
"condition": "%{JS: !%{IsSubproject} && '%{VersionControl}' === 'G.Git'}"
}
]
}
]
}

View File

@@ -38,8 +38,6 @@
#include "qmakeprojectmanagerconstants.h"
#include "qmakebuildconfiguration.h"
#include "findqmakeprofiles.h"
#include "wizards/abstractmobileapp.h"
#include "wizards/qtquickapp.h"
#include <utils/algorithm.h>
#include <coreplugin/icontext.h>

View File

@@ -38,7 +38,6 @@
#include "qmakestep.h"
#include "qmakebuildconfiguration.h"
#include "addlibrarywizard.h"
#include "wizards/qtquickapp.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>

View File

@@ -31,11 +31,6 @@ HEADERS += \
wizards/modulespage.h \
wizards/filespage.h \
wizards/qtwizard.h \
wizards/qtquickapp.h \
wizards/qtquickappwizard.h \
wizards/qtquickappwizardpages.h \
wizards/abstractmobileapp.h \
wizards/abstractmobileappwizard.h \
wizards/subdirsprojectwizard.h \
wizards/subdirsprojectwizarddialog.h \
qmakeprojectmanagerconstants.h \
@@ -80,11 +75,6 @@ SOURCES += \
wizards/modulespage.cpp \
wizards/filespage.cpp \
wizards/qtwizard.cpp \
wizards/qtquickapp.cpp \
wizards/qtquickappwizard.cpp \
wizards/qtquickappwizardpages.cpp \
wizards/abstractmobileapp.cpp \
wizards/abstractmobileappwizard.cpp \
wizards/subdirsprojectwizard.cpp \
wizards/subdirsprojectwizarddialog.cpp \
makestep.cpp \

View File

@@ -85,8 +85,6 @@ QtcPlugin {
name: "Wizards"
prefix: "wizards/"
files: [
"abstractmobileapp.cpp", "abstractmobileapp.h",
"abstractmobileappwizard.cpp", "abstractmobileappwizard.h",
"consoleappwizard.cpp", "consoleappwizard.h",
"consoleappwizarddialog.cpp", "consoleappwizarddialog.h",
"filespage.cpp", "filespage.h",
@@ -97,9 +95,6 @@ QtcPlugin {
"librarywizarddialog.cpp", "librarywizarddialog.h",
"modulespage.cpp", "modulespage.h",
"qtprojectparameters.cpp", "qtprojectparameters.h",
"qtquickapp.cpp", "qtquickapp.h",
"qtquickappwizard.cpp", "qtquickappwizard.h",
"qtquickappwizardpages.cpp", "qtquickappwizardpages.h",
"qtwizard.cpp", "qtwizard.h",
"subdirsprojectwizard.cpp", "subdirsprojectwizard.h",
"subdirsprojectwizarddialog.cpp", "subdirsprojectwizarddialog.h",

View File

@@ -42,7 +42,6 @@
#include "wizards/librarywizard.h"
#include "wizards/testwizard.h"
#include "wizards/subdirsprojectwizard.h"
#include "wizards/qtquickappwizard.h"
#include "customwidgetwizard/customwidgetwizard.h"
#include "qmakeprojectmanagerconstants.h"
#include "qmakeproject.h"
@@ -110,7 +109,6 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
addAutoReleasedObject(new SubdirsProjectWizard);
addAutoReleasedObject(new GuiAppWizard);
addAutoReleasedObject(new ConsoleAppWizard);
addAutoReleasedObject(new QtQuickAppWizard);
addAutoReleasedObject(new LibraryWizard);
addAutoReleasedObject(new TestWizard);
addAutoReleasedObject(new CustomWidgetWizard);

View File

@@ -1,252 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "abstractmobileapp.h"
#include <QDir>
#include <QFile>
#include <QTextStream>
#ifndef CREATORLESSTEST
#include <coreplugin/icore.h>
#endif // CREATORLESSTEST
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
namespace QmakeProjectManager {
AbstractGeneratedFileInfo::AbstractGeneratedFileInfo()
: fileType(ExtendedFile)
, currentVersion(-1)
, version(-1)
, dataChecksum(0)
, statedChecksum(0)
{
}
const QString AbstractMobileApp::CFileComment(QLatin1String("//"));
const QString AbstractMobileApp::ProFileComment(QLatin1Char('#'));
AbstractMobileApp::AbstractMobileApp()
: QObject()
{
}
AbstractMobileApp::~AbstractMobileApp() { }
void AbstractMobileApp::setProjectName(const QString &name)
{
m_projectName = name;
}
QString AbstractMobileApp::projectName() const
{
return m_projectName;
}
void AbstractMobileApp::setProjectPath(const QString &path)
{
m_projectPath.setFile(path);
}
QString AbstractMobileApp::path(int fileType) const
{
const QString originsRootApp = originsRoot();
const QString mainCppFileName = QLatin1String("main.cpp");
switch (fileType) {
case MainCpp: return outputPathBase() + mainCppFileName;
case MainCppOrigin: return originsRootApp + mainCppFileName;
case AppPro: return outputPathBase() + m_projectName + QLatin1String(".pro");
case AppProOrigin: return originsRootApp + QLatin1String("app.pro");
case AppProPath: return outputPathBase();
default: return pathExtended(fileType);
}
return QString();
}
bool AbstractMobileApp::readTemplate(int fileType, QByteArray *data, QString *errorMessage) const
{
Utils::FileReader reader;
if (!reader.fetch(path(fileType), errorMessage))
return false;
*data = reader.data();
return true;
}
QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const
{
QByteArray mainCppInput;
if (!readTemplate(MainCppOrigin, &mainCppInput, errorMessage))
return QByteArray();
QTextStream in(&mainCppInput);
QByteArray mainCppContent;
QTextStream out(&mainCppContent, QIODevice::WriteOnly | QIODevice::Text);
QString line;
while (!(line = in.readLine()).isNull()) {
bool adaptLine = true;
if (line.contains(QLatin1String("// DELETE_LINE")))
continue; // omit this line in the output
else
adaptLine = adaptCurrentMainCppTemplateLine(line);
if (adaptLine) {
const int commentIndex = line.indexOf(QLatin1String(" //"));
if (commentIndex != -1)
line.truncate(commentIndex);
out << line << endl;
}
}
return mainCppContent;
}
QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const
{
const QChar comment = QLatin1Char('#');
QByteArray proFileInput;
if (!readTemplate(AppProOrigin, &proFileInput, errorMessage))
return QByteArray();
QTextStream in(&proFileInput);
QByteArray proFileContent;
QTextStream out(&proFileContent, QIODevice::WriteOnly | QIODevice::Text);
QString valueOnNextLine;
bool commentOutNextLine = false;
QString line;
while (!(line = in.readLine()).isNull()) {
if (line.contains(QLatin1String("# REMOVE_NEXT_LINE"))) {
in.readLine(); // eats the following line
} else {
handleCurrentProFileTemplateLine(line, in, out, commentOutNextLine);
}
// Remove all marker comments
if (line.trimmed().startsWith(comment)
&& line.trimmed().endsWith(comment))
continue;
if (!valueOnNextLine.isEmpty()) {
out << line.left(line.indexOf(QLatin1Char('=')) + 2)
<< QDir::fromNativeSeparators(valueOnNextLine) << endl;
valueOnNextLine.clear();
continue;
}
if (commentOutNextLine) {
out << comment << line << endl;
commentOutNextLine = false;
continue;
}
out << line << endl;
};
return proFileContent;
}
#ifndef CREATORLESSTEST
// The definition of QtQuickApp::templatesRoot() for
// CREATORLESSTEST is in tests/manual/appwizards/helpers.cpp
QString AbstractMobileApp::templatesRoot()
{
return Core::ICore::resourcePath()
+ QLatin1String("/templates/");
}
Core::GeneratedFile AbstractMobileApp::file(const QByteArray &data,
const QString &targetFile)
{
Core::GeneratedFile generatedFile(targetFile);
generatedFile.setBinary(true);
generatedFile.setBinaryContents(data);
return generatedFile;
}
Core::GeneratedFiles AbstractMobileApp::generateFiles(QString *errorMessage) const
{
Core::GeneratedFiles files;
files << file(generateFile(AbstractGeneratedFileInfo::AppProFile, errorMessage), path(AppPro));
files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute);
files << file(generateFile(AbstractGeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp));
return files;
}
#endif // CREATORLESSTEST
QString AbstractMobileApp::error() const
{
return m_error;
}
QByteArray AbstractMobileApp::readBlob(const QString &filePath,
QString *errorMsg) const
{
Utils::FileReader reader;
if (!reader.fetch(filePath, errorMsg))
return QByteArray();
return reader.data();
}
QByteArray AbstractMobileApp::generateFile(int fileType,
QString *errorMessage) const
{
QByteArray data;
QString comment = CFileComment;
switch (fileType) {
case AbstractGeneratedFileInfo::MainCppFile:
data = generateMainCpp(errorMessage);
break;
case AbstractGeneratedFileInfo::AppProFile:
data = generateProFile(errorMessage);
comment = ProFileComment;
break;
default:
data = generateFileExtended(fileType, errorMessage);
}
return data;
}
QString AbstractMobileApp::outputPathBase() const
{
QString path = m_projectPath.absoluteFilePath();
if (!path.endsWith(QLatin1Char('/')))
path.append(QLatin1Char('/'));
return path + projectName() + QLatin1Char('/');
}
void AbstractMobileApp::insertParameter(QString &line, const QString &parameter)
{
line.replace(QRegExp(QLatin1String("\\([^()]+\\)")),
QLatin1Char('(') + parameter + QLatin1Char(')'));
}
} // namespace QmakeProjectManager

View File

@@ -1,144 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ABSTRACTMOBILEAPP_H
#define ABSTRACTMOBILEAPP_H
#include "../qmakeprojectmanager_global.h"
#include <QFileInfo>
#include <QPair>
#ifndef CREATORLESSTEST
# include <coreplugin/generatedfile.h>
#endif // CREATORLESSTEST
QT_FORWARD_DECLARE_CLASS(QTextStream)
namespace QmakeProjectManager {
/// \internal
struct
#ifndef CREATORLESSTEST
QMAKEPROJECTMANAGER_EXPORT
#endif // CREATORLESSTEST
AbstractGeneratedFileInfo
{
enum FileType {
MainCppFile,
AppProFile,
DeploymentPriFile,
ExtendedFile
};
AbstractGeneratedFileInfo();
int fileType;
QFileInfo fileInfo;
int currentVersion; // Current version of the template file in Creator
int version; // The version in the file header
quint16 dataChecksum; // The calculated checksum
quint16 statedChecksum; // The checksum in the file header
};
typedef QPair<QString, QString> DeploymentFolder; // QPair<.source, .target>
/// \internal
class
#ifndef CREATORLESSTEST
QMAKEPROJECTMANAGER_EXPORT
#endif // CREATORLESSTEST
AbstractMobileApp : public QObject
{
Q_OBJECT
public:
enum FileType {
MainCpp,
MainCppOrigin,
AppPro,
AppProOrigin,
AppProPath,
ExtendedFile
};
virtual ~AbstractMobileApp();
void setProjectName(const QString &name);
QString projectName() const;
void setProjectPath(const QString &path);
QString path(int fileType) const;
QString error() const;
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
protected:
AbstractMobileApp();
virtual QByteArray generateProFile(QString *errorMessage) const;
static QString templatesRoot();
static void insertParameter(QString &line, const QString &parameter);
QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
bool readTemplate(int fileType, QByteArray *data, QString *errorMessage) const;
QByteArray generateFile(int fileType, QString *errorMessage) const;
QString outputPathBase() const;
#ifndef CREATORLESSTEST
static Core::GeneratedFile file(const QByteArray &data,
const QString &targetFile);
#endif // CREATORLESSTEST
static const QString CFileComment;
static const QString ProFileComment;
QString m_error;
private:
QByteArray generateMainCpp(QString *errorMessage) const;
virtual QByteArray generateFileExtended(int fileType, QString *errorMessage) const = 0;
virtual QString pathExtended(int fileType) const = 0;
virtual QString originsRoot() const = 0;
virtual bool adaptCurrentMainCppTemplateLine(QString &line) const = 0;
virtual void handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const = 0;
QString m_projectName;
QFileInfo m_projectPath;
};
} // namespace QmakeProjectManager
#endif // ABSTRACTMOBILEAPP_H

View File

@@ -1,150 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "abstractmobileappwizard.h"
#include "abstractmobileapp.h"
#include "../qmakeprojectimporter.h"
#include <extensionsystem/pluginmanager.h>
#include <qmakeprojectmanager/qmakeproject.h>
#include <qmakeprojectmanager/qmakeprojectmanager.h>
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/qtkitinformation.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/targetsetuppage.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/session.h>
#include <coreplugin/editormanager/editormanager.h>
using namespace Core;
using namespace ProjectExplorer;
using namespace QtSupport;
namespace QmakeProjectManager {
AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent,
const QtSupport::QtVersionNumber &minimumQtVersionNumber,
const QtSupport::QtVersionNumber &maximumQtVersionNumber,
const Core::WizardDialogParameters &parameters)
: ProjectExplorer::BaseProjectWizardDialog(parent, parameters)
, m_kitsPage(0)
, m_minimumQtVersionNumber(minimumQtVersionNumber)
, m_maximumQtVersionNumber(maximumQtVersionNumber)
{
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) {
m_kitsPage = new ProjectExplorer::TargetSetupPage;
updateKitsPage();
resize(900, 450);
}
}
void AbstractMobileAppWizardDialog::addKitsPage()
{
if (m_kitsPage)
addPage(m_kitsPage);
}
void AbstractMobileAppWizardDialog::updateKitsPage()
{
if (m_kitsPage) {
QString platform = selectedPlatform();
if (platform.isEmpty()) {
m_kitsPage->setPreferredKitMatcher(
QtKitInformation::qtVersionMatcher(FeatureSet(QtSupport::Constants::FEATURE_MOBILE)));
} else {
m_kitsPage->setPreferredKitMatcher(QtKitInformation::platformMatcher(platform));
}
m_kitsPage->setRequiredKitMatcher(QtKitInformation::qtVersionMatcher(requiredFeatures(),
m_minimumQtVersionNumber,
m_maximumQtVersionNumber));
}
}
ProjectExplorer::TargetSetupPage *AbstractMobileAppWizardDialog::kitsPage() const
{
return m_kitsPage;
}
Core::BaseFileWizard *AbstractMobileAppWizard::create(QWidget *parent, const Core::WizardDialogParameters &parameters) const
{
AbstractMobileAppWizardDialog * const wdlg = createInternal(parent, parameters);
wdlg->setProjectName(ProjectExplorer::BaseProjectWizardDialog::uniqueProjectName(parameters.defaultPath()));
connect(wdlg, SIGNAL(projectParametersChanged(QString,QString)),
SLOT(useProjectPath(QString,QString)));
wdlg->addExtensionPages(parameters.extensionPages());
return wdlg;
}
Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizard,
QString *errorMessage) const
{
prepareGenerateFiles(wizard, errorMessage);
return app()->generateFiles(errorMessage);
}
bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
const Core::GeneratedFiles &l, QString *errorMessage)
{
Q_UNUSED(w)
Q_UNUSED(l)
Q_UNUSED(errorMessage)
QmakeManager * const manager
= ExtensionSystem::PluginManager::getObject<QmakeManager>();
Q_ASSERT(manager);
QmakeProject project(manager, app()->path(AbstractMobileApp::AppPro));
bool success = true;
if (wizardDialog()->kitsPage()) {
success = wizardDialog()->kitsPage()->setupProject(&project);
if (success) {
project.saveSettings();
success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
}
}
if (success) {
const QString fileToOpen = fileToOpenPostGeneration();
if (!fileToOpen.isEmpty())
EditorManager::openEditor(fileToOpen);
}
return success;
}
void AbstractMobileAppWizard::useProjectPath(const QString &projectName,
const QString &projectPath)
{
app()->setProjectName(projectName);
app()->setProjectPath(projectPath);
if (wizardDialog()->kitsPage())
wizardDialog()->kitsPage()->setProjectPath(app()->path(AbstractMobileApp::AppPro));
projectPathChanged(app()->path(AbstractMobileApp::AppPro));
}
} // namespace QmakeProjectManager

View File

@@ -1,94 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef ABSTRACTMOBILEAPPWIZARD_H
#define ABSTRACTMOBILEAPPWIZARD_H
#include <qmakeprojectmanager/qmakeprojectmanager_global.h>
#include <projectexplorer/baseprojectwizarddialog.h>
#include <qtsupport/baseqtversion.h>
namespace ProjectExplorer { class TargetSetupPage; }
namespace QtSupport { class QtVersionNumber; }
namespace QmakeProjectManager {
class AbstractMobileApp;
/// \internal
class QMAKEPROJECTMANAGER_EXPORT AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
Q_OBJECT
protected:
explicit AbstractMobileAppWizardDialog(QWidget *parent, const QtSupport::QtVersionNumber &minimumQtVersionNumber,
const QtSupport::QtVersionNumber &maximumQtVersionNumber,
const Core::WizardDialogParameters &parameters);
public:
ProjectExplorer::TargetSetupPage *kitsPage() const;
protected:
void addKitsPage();
void updateKitsPage();
private:
ProjectExplorer::TargetSetupPage *m_kitsPage;
const QtSupport::QtVersionNumber m_minimumQtVersionNumber;
const QtSupport::QtVersionNumber m_maximumQtVersionNumber;
};
/// \internal
class QMAKEPROJECTMANAGER_EXPORT AbstractMobileAppWizard : public Core::BaseFileWizardFactory
{
Q_OBJECT
private slots:
void useProjectPath(const QString &projectName, const QString &projectPath);
protected:
virtual QString fileToOpenPostGeneration() const = 0;
private:
Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters &parameters) const;
Core::GeneratedFiles generateFiles(const QWizard *wizard, QString *errorMessage) const;
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage);
virtual AbstractMobileApp *app() const = 0;
virtual AbstractMobileAppWizardDialog *wizardDialog() const = 0;
virtual AbstractMobileAppWizardDialog *createInternal(QWidget *parent,
const Core::WizardDialogParameters &parameters) const = 0;
virtual void projectPathChanged(const QString &path) const = 0;
virtual void prepareGenerateFiles(const QWizard *wizard, QString *errorMessage) const = 0;
};
} // namespace QmakeProjectManager
#endif // ABSTRACTMOBILEAPPWIZARD_H

View File

@@ -1,343 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qtquickapp.h"
#include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QTextStream>
#ifndef CREATORLESSTEST
#include <coreplugin/icore.h>
#endif // CREATORLESSTEST
namespace QmakeProjectManager {
namespace Internal {
static QString sharedDirectory()
{
return Core::ICore::resourcePath() + QLatin1String("/templates/shared/");
}
static QString templateRootDirectory()
{
return Core::ICore::resourcePath() + QLatin1String("/templates/qtquick/");
}
static QStringList templateNames()
{
QStringList templateNameList;
const QDir templateRoot(templateRootDirectory());
foreach (const QFileInfo &subDirectory,
templateRoot.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
templateNameList.append(subDirectory.fileName());
return templateNameList;
}
// Return locale language attribute "de_UTF8" -> "de", empty string for "C"
static QString languageSetting()
{
#ifdef QT_CREATOR
QString name = Core::ICore::userInterfaceLanguage();
const int underScorePos = name.indexOf(QLatin1Char('_'));
if (underScorePos != -1)
name.truncate(underScorePos);
if (name.compare(QLatin1String("C"), Qt::CaseInsensitive) == 0)
name.clear();
return name;
#else
return QLocale::system().name();
#endif
}
static inline bool assignLanguageElementText(QXmlStreamReader &reader,
const QString &desiredLanguage,
QString *target)
{
const QStringRef elementLanguage = reader.attributes().value(QLatin1String("xml:lang"));
if (elementLanguage.isEmpty()) {
// Try to find a translation for our Wizards
*target = QCoreApplication::translate("QmakeProjectManager::QtQuickAppWizard",
reader.readElementText().toLatin1().constData());
return true;
}
if (elementLanguage == desiredLanguage) {
*target = reader.readElementText();
return true;
}
return false;
}
static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info)
{
const QString locale = languageSetting();
static const QLatin1String tag_template("template");
static const QLatin1String tag_displayName("displayname");
static const QLatin1String tag_description("description");
static const QLatin1String attribute_featuresRequired("featuresRequired");
static const QLatin1String attribute_openEditor("openeditor");
static const QLatin1String attribute_priority("priority");
static const QLatin1String attribute_qrcdeployment("qrcdeployment");
static const QLatin1String attribute_requiredPlugins("requiredPlugins");
while (!reader.atEnd() && !reader.hasError()) {
reader.readNext();
if (reader.tokenType() != QXmlStreamReader::StartElement)
continue;
if (reader.name() == tag_template) {
info->openFile = reader.attributes().value(attribute_openEditor).toString();
if (reader.attributes().hasAttribute(attribute_priority))
info->priority = reader.attributes().value(attribute_priority).toString();
if (reader.attributes().hasAttribute(attribute_featuresRequired))
info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString();
if (reader.attributes().hasAttribute(attribute_qrcdeployment))
info->qrcDeployment = reader.attributes().value(attribute_qrcdeployment).toString();
// This attribute is currently used in enterprise addons to filter out templates when the enterprise
// addon is not installed. This applies to the Boot To Qt addon for example.
if (reader.attributes().hasAttribute(attribute_requiredPlugins))
info->requiredPlugins = reader.attributes().value(attribute_requiredPlugins).toString()
.split(QLatin1Char(','), QString::SkipEmptyParts);
} else if (reader.name() == tag_displayName) {
if (!assignLanguageElementText(reader, locale, &info->displayName))
continue;
} else if (reader.name() == tag_description) {
if (!assignLanguageElementText(reader, locale, &info->description))
continue;
}
}
if (reader.hasError()) {
qWarning() << reader.errorString();
return false;
}
return true;
}
class TemplateInfoList
{
public:
TemplateInfoList()
{
QSet<QString> availablePlugins;
foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) {
if (s->state() == ExtensionSystem::PluginSpec::Running && !s->hasError())
availablePlugins += s->name();
}
QMultiMap<QString, TemplateInfo> multiMap;
foreach (const QString &templateName, templateNames()) {
const QString templatePath = templateRootDirectory() + templateName;
QFile xmlFile(templatePath + QLatin1String("/template.xml"));
if (!xmlFile.open(QIODevice::ReadOnly)) {
qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath()));
continue;
}
TemplateInfo info;
info.templateName = templateName;
info.templatePath = templatePath;
QXmlStreamReader reader(&xmlFile);
if (!parseTemplateXml(reader, &info))
continue;
bool ok = true;
foreach (const QString &neededPlugin, info.requiredPlugins) {
if (!availablePlugins.contains(neededPlugin)) {
ok = false;
break;
}
}
if (ok)
multiMap.insert(info.priority, info);
}
m_templateInfoList = multiMap.values();
}
QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; }
private:
QList<TemplateInfo> m_templateInfoList;
};
Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList)
QList<TemplateInfo> QtQuickApp::templateInfos()
{
return templateInfoList()->templateInfoList();
}
QtQuickApp::QtQuickApp()
: AbstractMobileApp()
{
}
void QtQuickApp::setTemplateInfo(const TemplateInfo &templateInfo)
{
m_templateInfo = templateInfo;
}
QString QtQuickApp::pathExtended(int fileType) const
{
const QString mainQmlFile = QLatin1String("main.qml");
const QString mainQrcFile = QLatin1String("qml.qrc");
const QString qrcDeploymentFile = QLatin1String("deployment.pri");
const QString pathBase = outputPathBase();
switch (fileType) {
case MainQml: return pathBase + mainQmlFile;
case MainQmlOrigin: return originsRoot() + mainQmlFile;
case MainQrc: return pathBase + mainQrcFile;
case MainQrcOrigin: return originsRoot() + mainQrcFile;
case QrcDeployment: return pathBase + qrcDeploymentFile;
case QrcDeploymentOrigin: return sharedDirectory() + qrcDeployment();
default: qFatal("QtQuickApp::pathExtended() needs more work");
}
return QString();
}
QString QtQuickApp::originsRoot() const
{
return m_templateInfo.templatePath + QLatin1Char('/');
}
bool QtQuickApp::adaptCurrentMainCppTemplateLine(QString &line) const
{
Q_UNUSED(line)
return true;
}
void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const
{
Q_UNUSED(commentOutNextLine)
if (line.contains(QLatin1String("# QML_IMPORT_PATH"))) {
QString nextLine = proFileTemplate.readLine(); // eats 'QML_IMPORT_PATH ='
if (!nextLine.startsWith(QLatin1String("QML_IMPORT_PATH =")))
return;
proFile << nextLine << endl;
}
}
#ifndef CREATORLESSTEST
static QFileInfoList allFilesRecursive(const QString &path)
{
const QDir currentDirectory(path);
QFileInfoList allFiles = currentDirectory.entryInfoList(QDir::Files);
foreach (const QFileInfo &subDirectory, currentDirectory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
allFiles.append(allFilesRecursive(subDirectory.absoluteFilePath()));
return allFiles;
}
Core::GeneratedFiles QtQuickApp::generateFiles(QString *errorMessage) const
{
Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage);
const QFileInfoList templateFiles = allFilesRecursive(originsRoot());
//Deploy additional .qml files
foreach (const QFileInfo &templateFile, templateFiles) {
QString targetFileName = templateFile.fileName();
if (templateFile.suffix() == QLatin1String("qml")
&& targetFileName != QLatin1String("main.qml"))
files.append(file(readBlob(templateFile.absoluteFilePath(), errorMessage), outputPathBase() + targetFileName));
}
if (!useExistingMainQml()) {
files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainQmlFile, errorMessage), path(MainQml)));
files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
}
if (QFileInfo::exists(path(MainQrcOrigin))) {
files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainQrcFile, errorMessage), path(MainQrc)));
}
if (!qrcDeployment().isEmpty()) {
files.append(file(generateFile(QtQuickAppGeneratedFileInfo::QrcDeploymentFile, errorMessage), path(QrcDeployment)));
}
return files;
}
#endif // CREATORLESSTEST
bool QtQuickApp::useExistingMainQml() const
{
return !m_mainQmlFile.filePath().isEmpty();
}
QString QtQuickApp::qrcDeployment() const
{
return m_templateInfo.qrcDeployment;
}
QByteArray QtQuickApp::generateProFile(QString *errorMessage) const
{
QByteArray proFileContent = AbstractMobileApp::generateProFile(errorMessage);
proFileContent.replace("../../shared/qrc", ""); // fix a path to qrcdeployment.pri
return proFileContent;
}
QByteArray QtQuickApp::generateFileExtended(int fileType, QString *errorMessage) const
{
QByteArray data;
switch (fileType) {
case QtQuickAppGeneratedFileInfo::MainQmlFile:
data = readBlob(path(MainQmlOrigin), errorMessage);
break;
case QtQuickAppGeneratedFileInfo::MainQrcFile:
data = readBlob(path(MainQrcOrigin), errorMessage);
break;
case QtQuickAppGeneratedFileInfo::QrcDeploymentFile:
data = readBlob(path(QrcDeploymentOrigin), errorMessage);
break;
default:
break;
}
return data;
}
} // namespace Internal
} // namespace QmakeProjectManager

View File

@@ -1,117 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QTQUICKAPP_H
#define QTQUICKAPP_H
#include "abstractmobileapp.h"
#include <QStringList>
namespace QmakeProjectManager {
namespace Internal {
struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo
{
enum ExtendedFileType {
MainQmlFile = ExtendedFile,
MainQrcFile,
AppViewerPriFile,
AppViewerCppFile,
AppViewerHFile,
QrcDeploymentFile
};
QtQuickAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
};
class TemplateInfo
{
public:
QString templateName;
QString templatePath;
QString displayName;
QString description;
QString openFile;
QString featuresRequired;
QString priority;
QString qrcDeployment;
QStringList requiredPlugins;
};
class QtQuickApp : public AbstractMobileApp
{
public:
enum ExtendedFileType {
MainQml = ExtendedFile,
MainQmlOrigin,
MainQrc,
MainQrcOrigin,
QrcDeployment,
QrcDeploymentOrigin
};
QtQuickApp();
static QList<TemplateInfo> templateInfos();
void setTemplateInfo(const TemplateInfo &templateInfo);
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
bool useExistingMainQml() const;
static const int StubVersion;
protected:
virtual QByteArray generateProFile(QString *errorMessage) const;
QString qrcDeployment() const;
private:
virtual QByteArray generateFileExtended(int fileType, QString *errorMessage) const;
virtual QString pathExtended(int fileType) const;
virtual QString originsRoot() const;
virtual bool adaptCurrentMainCppTemplateLine(QString &line) const;
virtual void handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &commentOutNextLine) const;
QFileInfo m_mainQmlFile;
TemplateInfo m_templateInfo;
};
} // namespace Internal
} // namespace QmakeProjectManager
#endif // QTQUICKAPP_H

View File

@@ -1,170 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qtquickappwizard.h"
#include "qtquickapp.h"
#include "qtquickappwizardpages.h"
#include "../qmakeprojectmanagerconstants.h"
#include <qtsupport/qtsupportconstants.h>
#include <qtsupport/baseqtversion.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/targetsetuppage.h>
#include <QIcon>
namespace QmakeProjectManager {
namespace Internal {
class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
{
Q_OBJECT
public:
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters &parameters);
TemplateInfo templateInfo() const;
protected:
void initializePage(int id);
private:
QtQuickComponentSetPage *m_componentSetPage;
};
QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
const Core::WizardDialogParameters &parameters)
: AbstractMobileAppWizardDialog(parent,
QtSupport::QtVersionNumber(4, 7, 0),
QtSupport::QtVersionNumber(5, INT_MAX, INT_MAX), parameters)
{
setWindowTitle(tr("New Qt Quick Application"));
setIntroDescription(tr("This wizard generates a Qt Quick Application project."));
m_componentSetPage = new Internal::QtQuickComponentSetPage;
addPage(m_componentSetPage);
addKitsPage();
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK));
}
void QtQuickAppWizardDialog::initializePage(int id)
{
if (page(id) == kitsPage()) {
QStringList stringList =
templateInfo().featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts);
Core::FeatureSet features;
foreach (const QString &string, stringList) {
Core::Feature feature(Core::Id::fromString(string.trimmed()));
features |= feature;
}
setRequiredFeatures(features);
updateKitsPage();
}
AbstractMobileAppWizardDialog::initializePage(id);
}
TemplateInfo QtQuickAppWizardDialog::templateInfo() const
{
return m_componentSetPage->templateInfo();
}
class QtQuickAppWizardPrivate
{
class QtQuickApp *app;
class QtQuickAppWizardDialog *wizardDialog;
friend class QtQuickAppWizard;
};
QtQuickAppWizard::QtQuickAppWizard()
: d(new QtQuickAppWizardPrivate)
{
setWizardKind(ProjectWizard);
setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP)));
setId(QLatin1String("D.QMLA Application"));
setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
setDisplayCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY));
setDisplayName(tr("Qt Quick Application"));
setDescription(tr("Creates a Qt Quick application project that can contain both QML and C++ code."));
setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK));
d->app = new QtQuickApp;
d->wizardDialog = 0;
}
QtQuickAppWizard::~QtQuickAppWizard()
{
delete d->app;
delete d;
}
AbstractMobileAppWizardDialog *QtQuickAppWizard::createInternal(QWidget *parent,
const Core::WizardDialogParameters &parameters) const
{
d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters);
return d->wizardDialog;
}
void QtQuickAppWizard::projectPathChanged(const QString &path) const
{
if (d->wizardDialog->kitsPage())
d->wizardDialog->kitsPage()->setProjectPath(path);
}
void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
QString *errorMessage) const
{
Q_UNUSED(errorMessage)
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
d->app->setTemplateInfo(wizard->templateInfo());
}
QString QtQuickAppWizard::fileToOpenPostGeneration() const
{
return d->app->path(QtQuickApp::MainQml);
}
AbstractMobileApp *QtQuickAppWizard::app() const
{
return d->app;
}
AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const
{
return d->wizardDialog;
}
} // namespace Internal
} // namespace QmakeProjectManager
#include "qtquickappwizard.moc"

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QTQUICKAPPWIZARD_H
#define QTQUICKAPPWIZARD_H
#include "abstractmobileappwizard.h"
namespace QmakeProjectManager {
namespace Internal {
class QtQuickAppWizard : public AbstractMobileAppWizard
{
Q_OBJECT
public:
QtQuickAppWizard();
~QtQuickAppWizard();
protected:
QString fileToOpenPostGeneration() const;
private:
AbstractMobileApp *app() const;
AbstractMobileAppWizardDialog *wizardDialog() const;
AbstractMobileAppWizardDialog *createInternal(QWidget *parent,
const Core::WizardDialogParameters &parameters) const;
void projectPathChanged(const QString &path) const;
void prepareGenerateFiles(const QWizard *wizard, QString *errorMessage) const;
class QtQuickAppWizardPrivate *d;
};
} // namespace Internal
} // namespace QmakeProjectManager
#endif // QTQUICKAPPWIZARD_H

View File

@@ -1,101 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "qtquickappwizardpages.h"
#include <utils/wizard.h>
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
namespace QmakeProjectManager {
namespace Internal {
class QtQuickComponentSetPagePrivate
{
public:
QComboBox *m_versionComboBox;
QLabel *m_descriptionLabel;
};
QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent)
: QWizardPage(parent)
, d(new QtQuickComponentSetPagePrivate)
{
setTitle(tr("Select Qt Quick Component Set"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QHBoxLayout *l = new QHBoxLayout();
QLabel *label = new QLabel(tr("Qt Quick component set:"), this);
d->m_versionComboBox = new QComboBox(this);
foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos())
d->m_versionComboBox->addItem(templateInfo.displayName);
l->addWidget(label);
l->addWidget(d->m_versionComboBox);
d->m_descriptionLabel = new QLabel(this);
d->m_descriptionLabel->setWordWrap(true);
d->m_descriptionLabel->setTextFormat(Qt::RichText);
connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateDescription(int)));
updateDescription(d->m_versionComboBox->currentIndex());
mainLayout->addLayout(l);
mainLayout->addWidget(d->m_descriptionLabel);
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Component Set"));
}
QtQuickComponentSetPage::~QtQuickComponentSetPage()
{
delete d;
}
TemplateInfo QtQuickComponentSetPage::templateInfo() const
{
if (QtQuickApp::templateInfos().isEmpty())
return TemplateInfo();
return QtQuickApp::templateInfos().at(d->m_versionComboBox->currentIndex());
}
void QtQuickComponentSetPage::updateDescription(int index)
{
if (QtQuickApp::templateInfos().isEmpty())
return;
const TemplateInfo templateInfo = QtQuickApp::templateInfos().at(index);
d->m_descriptionLabel->setText(templateInfo.description);
}
} // namespace Internal
} // namespace QmakeProjectManager

View File

@@ -1,60 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QTQUICKAPPWIZARDPAGES_H
#define QTQUICKAPPWIZARDPAGES_H
#include <QWizardPage>
#include "qtquickapp.h"
namespace QmakeProjectManager {
namespace Internal {
class QtQuickComponentSetPage : public QWizardPage
{
Q_OBJECT
public:
explicit QtQuickComponentSetPage(QWidget *parent = 0);
virtual ~QtQuickComponentSetPage();
TemplateInfo templateInfo() const;
private slots:
void updateDescription(int index);
private:
class QtQuickComponentSetPagePrivate *d;
};
} // namespace Internal
} // namespace QmakeProjectManager
#endif // QTQUICKAPPWIZARDPAGES_H