From b41237f01ef626381d8519f0703e54a4551f6c36 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 16 Nov 2011 13:09:03 +0100 Subject: Don't use MDeclarativeCache::qDeclarativeView() Commit d687d11240877f848f3d1c28e2ec70ed4ff555f4 unfortunately caused two severe regressions for MeeGo: QTCREATORBUG-6473: The application creates two QDeclarativeViews QTCREATORBUG-6490: QDView functions inaccessible. Existing apps broken This commit removes most of d687d11240877f848f3d1c28e2ec70ed4ff555f4 just leaving the boosted QApplication. Now, QmlApplicationViewer *is* again the QDeclarativeView. Change-Id: I219540353ff4dd1061221d6cbe69ce9a58500e91 Task-Id: QTCREATORBUG-6473 Task-Id: QTCREATORBUG-6490 Reviewed-by: Kai Koehne --- share/qtcreator/templates/qtquickapp/main.cpp | 10 ++--- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 46 ++++++---------------- .../qmlapplicationviewer/qmlapplicationviewer.h | 1 - .../qt4projectmanager/wizards/qtquickapp.cpp | 2 +- 4 files changed, 17 insertions(+), 42 deletions(-) diff --git a/share/qtcreator/templates/qtquickapp/main.cpp b/share/qtcreator/templates/qtquickapp/main.cpp index 82347f65b2..e906d7fa45 100644 --- a/share/qtcreator/templates/qtquickapp/main.cpp +++ b/share/qtcreator/templates/qtquickapp/main.cpp @@ -4,12 +4,12 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer app(createApplication(argc, argv)); - QScopedPointer viewer(QmlApplicationViewer::create()); - viewer->addImportPath(QLatin1String("modules")); // ADDIMPORTPATH - viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION - viewer->setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML - viewer->showExpanded(); + QmlApplicationViewer viewer; + viewer.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); // ORIENTATION + viewer.setMainQmlFile(QLatin1String("qml/app/main.qml")); // MAINQML + viewer.showExpanded(); return app->exec(); } diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp index 1bba248d97..448714fb52 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -11,10 +11,10 @@ #include #include +#include #include #include #include -#include #include // MEEGO_EDITION_HARMATTAN @@ -49,12 +49,9 @@ static QmlJsDebuggingEnabler enableDebuggingHelper; class QmlApplicationViewerPrivate { - QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} - QString mainQmlFile; - QDeclarativeView *view; friend class QmlApplicationViewer; - QString adjustPath(const QString &path); + static QString adjustPath(const QString &path); }; QString QmlApplicationViewerPrivate::adjustPath(const QString &path) @@ -76,34 +73,17 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path) QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : QDeclarativeView(parent) - , d(new QmlApplicationViewerPrivate(this)) + , d(new QmlApplicationViewerPrivate()) { 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(d->view->engine()); + new QmlJSDebugger::JSDebuggerAgent(engine()); #endif #if !defined(NO_QMLOBSERVER) - 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); + new QmlJSDebugger::QDeclarativeViewObserver(this, this); #endif #endif } @@ -115,22 +95,18 @@ QmlApplicationViewer::~QmlApplicationViewer() QmlApplicationViewer *QmlApplicationViewer::create() { -#ifdef HARMATTAN_BOOSTER - return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); -#else return new QmlApplicationViewer(); -#endif } void QmlApplicationViewer::setMainQmlFile(const QString &file) { - d->mainQmlFile = d->adjustPath(file); - d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); + d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); + setSource(QUrl::fromLocalFile(d->mainQmlFile)); } void QmlApplicationViewer::addImportPath(const QString &path) { - d->view->engine()->addImportPath(d->adjustPath(path)); + engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); } void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) @@ -179,11 +155,11 @@ void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) void QmlApplicationViewer::showExpanded() { #if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) - d->view->showFullScreen(); + showFullScreen(); #elif defined(Q_WS_MAEMO_5) - d->view->showMaximized(); + showMaximized(); #else - d->view->show(); + show(); #endif } diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h index d6cb43e10e..7f06207113 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.h @@ -37,7 +37,6 @@ public: void showExpanded(); private: - explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); class QmlApplicationViewerPrivate *d; }; diff --git a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp index a2cf2171fc..c9453a9073 100644 --- a/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp +++ b/src/plugins/qt4projectmanager/wizards/qtquickapp.cpp @@ -466,7 +466,7 @@ QString QtQuickApp::componentSetDir(ComponentSet componentSet) const } } -const int QtQuickApp::StubVersion = 18; +const int QtQuickApp::StubVersion = 19; } // namespace Internal } // namespace Qt4ProjectManager -- cgit v1.2.1