diff --git a/share/qtcreator/templates/qtquickapp/app.pro b/share/qtcreator/templates/qtquickapp/app.pro index e8d197665af13364eec6704944579655e904af12..fcbcc0b8aff75a7a832aff17c85114b38a67f16e 100644 --- a/share/qtcreator/templates/qtquickapp/app.pro +++ b/share/qtcreator/templates/qtquickapp/app.pro @@ -28,7 +28,11 @@ symbian:TARGET.CAPABILITY += NetworkServices # CONFIG += mobility # MOBILITY += -# Add dependency to symbian components +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +# HARMATTAN_BOOSTABLE # +# CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components # QTQUICKCOMPONENTS # # CONFIG += qtquickcomponents diff --git a/share/qtcreator/templates/qtquickapp/main.cpp b/share/qtcreator/templates/qtquickapp/main.cpp index dfb208a90c671da67a38fc40b923d33c7cb6867b..82347f65b2c6f177e0f568f6b0dc3c3a3c98d6ae 100644 --- a/share/qtcreator/templates/qtquickapp/main.cpp +++ b/share/qtcreator/templates/qtquickapp/main.cpp @@ -1,15 +1,15 @@ #include <QtGui/QApplication> #include "qmlapplicationviewer.h" -int main(int argc, char *argv[]) +Q_DECL_EXPORT int main(int argc, char *argv[]) { - QApplication app(argc, argv); + QScopedPointer<QApplication> app(createApplication(argc, argv)); + QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create()); - QmlApplicationViewer viewer; - viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH - viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION - viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML - viewer.showExpanded(); + viewer->addImportPath(QLatin1String("modules")); // ADDIMPORTPATH + viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION + viewer->setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML + viewer->showExpanded(); - return app.exec(); + return app->exec(); } diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp index d8500a28c46fd652a7dbfccd511d4b86c4a23d5d..c7ccf089beac9c2ba20f5dbd216cfd15a95a4514 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -9,15 +9,19 @@ #include "qmlapplicationviewer.h" -#include <QtCore/QCoreApplication> #include <QtCore/QDir> #include <QtCore/QFileInfo> #include <QtDeclarative/QDeclarativeComponent> #include <QtDeclarative/QDeclarativeEngine> #include <QtDeclarative/QDeclarativeContext> +#include <QtGui/QApplication> #include <qplatformdefs.h> // MEEGO_EDITION_HARMATTAN +#ifdef HARMATTAN_BOOSTER +#include <MDeclarativeCache> +#endif + #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #include <qt_private/qdeclarativedebughelper_p.h> @@ -45,9 +49,12 @@ static QmlJsDebuggingEnabler enableDebuggingHelper; class QmlApplicationViewerPrivate { + QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} + QString mainQmlFile; + QDeclarativeView *view; friend class QmlApplicationViewer; - static QString adjustPath(const QString &path); + QString adjustPath(const QString &path); }; QString QmlApplicationViewerPrivate::adjustPath(const QString &path) @@ -58,49 +65,78 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path) return QCoreApplication::applicationDirPath() + QLatin1String("/../Resources/") + path; #else - const QString pathInInstallDir = QCoreApplication::applicationDirPath() - + QLatin1String("/../") + path; - if (pathInInstallDir.contains(QLatin1String("opt")) - && pathInInstallDir.contains(QLatin1String("bin")) - && QFileInfo(pathInInstallDir).exists()) { + QString pathInInstallDir; +#ifdef HARMATTAN_BOOSTER + QString applicationDirPath = MDeclarativeCache::applicationDirPath(); +#else + QString applicationDirPath = QCoreApplication::applicationDirPath(); +#endif + pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); + + if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; - } #endif #endif return path; } -QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : - QDeclarativeView(parent), - m_d(new QmlApplicationViewerPrivate) +QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) + : QDeclarativeView(parent) + , d(new QmlApplicationViewerPrivate(this)) { connect(engine(), SIGNAL(quit()), SLOT(close())); setResizeMode(QDeclarativeView::SizeRootObjectToView); // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #if !defined(NO_JSDEBUGGER) - new QmlJSDebugger::JSDebuggerAgent(engine()); + new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); #endif #if !defined(NO_QMLOBSERVER) - new QmlJSDebugger::QDeclarativeViewObserver(this, this); + new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); +#endif +#endif +} + +QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) + : QDeclarativeView(parent) + , d(new QmlApplicationViewerPrivate(view)) +{ + connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in +#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 +#if !defined(NO_JSDEBUGGER) + new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); +#endif +#if !defined(NO_QMLOBSERVER) + new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); #endif #endif } QmlApplicationViewer::~QmlApplicationViewer() { - delete m_d; + delete d; +} + +QmlApplicationViewer *QmlApplicationViewer::create() +{ +#ifdef HARMATTAN_BOOSTER + return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); +#else + return new QmlApplicationViewer(); +#endif } void QmlApplicationViewer::setMainQmlFile(const QString &file) { - m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); - setSource(QUrl::fromLocalFile(m_d->mainQmlFile)); + d->mainQmlFile = d->adjustPath(file); + d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); } void QmlApplicationViewer::addImportPath(const QString &path) { - engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); + d->view->engine()->addImportPath(d->adjustPath(path)); } void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) @@ -149,10 +185,19 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) void QmlApplicationViewer::showExpanded() { #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - showFullScreen(); + d->view->showFullScreen(); #elif defined(Q_WS_MAEMO_5) - showMaximized(); + d->view->showMaximized(); +#else + d->view->show(); +#endif +} + +QApplication *createApplication(int &argc, char **argv) +{ +#ifdef HARMATTAN_BOOSTER + return MDeclarativeCache::qApplication(argc, argv); #else - show(); + return new QApplication(argc, argv); #endif } diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h index f4d7f40cd9d0b922e8022fb42c7f5c242d2d513c..d6cb43e10ed8db1bdd1f9d563650d8a7ea6b6350 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h @@ -26,6 +26,8 @@ public: explicit QmlApplicationViewer(QWidget *parent = 0); virtual ~QmlApplicationViewer(); + static QmlApplicationViewer *create(); + void setMainQmlFile(const QString &file); void addImportPath(const QString &path); @@ -35,7 +37,10 @@ public: void showExpanded(); private: - class QmlApplicationViewerPrivate *m_d; + explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); + class QmlApplicationViewerPrivate *d; }; +QApplication *createApplication(int &argc, char **argv); + #endif // QMLAPPLICATIONVIEWER_H diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.pri b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.pri index 6704a74c1b17ba0d043c5a26808672154e8cf6d9..a32c88d1ae91f3fc2c3125ef8da9c4fb853f517b 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.pri +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.pri @@ -16,3 +16,7 @@ INCLUDEPATH += $$PWD } else { DEFINES -= QMLJSDEBUGGER } + +contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { + DEFINES += HARMATTAN_BOOSTER +} diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp index 859d2da0901346aeb1fa20b4114a364d1e805993..72446e5bd67b19af600a1a7f809229f807cf2698 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp @@ -460,7 +460,7 @@ QString QtQuickApp::componentSetDir(ComponentSet componentSet) const } } -const int QtQuickApp::StubVersion = 15; +const int QtQuickApp::StubVersion = 16; } // namespace Internal } // namespace Qt4ProjectManager