Fix compilation for QT_NO_FILEDIALOG
[profile/ivi/qtdeclarative.git] / tools / qmlscene / main.cpp
index 0d97ba1..4e6dd92 100644 (file)
@@ -137,15 +137,6 @@ void RenderStatistics::printTotalStats()
 }
 #endif
 
-class MyQQuickView : public QQuickView
-{
-public:
-    MyQQuickView() : QQuickView()
-    {
-        setResizeMode(QQuickView::SizeRootObjectToView);
-    }
-};
-
 struct Options
 {
     Options()
@@ -157,6 +148,7 @@ struct Options
         , versionDetection(true)
         , slowAnimations(false)
         , quitImmediately(false)
+        , resizeViewToRootItem(false)
     {
     }
 
@@ -170,6 +162,7 @@ struct Options
     bool versionDetection;
     bool slowAnimations;
     bool quitImmediately;
+    bool resizeViewToRootItem;
 };
 
 #if defined(QMLSCENE_BUNDLE)
@@ -298,7 +291,7 @@ static bool checkVersion(const QUrl &url)
 
 static void displayFileDialog(Options *options)
 {
-#ifdef QT_WIDGETS_LIB
+#if defined(QT_WIDGETS_LIB) && !defined(QT_NO_FILEDIALOG)
     QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)");
     if (!fileName.isEmpty()) {
         QFileInfo fi(fileName);
@@ -349,6 +342,7 @@ static void usage()
     qWarning("  --no-multisample .......................... Disable multisampling (anti-aliasing)");
     qWarning("  --no-version-detection .................... Do not try to detect the version of the .qml file");
     qWarning("  --slow-animations ......................... Run all animations in slow motion");
+    qWarning("  --resize-to-root .......................... Resize the window to the size of the root item");
     qWarning("  --quit .................................... Quit immediately after starting");
     qWarning("  -I <path> ................................. Add <path> to the list of import paths");
     qWarning("  -B <name> <file> .......................... Add a named bundle");
@@ -380,6 +374,8 @@ int main(int argc, char ** argv)
                 options.slowAnimations = true;
             else if (lowerArgument == QLatin1String("--quit"))
                 options.quitImmediately = true;
+            else if (lowerArgument == QLatin1String("--resize-to-root"))
+                options.resizeViewToRootItem = true;
             else if (lowerArgument == QLatin1String("-i") && i + 1 < argc)
                 imports.append(QString::fromLatin1(argv[++i]));
             else if (lowerArgument == QLatin1String("-b") && i + 2 < argc) {
@@ -419,7 +415,7 @@ int main(int argc, char ** argv)
 
     if (!options.file.isEmpty()) {
         if (!options.versionDetection || checkVersion(options.file)) {
-            QQuickView *qxView = new MyQQuickView();
+            QQuickView *qxView = new QQuickView();
             engine = qxView->engine();
             for (int i = 0; i < imports.size(); ++i)
                 engine->addImportPath(imports.at(i));
@@ -434,6 +430,11 @@ int main(int argc, char ** argv)
 
             QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
 
+            if (options.resizeViewToRootItem)
+                qxView->setResizeMode(QQuickView::SizeViewToRootObject);
+            else
+                qxView->setResizeMode(QQuickView::SizeRootObjectToView);
+
             window->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
             if (options.fullscreen)
                 window->showFullScreen();