diff options
author | Jarek Kobus <jaroslaw.kobus@nokia.com> | 2014-01-29 15:43:04 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@digia.com> | 2014-01-31 13:24:23 +0100 |
commit | 848a725e3b3bd51394ddbd0a10be52a8ae0bdd25 (patch) | |
tree | 2134249c247f7af9f8d56e984ff9233a2304e2d4 /share/qtcreator/templates | |
parent | 0eea7ca90bbf1ee44e836ab8ab3b6aab41dc82a1 (diff) | |
download | qt-creator-848a725e3b3bd51394ddbd0a10be52a8ae0bdd25.tar.gz |
Use qrc files for qml files inside qtquick app templates
Remove unused application viewers
Task-number: QTCREATORBUG-11264
Change-Id: I3e24be9b58ef47cb2b2c2cce0361c08e71c93ee9
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'share/qtcreator/templates')
32 files changed, 80 insertions, 446 deletions
diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro b/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro index 1c990093fb..6b9f7aad3e 100644 --- a/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro +++ b/share/qtcreator/templates/qtquick/qtquick_1_1/app.pro @@ -1,7 +1,7 @@ # Add more folders to ship with the application, here # DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml +folder_01.source = qml +folder_01.target = DEPLOYMENTFOLDERS = folder_01 # DEPLOYMENTFOLDERS_END # diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/main.cpp b/share/qtcreator/templates/qtquick/qtquick_1_1/main.cpp index da0c307555..47d27cac01 100644 --- a/share/qtcreator/templates/qtquick/qtquick_1_1/main.cpp +++ b/share/qtcreator/templates/qtquick/qtquick_1_1/main.cpp @@ -8,7 +8,7 @@ int main(int argc, char *argv[]) QtQuick1ApplicationViewer viewer; viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH viewer.setOrientation(QtQuick1ApplicationViewer::ScreenOrientationAuto); // ORIENTATION - viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML + viewer.setMainQmlFile(QLatin1String("qml/main.qml")); // MAINQML viewer.showExpanded(); return app.exec(); diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_1_1/qml/main.qml index 460a22fc2c..460a22fc2c 100644 --- a/share/qtcreator/templates/qtquick/qtquick_1_1/qml/app/main.qml +++ b/share/qtcreator/templates/qtquick/qtquick_1_1/qml/main.qml diff --git a/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml b/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml index e9ab8b2956..43c7b37f4c 100644 --- a/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml +++ b/share/qtcreator/templates/qtquick/qtquick_1_1/template.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<template openeditor="main.qml" priority="F" +<template openeditor="main.qml" priority="E" featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.1.1" viewerdir="qtquick1applicationviewer" viewerclassname="QtQuick1ApplicationViewer" diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro deleted file mode 100644 index c9e32a3c26..0000000000 --- a/share/qtcreator/templates/qtquick/qtquick_2_0/app.pro +++ /dev/null @@ -1,22 +0,0 @@ -# Add more folders to ship with the application, here -# DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 -# DEPLOYMENTFOLDERS_END # - -# Additional import path used to resolve QML modules in Creator's code model -# QML_IMPORT_PATH # -QML_IMPORT_PATH = - -# The .cpp file which was generated for your project. Feel free to hack it. -SOURCES += main.cpp - -# Installation path -# target.path = - -# Please do not modify the following two lines. Required for deployment. -include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri) -# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # -include(../../shared/deployment.pri) -qtcAddDeployment() diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/main.cpp b/share/qtcreator/templates/qtquick/qtquick_2_0/main.cpp deleted file mode 100644 index fd46906328..0000000000 --- a/share/qtcreator/templates/qtquick/qtquick_2_0/main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include <QtGui/QGuiApplication> -#include "qtquick2applicationviewer.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - QtQuick2ApplicationViewer viewer; - viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML - viewer.showExpanded(); - - return app.exec(); -} diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_2_0/qml/app/main.qml deleted file mode 100644 index 897812a6cb..0000000000 --- a/share/qtcreator/templates/qtquick/qtquick_2_0/qml/app/main.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 360 - height: 360 - Text { - text: qsTr("Hello World") - anchors.centerIn: parent - } - MouseArea { - anchors.fill: parent - onClicked: { - Qt.quit(); - } - } -} diff --git a/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml deleted file mode 100644 index 2c29847412..0000000000 --- a/share/qtcreator/templates/qtquick/qtquick_2_0/template.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<template openeditor="main.qml" priority="E" - featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2" - viewerdir="qtquick2applicationviewer" - viewerclassname="QtQuick2ApplicationViewer" - stubversionminor="5"> - <displayname>Qt Quick 2.0</displayname> - <description>Creates a deployable Qt Quick 2 application using the QtQuick 2.0 import. Requires Qt 5.0 or newer.</description> -</template> diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro index c9e32a3c26..f89227f8b1 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro +++ b/share/qtcreator/templates/qtquick/qtquick_2_1/app.pro @@ -1,22 +1,12 @@ -# Add more folders to ship with the application, here -# DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 -# DEPLOYMENTFOLDERS_END # +TEMPLATE = app -# Additional import path used to resolve QML modules in Creator's code model -# QML_IMPORT_PATH # -QML_IMPORT_PATH = +QT += qml quick -# The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp -# Installation path -# target.path = +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +# QML_IMPORT_PATH # +QML_IMPORT_PATH = -# Please do not modify the following two lines. Required for deployment. -include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri) -# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # -include(../../shared/deployment.pri) -qtcAddDeployment() diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp b/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp index fd46906328..b2d3e09a71 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp +++ b/share/qtcreator/templates/qtquick/qtquick_2_1/main.cpp @@ -1,13 +1,12 @@ #include <QtGui/QGuiApplication> -#include "qtquick2applicationviewer.h" +#include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - QtQuick2ApplicationViewer viewer; - viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML - viewer.showExpanded(); + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); } diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/qml.qrc b/share/qtcreator/templates/qtquick/qtquick_2_1/qml.qrc new file mode 100644 index 0000000000..69145a822f --- /dev/null +++ b/share/qtcreator/templates/qtquick/qtquick_2_1/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_2_1/qml/main.qml index 20ec49e4ff..72ffa35722 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_1/qml/app/main.qml +++ b/share/qtcreator/templates/qtquick/qtquick_2_1/qml/main.qml @@ -1,12 +1,16 @@ import QtQuick 2.1 +import QtQuick.Window 2.1 -Rectangle { +Window { + visible: true width: 360 height: 360 + Text { text: qsTr("Hello World") anchors.centerIn: parent } + MouseArea { anchors.fill: parent onClicked: { diff --git a/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml index 4db5883e43..360de04d51 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml +++ b/share/qtcreator/templates/qtquick/qtquick_2_1/template.xml @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <template openeditor="main.qml" priority="C" featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2" - viewerdir="qtquick2applicationviewer" - viewerclassname="QtQuick2ApplicationViewer" stubversionminor="5"> <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> diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro b/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro index c9e32a3c26..f89227f8b1 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro +++ b/share/qtcreator/templates/qtquick/qtquick_2_2/app.pro @@ -1,22 +1,12 @@ -# Add more folders to ship with the application, here -# DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 -# DEPLOYMENTFOLDERS_END # +TEMPLATE = app -# Additional import path used to resolve QML modules in Creator's code model -# QML_IMPORT_PATH # -QML_IMPORT_PATH = +QT += qml quick -# The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp -# Installation path -# target.path = +RESOURCES += qml.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +# QML_IMPORT_PATH # +QML_IMPORT_PATH = -# Please do not modify the following two lines. Required for deployment. -include(../../shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri) -# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # -include(../../shared/deployment.pri) -qtcAddDeployment() diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp b/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp index fd46906328..b2d3e09a71 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp +++ b/share/qtcreator/templates/qtquick/qtquick_2_2/main.cpp @@ -1,13 +1,12 @@ #include <QtGui/QGuiApplication> -#include "qtquick2applicationviewer.h" +#include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - QtQuick2ApplicationViewer viewer; - viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML - viewer.showExpanded(); + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); } diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/qml.qrc b/share/qtcreator/templates/qtquick/qtquick_2_2/qml.qrc new file mode 100644 index 0000000000..69145a822f --- /dev/null +++ b/share/qtcreator/templates/qtquick/qtquick_2_2/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquick_2_2/qml/main.qml index 7f67d2c235..6298428461 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_2/qml/app/main.qml +++ b/share/qtcreator/templates/qtquick/qtquick_2_2/qml/main.qml @@ -1,12 +1,16 @@ import QtQuick 2.2 +import QtQuick.Window 2.1 -Rectangle { +Window { + visible: true width: 360 height: 360 + Text { text: qsTr("Hello World") anchors.centerIn: parent } + MouseArea { anchors.fill: parent onClicked: { diff --git a/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml b/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml index 9416267e46..df31c91d87 100644 --- a/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml +++ b/share/qtcreator/templates/qtquick/qtquick_2_2/template.xml @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <template openeditor="main.qml" priority="A" featuresRequired="QtSupport.Wizards.FeatureQtQuick, QtSupport.Wizards.FeatureQtQuick.2" - viewerdir="qtquick2applicationviewer" - viewerclassname="QtQuick2ApplicationViewer" stubversionminor="5"> <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> diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro index 89f1ed5fe9..370208fcee 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/app.pro @@ -1,22 +1,10 @@ -# Add more folders to ship with the application, here -# DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 -# DEPLOYMENTFOLDERS_END # +TEMPLATE = app -# Additional import path used to resolve QML modules in Creator's code model -# QML_IMPORT_PATH # -QML_IMPORT_PATH = +QT += qml quick widgets -# The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp -# Installation path -# target.path = +RESOURCES += qml.qrc -# Please do not modify the following two lines. Required for deployment. -include(../../shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri) -# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # -include(../../shared/deployment.pri) -qtcAddDeployment() +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/main.cpp b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/main.cpp index 18fd2076cf..6ed400dcef 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/main.cpp +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/main.cpp @@ -1,12 +1,12 @@ -#include "qtquick2controlsapplicationviewer.h" +#include <QtQml/QQmlApplicationEngine> +#include <QtWidgets/QApplication> int main(int argc, char *argv[]) { - Application app(argc, argv); + QApplication app(argc, argv); - QtQuick2ControlsApplicationViewer viewer; - viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML - viewer.show(); + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); } diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml.qrc b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml.qrc new file mode 100644 index 0000000000..69145a822f --- /dev/null +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml/main.qml index 4069d1e713..2e6b1dd3d0 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml/app/main.qml +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_0/qml/main.qml @@ -2,9 +2,10 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 ApplicationWindow { - title: qsTr("Hello World") + visible: true width: 640 height: 480 + title: qsTr("Hello World") menuBar: MenuBar { Menu { @@ -16,7 +17,7 @@ ApplicationWindow { } } - Button { + Text { text: qsTr("Hello World") anchors.centerIn: parent } diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro index 89f1ed5fe9..370208fcee 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/app.pro @@ -1,22 +1,10 @@ -# Add more folders to ship with the application, here -# DEPLOYMENTFOLDERS # -folder_01.source = qml/app -folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 -# DEPLOYMENTFOLDERS_END # +TEMPLATE = app -# Additional import path used to resolve QML modules in Creator's code model -# QML_IMPORT_PATH # -QML_IMPORT_PATH = +QT += qml quick widgets -# The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp -# Installation path -# target.path = +RESOURCES += qml.qrc -# Please do not modify the following two lines. Required for deployment. -include(../../shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri) -# REMOVE_NEXT_LINE (wizard will remove the include and append deployment.pri to qmlapplicationviewer.pri, instead) # -include(../../shared/deployment.pri) -qtcAddDeployment() +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp index 18fd2076cf..6ed400dcef 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/main.cpp @@ -1,12 +1,12 @@ -#include "qtquick2controlsapplicationviewer.h" +#include <QtQml/QQmlApplicationEngine> +#include <QtWidgets/QApplication> int main(int argc, char *argv[]) { - Application app(argc, argv); + QApplication app(argc, argv); - QtQuick2ControlsApplicationViewer viewer; - viewer.setMainQmlFile(QStringLiteral("qml/app/main.qml")); // MAINQML - viewer.show(); + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); return app.exec(); } diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml.qrc b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml.qrc new file mode 100644 index 0000000000..69145a822f --- /dev/null +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>qml/main.qml</file> + </qresource> +</RCC> diff --git a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/main.qml index b257de0b83..4187749b5f 100644 --- a/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/app/main.qml +++ b/share/qtcreator/templates/qtquick/qtquickcontrols_1_1/qml/main.qml @@ -2,9 +2,10 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 ApplicationWindow { - title: qsTr("Hello World") + visible: true width: 640 height: 480 + title: qsTr("Hello World") menuBar: MenuBar { Menu { @@ -16,7 +17,7 @@ ApplicationWindow { } } - Button { + Text { text: qsTr("Hello World") anchors.centerIn: parent } diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp deleted file mode 100644 index 2a62ca97b6..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#include "qtquick2applicationviewer.h" - -#include <QtCore/QCoreApplication> -#include <QtCore/QDir> -#include <QtQml/QQmlEngine> - -class QtQuick2ApplicationViewerPrivate -{ - QString mainQmlFile; - friend class QtQuick2ApplicationViewer; - static QString adjustPath(const QString &path); -}; - -QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) -{ -#if defined(Q_OS_IOS) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_MAC) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/../Resources/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_BLACKBERRY) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("app/native/%1").arg(path); -#elif !defined(Q_OS_ANDROID) - QString pathInInstallDir = - QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; - pathInInstallDir = - QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#elif defined(Q_OS_ANDROID_NO_SDK) - return QLatin1String("/data/user/qt/") + path; -#endif - return path; -} - -QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent) - : QQuickView(parent) - , d(new QtQuick2ApplicationViewerPrivate()) -{ - connect(engine(), SIGNAL(quit()), SLOT(close())); - setResizeMode(QQuickView::SizeRootObjectToView); -} - -QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() -{ - delete d; -} - -void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) - setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); -#else - setSource(QUrl::fromLocalFile(d->mainQmlFile)); -#endif -} - -void QtQuick2ApplicationViewer::addImportPath(const QString &path) -{ - engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); -} - -void QtQuick2ApplicationViewer::showExpanded() -{ -#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX) - showFullScreen(); -#else - show(); -#endif -} diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h deleted file mode 100644 index 6eee3c89b9..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ApplicationViewer is a convenience class containing mobile device specific - code such as screen orientation handling. Also QML paths and debugging are - handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ - -#ifndef QTQUICK2APPLICATIONVIEWER_H -#define QTQUICK2APPLICATIONVIEWER_H - -#include <QtQuick/QQuickView> - -class QtQuick2ApplicationViewer : public QQuickView -{ - Q_OBJECT - -public: - explicit QtQuick2ApplicationViewer(QWindow *parent = 0); - virtual ~QtQuick2ApplicationViewer(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - - void showExpanded(); - -private: - class QtQuick2ApplicationViewerPrivate *d; -}; - -#endif // QTQUICK2APPLICATIONVIEWER_H diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri deleted file mode 100644 index 5123a2567e..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2applicationviewer/qtquick2applicationviewer.pri +++ /dev/null @@ -1,11 +0,0 @@ -# This file was generated by the Qt Quick 2 Application wizard of Qt Creator. -# The code below adds the QtQuick2ApplicationViewer to the project and handles -# the activation of QML debugging. -# It is recommended not to modify this file, since newer versions of Qt Creator -# may offer an updated version of it. - -QT += qml quick - -SOURCES += $$PWD/qtquick2applicationviewer.cpp -HEADERS += $$PWD/qtquick2applicationviewer.h -INCLUDEPATH += $$PWD diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp deleted file mode 100644 index bbce9d70bf..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ControlsApplicationViewer is a convenience class. - QML paths are handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ -#include "qtquick2controlsapplicationviewer.h" - -#include <QCoreApplication> -#include <QDir> -#include <QQmlComponent> -#include <QQmlEngine> -#include <QQuickView> - -class QtQuick2ApplicationViewerPrivate -{ - QString mainQmlFile; - QQmlEngine engine; - QQuickWindow *window; - - QtQuick2ApplicationViewerPrivate() : window(0) - {} - - ~QtQuick2ApplicationViewerPrivate() - { - delete window; - } - - static QString adjustPath(const QString &path); - - friend class QtQuick2ControlsApplicationViewer; -}; - -QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) -{ -#if defined(Q_OS_IOS) - if (!QDir::isAbsolutePath(path)) - return QString::fromLatin1("%1/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_MAC) - if (!QDir::isAbsolutePath(path)) - return QStringLiteral("%1/../Resources/%2") - .arg(QCoreApplication::applicationDirPath(), path); -#elif defined(Q_OS_BLACKBERRY) - if (!QDir::isAbsolutePath(path)) - return QStringLiteral("app/native/%1").arg(path); -#elif !defined(Q_OS_ANDROID) - QString pathInInstallDir = - QStringLiteral("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; - pathInInstallDir = - QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(), path); - if (QFileInfo(pathInInstallDir).exists()) - return pathInInstallDir; -#endif - return path; -} - -QtQuick2ControlsApplicationViewer::QtQuick2ControlsApplicationViewer() - : d(new QtQuick2ApplicationViewerPrivate()) -{ - -} - -QtQuick2ControlsApplicationViewer::~QtQuick2ControlsApplicationViewer() -{ - delete d; -} - -void QtQuick2ControlsApplicationViewer::setMainQmlFile(const QString &file) -{ - d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file); - - QQmlComponent component(&d->engine); - - QObject::connect(&d->engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); - -#ifdef Q_OS_ANDROID - component.loadUrl(QUrl(QStringLiteral("assets:/")+d->mainQmlFile)); -#else - component.loadUrl(QUrl::fromLocalFile(d->mainQmlFile)); -#endif - - if (!component.isReady()) - qWarning("%s", qPrintable(component.errorString())); - - d->window = qobject_cast<QQuickWindow *>(component.create()); - if (!d->window) - qFatal("Error: Your root item has to be a Window."); - - d->engine.setIncubationController(d->window->incubationController()); -} - -void QtQuick2ControlsApplicationViewer::addImportPath(const QString &path) -{ - d->engine.addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path)); -} - -void QtQuick2ControlsApplicationViewer::show() -{ - if (d->window) - d->window->show(); -} diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h deleted file mode 100644 index 76c12b7720..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - This file was generated by the Qt Quick 2 Application wizard of Qt Creator. - QtQuick2ControlsApplicationViewer is a convenience class. - QML paths are handled here. - It is recommended not to modify this file, since newer versions of Qt Creator - may offer an updated version of it. -*/ -#ifndef QTQUICK2APPLICATIONVIEWER_H -#define QTQUICK2APPLICATIONVIEWER_H - -#ifndef QT_NO_WIDGETS -#include <QApplication> -#else -#include <QGuiApplication> -#endif - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_WIDGETS -#define Application QApplication -#else -#define Application QGuiApplication -#endif - -QT_END_NAMESPACE - -class QtQuick2ControlsApplicationViewer -{ -public: - explicit QtQuick2ControlsApplicationViewer(); - virtual ~QtQuick2ControlsApplicationViewer(); - - void setMainQmlFile(const QString &file); - void addImportPath(const QString &path); - void show(); - -private: - class QtQuick2ApplicationViewerPrivate *d; -}; - -#endif // QTQUICK2APPLICATIONVIEWER_H diff --git a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri b/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri deleted file mode 100644 index 32007f73fd..0000000000 --- a/share/qtcreator/templates/shared/qtquickapplicationviewer/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri +++ /dev/null @@ -1,11 +0,0 @@ -# This file was generated by the Qt Quick 2 Controls Application wizard of Qt Creator. -# The code below adds the QtQuick2ApplicationViewer to the project and handles -# the activation of QML debugging. -# It is recommended not to modify this file, since newer versions of Qt Creator -# may offer an updated version of it. - -QT += qml quick widgets - -SOURCES += $$PWD/qtquick2controlsapplicationviewer.cpp -HEADERS += $$PWD/qtquick2controlsapplicationviewer.h -INCLUDEPATH += $$PWD |