qmlscene: add --transparent argument
authorGirish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Thu, 14 Jun 2012 00:28:00 +0000 (17:28 -0700)
committerQt by Nokia <qt-info@nokia.com>
Tue, 19 Jun 2012 13:32:14 +0000 (15:32 +0200)
The option makes qmlscene request a format with alpha for the QQuickView.

Change-Id: I6490e606dd0af534147de95783f3a2ddfa8c52c8
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>

tools/qmlscene/main.cpp

index 06b3c37..54713fc 100644 (file)
@@ -144,6 +144,7 @@ struct Options
         , originalQmlRaster(false)
         , maximized(false)
         , fullscreen(false)
+        , transparent(false)
         , clip(false)
         , versionDetection(true)
         , slowAnimations(false)
@@ -157,6 +158,7 @@ struct Options
     bool originalQmlRaster;
     bool maximized;
     bool fullscreen;
+    bool transparent;
     bool scenegraphOnGraphicsview;
     bool clip;
     bool versionDetection;
@@ -336,6 +338,7 @@ static void usage()
     qWarning(" options:");
     qWarning("  --maximized ............................... run maximized");
     qWarning("  --fullscreen .............................. run fullscreen");
+    qWarning("  --transparent ............................. Make the window transparent");
     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");
@@ -363,6 +366,8 @@ int main(int argc, char ** argv)
                 options.maximized = true;
             else if (lowerArgument == QLatin1String("--fullscreen"))
                 options.fullscreen = true;
+            else if (lowerArgument == QLatin1String("--transparent"))
+                options.transparent = true;
             else if (lowerArgument == QLatin1String("--clip"))
                 options.clip = true;
             else if (lowerArgument == QLatin1String("--no-version-detection"))
@@ -432,6 +437,15 @@ int main(int argc, char ** argv)
             else
                 qxView->setResizeMode(QQuickView::SizeRootObjectToView);
 
+            if (options.transparent) {
+                QSurfaceFormat surfaceFormat;
+                surfaceFormat.setAlphaBufferSize(8);
+                qxView->setFormat(surfaceFormat);
+                qxView->setClearBeforeRendering(true);
+                qxView->setClearColor(QColor(Qt::transparent));
+                qxView->setWindowFlags(Qt::FramelessWindowHint);
+            }
+
             window->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
             if (options.fullscreen)
                 window->showFullScreen();