qmlplugindump: Don't depend on qtquick1 and widgets.
authorChristian Kamm <christian.d.kamm@nokia.com>
Thu, 8 Dec 2011 08:52:01 +0000 (09:52 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 9 Dec 2011 10:47:09 +0000 (11:47 +0100)
Change-Id: I38baaf2d8d02c3f35d2dece9fc580c6e1fee872d
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
tools/qmlplugindump/main.cpp
tools/qmlplugindump/qmlplugindump.pro

index 79c6fce..54b3d94 100644 (file)
 #include <QtQuick/private/qquickevents_p_p.h>
 #include <QtQuick/private/qquickpincharea_p.h>
 
+#ifdef QT_WIDGETS_LIB
 #include <QtWidgets/QApplication>
+#endif
 
+#include <QtGui/QGuiApplication>
 #include <QtCore/QDir>
 #include <QtCore/QFileInfo>
 #include <QtCore/QSet>
@@ -607,7 +610,12 @@ int main(int argc, char *argv[])
     // Running this application would bring up the Qt Simulator (since it links QtGui), avoid that!
     QtSimulatorPrivate::SimulatorConnection::createStubInstance();
 #endif
+
+#ifdef QT_WIDGETS_LIB
     QApplication app(argc, argv);
+#else
+    QGuiApplication app(argc, argv);
+#endif
     const QStringList args = app.arguments();
     const QString appName = QFileInfo(app.applicationFilePath()).baseName();
     if (args.size() < 2) {
@@ -679,11 +687,26 @@ int main(int argc, char *argv[])
         engine.addImportPath(pluginImportPath);
     }
 
-    // load the QtQuick 1 & 2 plugins
+#ifdef QT_WIDGETS_LIB
+    // load the QtQuick 1 plugin
+    {
+        QByteArray code("import QtQuick 1.0\nQtObject {}");
+        QDeclarativeComponent c(&engine);
+        c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick1.qml"));
+        c.create();
+        if (!c.errors().isEmpty()) {
+            foreach (const QDeclarativeError &error, c.errors())
+                qWarning() << error.toString();
+            return EXIT_IMPORTERROR;
+        }
+    }
+#endif
+
+    // load the QtQuick 2 plugin
     {
-        QByteArray code("import QtQuick 1.0 as Q1\nimport QtQuick 2.0 as Q2\nQ2.QtObject {}");
+        QByteArray code("import QtQuick 2.0\nQtObject {}");
         QDeclarativeComponent c(&engine);
-        c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick.qml"));
+        c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick2.qml"));
         c.create();
         if (!c.errors().isEmpty()) {
             foreach (const QDeclarativeError &error, c.errors())
index a327bb6..25c0037 100644 (file)
@@ -2,7 +2,8 @@ TEMPLATE = app
 CONFIG += qt uic console
 DESTDIR = $$QT.declarative.bins
 
-QT += declarative declarative-private quick-private qtquick1 core-private widgets
+QT += declarative declarative-private quick-private core-private
+!isEmpty(QT.widgets.name):!isEmpty(QT.qtquick1.name): QT += widgets qtquick1
 
 TARGET = qmlplugindump