window and Screen example: new properties; splash screen
authorShawn Rutledge <shawn.rutledge@digia.com>
Fri, 8 Mar 2013 15:44:52 +0000 (16:44 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 28 May 2013 08:08:41 +0000 (10:08 +0200)
Demonstrates the new properties, how to make a splash screen, and
how to make a standalone app with an icon.  Combined the Screen info
into this example too.

Change-Id: I5b731539b39c55327f4e5b93860a880a35835896
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
20 files changed:
examples/quick/shared/images/qt-logo.png [new file with mode: 0644]
examples/quick/shared/shared.qrc
examples/quick/window/ScreenInfo.qml [moved from examples/quick/window/screen/screenInfo.qml with 95% similarity]
examples/quick/window/Splash.qml [moved from examples/quick/window/window/Window.qml with 72% similarity]
examples/quick/window/doc/images/qml-window-example.png [new file with mode: 0644]
examples/quick/window/doc/src/window.qdoc [new file with mode: 0644]
examples/quick/window/main.cpp [moved from examples/quick/window/window/window.cpp with 97% similarity]
examples/quick/window/resources/icon.icns [new file with mode: 0644]
examples/quick/window/resources/icon.ico [new file with mode: 0644]
examples/quick/window/resources/icon.svg [new file with mode: 0644]
examples/quick/window/resources/icon64.png [new file with mode: 0644]
examples/quick/window/resources/window.rc [new file with mode: 0644]
examples/quick/window/window.pro
examples/quick/window/window.qml [new file with mode: 0644]
examples/quick/window/window.qrc [new file with mode: 0644]
examples/quick/window/window/nogui.qml [deleted file]
examples/quick/window/window/standalone.qml [deleted file]
examples/quick/window/window/twowindows.qml [deleted file]
examples/quick/window/window/window.pro [deleted file]
examples/quick/window/window/window.qrc [deleted file]

diff --git a/examples/quick/shared/images/qt-logo.png b/examples/quick/shared/images/qt-logo.png
new file mode 100644 (file)
index 0000000..7d3e97e
Binary files /dev/null and b/examples/quick/shared/images/qt-logo.png differ
index 0b574ac..8912c17 100644 (file)
@@ -8,5 +8,7 @@
         <file>CheckBox.qml</file>
         <file>images/back.png</file>
         <file>images/next.png</file>
+        <file>images/qt-logo.png</file>
+        <file>images/checkmark.png</file>
     </qresource>
 </RCC>
similarity index 95%
rename from examples/quick/window/screen/screenInfo.qml
rename to examples/quick/window/ScreenInfo.qml
index 33fbc5d..e4abc8d 100644 (file)
@@ -44,7 +44,7 @@ import QtQuick.Window 2.1
 Item {
     id: root
     width: 400
-    height: 200
+    height: propertyGrid.implicitHeight + 16
 
     function orientationToString(o) {
         switch (o) {
@@ -63,10 +63,13 @@ Item {
     }
 
     Grid {
-        anchors.centerIn: parent
+        id: propertyGrid
         columns: 2
         spacing: 8
+        x: spacing
+        y: spacing
 
+        //! [screen]
         Text {
             text: "Screen \"" + Screen.name + "\":"
             font.bold: true
@@ -87,5 +90,6 @@ Item {
 
         Text { text: "primary orientation" }
         Text { text: orientationToString(Screen.primaryOrientation) + " (" + Screen.primaryOrientation + ")" }
+        //! [screen]
     }
 }
similarity index 72%
rename from examples/quick/window/window/Window.qml
rename to examples/quick/window/Splash.qml
index 0790093..092e6e6 100644 (file)
 ****************************************************************************/
 
 import QtQuick 2.0
-import QtQuick.Window 2.0
+import QtQuick.Window 2.1
 
+//! [splash-properties]
 Window {
-    width: 640
-    height: 480
-    visible: true //It's false by default
-    property Component self
-    Component.onCompleted: self = Qt.createComponent("Window.qml")
-    Text{
-        text: "Hello World!"
-        anchors.centerIn: parent
+    visible: true
+    width: splashImage.width
+    height: splashImage.height
+    color: "transparent"
+    title: "Splash Window"
+    modality: Qt.ApplicationModal
+    flags: Qt.SplashScreen
+    property int timeout: 2000
+//! [splash-properties]
+//! [screen-properties]
+    x: (Screen.width - splashImage.width) / 2
+    y: (Screen.height - splashImage.height) / 2
+//! [screen-properties]
+
+    Image {
+        id: splashImage
+        source: "../../shared/images/qt-logo.png"
+        MouseArea {
+            anchors.fill: parent
+            onClicked: Qt.quit()
+        }
     }
-    MouseArea{
-        anchors.fill: parent
-        onClicked: self.createObject();
+    //! [timer]
+    Timer {
+        interval: timeout; running: true; repeat: false
+        onTriggered: visible = false
     }
+    //! [timer]
 }
diff --git a/examples/quick/window/doc/images/qml-window-example.png b/examples/quick/window/doc/images/qml-window-example.png
new file mode 100644 (file)
index 0000000..72487b4
Binary files /dev/null and b/examples/quick/window/doc/images/qml-window-example.png differ
diff --git a/examples/quick/window/doc/src/window.qdoc b/examples/quick/window/doc/src/window.qdoc
new file mode 100644 (file)
index 0000000..07d2f11
--- /dev/null
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.  For licensing terms and
+** conditions see http://qt.digia.com/licensing.  For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.  Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+    \title Qt Quick Examples - Window and Screen
+    \example window
+    \brief This example demonstrates the Window and Screen types in QML
+    \image qml-window-example.png
+    \ingroup qtquickexamples
+
+    This example shows you how to create a Window in QML, how to control its
+    \l {QQuickWindow::visibility} {visibility}, how to present a splash screen
+    during application startup, and how to access the properties of the
+    \l Screen. It also demonstrates how to package QML into
+    \l {The Qt Resource System} {resources} and provide an
+    \l {Setting the Application Icon} {icon} to create a standalone QML desktop application.
+
+    A splash screen can be created with the \l {Qt::SplashScreen} {Qt.SplashScreen} flag,
+    and should be \l {Qt::ApplicationModal} {ApplicationModal} to prevent interaction
+    with the main window. If the splash window is also transparent, and showing a
+    partially transparent image, then it will look like a shaped window.
+    \snippet window/Splash.qml splash-properties
+
+    In this example a \l Timer will automatically dismiss the splash screen,
+    but in a real application you might want to connect to a signal from the
+    application logic to hide the splash when initialization is complete.
+    \snippet window/Splash.qml timer
+
+    The main window in this example is the control window, with some buttons
+    and checkboxes to control and provide feedback on the state of a secondary
+    window. Each checkbox has a binding to the property whose state it is
+    displaying, and also an onClicked handler to change the state. This is the
+    typical pattern to create a two-way binding while avoiding binding loops.
+    \snippet window/window.qml windowedCheckbox
+
+    The \l Screen has several properties which are generally useful to applications
+    which need to rotate some content when the screen orientation changes, to position
+    windows on the screen or to convert real units to logical pixel units.  ScreenInfo.qml
+    (which is displayed inline in window.qml, or can be run by itself with qmlscene)
+    simply displays the property values, while the splash screen uses them to
+    center the window on the screen.
+    \snippet window/Splash.qml screen-properties
+
+    If a Window is nested inside an \l Item or another Window, the inner window
+    becomes "transient for" the outer one (see \l Window for more explanation).
+    But if you want to create multiple top-level windows as unrelated peers, you
+    can create them inside a non-visual \l QtObject root item, as this example does.
+*/
similarity index 97%
rename from examples/quick/window/window/window.cpp
rename to examples/quick/window/main.cpp
index 277effc..2223c60 100644 (file)
@@ -49,7 +49,7 @@ int main(int argc, char* argv[])
     QGuiApplication app(argc, argv);
     QQmlEngine engine;
     QQmlComponent component(&engine);
-    component.loadUrl(QUrl("qrc:///window/window/Window.qml"));
+    component.loadUrl(QUrl("qrc:///window/window.qml"));
     if ( component.isReady() )
         component.create();
     else
diff --git a/examples/quick/window/resources/icon.icns b/examples/quick/window/resources/icon.icns
new file mode 100644 (file)
index 0000000..88b4b24
Binary files /dev/null and b/examples/quick/window/resources/icon.icns differ
diff --git a/examples/quick/window/resources/icon.ico b/examples/quick/window/resources/icon.ico
new file mode 100644 (file)
index 0000000..52af30a
Binary files /dev/null and b/examples/quick/window/resources/icon.ico differ
diff --git a/examples/quick/window/resources/icon.svg b/examples/quick/window/resources/icon.svg
new file mode 100644 (file)
index 0000000..0b61532
--- /dev/null
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="128"
+   height="128"
+   id="svg2"
+   sodipodi:version="0.32"
+   inkscape:version="0.48.2 r9819"
+   version="1.0"
+   sodipodi:docname="icon.svg"
+   inkscape:export-filename="/Users/rutledge/dev/qt5-stable/qtdeclarative/examples/quick/window/window/icon80.png"
+   inkscape:export-xdpi="61.509998"
+   inkscape:export-ydpi="61.509998"
+   inkscape:output_extension="org.inkscape.output.svg.inkscape">
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient4009">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop4011" />
+      <stop
+         id="stop4019"
+         offset="0.875"
+         style="stop-color:#ffffff;stop-opacity:0.49803922;" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:0;"
+         offset="1"
+         id="stop4013" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 186.64798 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="559.62469 : 186.64798 : 1"
+       inkscape:persp3d-origin="279.81235 : 124.43199 : 1"
+       id="perspective4876" />
+    <inkscape:perspective
+       id="perspective2836"
+       inkscape:persp3d-origin="22 : 14.666667 : 1"
+       inkscape:vp_z="44 : 22 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 22 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <filter
+       inkscape:collect="always"
+       id="filter4063"
+       x="-0.195491"
+       width="1.390982"
+       y="-0.16235915"
+       height="1.3247183">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="3.3077485"
+         id="feGaussianBlur4065" />
+    </filter>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     gridtolerance="10"
+     guidetolerance="10"
+     objecttolerance="10000"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="2.9775825"
+     inkscape:cx="62.656189"
+     inkscape:cy="42.423381"
+     inkscape:document-units="px"
+     inkscape:current-layer="layer1"
+     inkscape:window-width="1280"
+     inkscape:window-height="744"
+     inkscape:window-x="2003"
+     inkscape:window-y="156"
+     showgrid="true"
+     borderlayer="true"
+     showguides="true"
+     inkscape:guide-bbox="true"
+     inkscape:snap-global="false"
+     inkscape:window-maximized="0">
+    <inkscape:grid
+       type="xygrid"
+       id="grid7194"
+       visible="true"
+       enabled="true"
+       spacingx="8px"
+       spacingy="8px" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-66.38047,-391.3222)">
+    <path
+       id="path7304"
+       d="M 95.556318,434.65407 L 165.25811,434.65407 L 165.25811,490.10429 L 95.556318,490.10429 L 95.556318,434.65407 z"
+       style="fill:#01afaf;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5.24121141000000000;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+    <path
+       style="fill:#a7c706;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 96.869177,465.30846 c 27.677903,3.04574 41.155393,12.11589 48.000003,24 l -48.000003,0 0,-24 z"
+       id="path7300"
+       sodipodi:nodetypes="cccc"
+       inkscape:connector-curvature="0" />
+    <path
+       sodipodi:nodetypes="cccc"
+       id="path7302"
+       d="M 165.46767,465.22201 C 137.78977,468.26775 124.31228,477.33791 117.46767,489.22201 L 165.46767,489.22201 L 165.46767,465.22201 z"
+       style="fill:#966406;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1" />
+    <path
+       style="fill:#80ffff;fill-rule:evenodd;stroke:#000000;stroke-width:5.24121141000000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;opacity:1;fill-opacity:1"
+       d="M 95.532809,434.35736 L 74.567964,420.38079 L 74.567964,497.25189 L 95.532809,490.26361 L 95.532809,434.35736 z"
+       id="path7270"
+       sodipodi:nodetypes="ccccc" />
+    <path
+       style="fill:#00ffff;fill-rule:evenodd;stroke:#000000;stroke-width:5.24121141;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="M 74.567964,455.3222 L 95.532809,462.31048"
+       id="path7272"
+       sodipodi:nodetypes="cc" />
+    <g
+       style="fill:#80ffff;fill-opacity:1"
+       id="g7278"
+       transform="matrix(-0.8735352,0,0,0.8735352,244.36615,64.570513)">
+      <path
+         style="fill:#80ffff;fill-rule:evenodd;stroke:#000000;stroke-width:6;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
+         d="M 24,32 L 0,16 L 0,104 L 24,96 L 24,32 z"
+         id="path7280"
+         transform="translate(66.38047,391.3222)" />
+      <path
+         style="fill:#80ffff;fill-rule:evenodd;stroke:#000000;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;fill-opacity:1"
+         d="M 0,56 L 24,64"
+         id="path7282"
+         transform="translate(66.38047,391.3222)"
+         sodipodi:nodetypes="cc" />
+    </g>
+    <path
+       style="fill:#ffffff;fill-opacity:1;filter:url(#filter4063)"
+       d="m 119.74679,437.94232 c -0.0487,0.003 -0.0932,0.0315 -0.14149,0.0354 -0.1659,0.0132 -0.33372,0.008 -0.49523,0.0354 -0.96156,0.0643 -1.9037,0.14607 -2.86523,0.21224 -2.94807,0.23566 -5.19987,2.66253 -5.19987,6.01345 l 0,39.51194 3.32508,3.07747 0,-0.0354 33.2155,-5.58898 c 2.28673,-0.39587 4.06792,-3.06727 4.06792,-5.97808 l 0,-32.18967 -30.5625,-5.023 c -0.45263,-0.0748 -0.91269,-0.0942 -1.34418,-0.0708 z"
+       id="path3987"
+       inkscape:connector-curvature="0" />
+    <g
+       id="g3"
+       transform="matrix(0.20572087,0,0,0.20572087,113.4162,440.80626)">
+      <path
+         sodipodi:nodetypes="cccccccc"
+         id="path5"
+         style="fill:#006225"
+         d="M 43.09,0.3586 C 40.94,0.0036 38.84,-0.0824 36.81,0.0776 31.968136,0.39505671 27.122677,0.73638425 22.28,1.0696 9.62,2.0816 0,12.4996 0,26.8896 l 0,169.7 14.19,13.2 28.87,-209.42 0.03,-0.011 z"
+         inkscape:connector-curvature="0" />
+      <path
+         id="path7"
+         style="fill:#80c342"
+         d="m 174.4,160 c 0,12.5 -7.75,24.07 -17.57,25.77 L 14.23,209.73 V 25.93 C 14.23,9.21 27.57,-2.27 43.12,0.3 l 131.3,21.52 v 138.2 z"
+         inkscape:connector-curvature="0" />
+      <path
+         id="path11"
+         style="fill:#006225"
+         d="m 154.9,80.96 -12.96,-0.598 0,0.278 6.945,0.32 6.016,0 z"
+         inkscape:connector-curvature="0" />
+      <path
+         id="path13"
+         style="fill:#006225"
+         d="m 144.6,135.6 c 0.66,0.328 1.43,0.476 2.351,0.476 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 h -6.015 c -1.821,0.832 -3.532,1.457 -5.176,1.848 z"
+         inkscape:connector-curvature="0" />
+      <path
+         d="m 91.15,132.4 c 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -4.34,0 -7.68,2.535 -10.01,7.625 -2.52,5.543 -3.793,17.04 -3.793,34.44 0,16.82 1.238,28.75 3.734,35.75 2.356,6.672 5.879,9.976 10.5,9.976 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 m 17.98,3.75 c -4.117,9.707 -10.39,16.06 -18.99,19 0.867,4.449 2.176,7.441 3.922,9.019 1.351,1.211 3.433,1.821 6.222,1.821 0.805,0 1.668,-0.055 2.59,-0.157 v 13.12 l -5.961,0.782 c -1.758,0.23 -3.426,0.343 -5.004,0.343 -5.218,0 -9.445,-1.265 -12.62,-3.824 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 1.629,0 3.309,0.102 5.043,0.305 11.95,1.375 20.62,7.016 26.26,16.79 5.535,9.562 8.254,23.27 8.254,41.26 0,16.48 -2,29.45 -6.043,39.02 z M 130.4,45.91 l 11.52,1.238 0,20.21 12.96,0.914 0,12.68 -12.96,-0.598 0,46.33 c 0,4.032 0.445,6.625 1.34,7.789 0.8,1.067 2.046,1.594 3.71,1.594 0.161,0 0.329,-0.004 0.497,-0.016 2.55,-0.148 5.32,-0.933 8.343,-2.308 v 11.65 c -5.136,2.258 -10.18,3.598 -15.12,4.02 -0.718,0.055 -1.41,0.086 -2.078,0.086 -4.48,0 -7.906,-1.301 -10.25,-3.934 -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.535 L 118.046,79.25 V 65.66 l 7.586,0.547 4.773,-20.3 z"
+         style="fill:#ffffff"
+         id="path17"
+         inkscape:connector-curvature="0" />
+      <path
+         id="path19"
+         style="fill:#006225"
+         d="m 100.3,166 c 0.809,0 1.672,-0.055 2.59,-0.157 H 98.054 C 98.73,165.949 99.507,166 100.3,166 z"
+         inkscape:connector-curvature="0" />
+      <path
+         d="m 84.85,63.98 c 2.336,5.997 3.484,16.92 3.484,32.81 0,17.7 -1.16,29.57 -3.512,35.62 -1.894,4.879 -4.527,7.902 -7.863,9.07 0.965,0.368 1.992,0.551 3.078,0.551 0.207,0 0.41,-0.008 0.621,-0.019 4.633,-0.293 8.121,-3.496 10.49,-9.602 2.351,-6.051 3.511,-17.91 3.511,-35.62 0,-15.89 -1.148,-26.82 -3.484,-32.81 -2.336,-6.027 -5.832,-9.281 -10.52,-9.691 -0.359,-0.031 -0.714,-0.051 -1.058,-0.051 -1.09,0 -2.117,0.16 -3.082,0.481 h -0.004 c 3.601,1.121 6.379,4.215 8.336,9.261 z m -2.344,114.3 c -0.113,-0.05 -0.227,-0.105 -0.336,-0.16 -0.012,-0.004 -0.023,-0.012 -0.035,-0.015 -0.102,-0.051 -0.207,-0.106 -0.309,-0.157 -0.019,-0.011 -0.039,-0.019 -0.058,-0.031 -0.09,-0.051 -0.184,-0.098 -0.278,-0.148 -0.027,-0.016 -0.054,-0.036 -0.086,-0.051 -0.082,-0.043 -0.164,-0.09 -0.242,-0.137 -0.039,-0.023 -0.078,-0.047 -0.113,-0.07 -0.07,-0.039 -0.145,-0.082 -0.215,-0.125 -0.047,-0.031 -0.094,-0.059 -0.14,-0.09 -0.059,-0.039 -0.118,-0.074 -0.176,-0.113 -0.059,-0.039 -0.114,-0.075 -0.168,-0.114 -0.051,-0.031 -0.102,-0.066 -0.149,-0.097 -0.066,-0.047 -0.132,-0.094 -0.195,-0.137 -0.039,-0.027 -0.078,-0.055 -0.113,-0.082 -0.078,-0.055 -0.153,-0.113 -0.231,-0.172 -0.023,-0.016 -0.05,-0.035 -0.078,-0.055 -0.098,-0.078 -0.199,-0.156 -0.297,-0.234 -4.207,-3.379 -7.308,-9.894 -9.297,-19.54 -9.136,-1.945 -16.26,-7.754 -21.19,-17.5 -5.004,-9.902 -7.551,-24.39 -7.551,-43.34 0,-20.43 3.484,-35.51 10.34,-45.07 5.789,-8.07 13.86,-12.04 24.02,-12.04 h -6.351 c -10.15,0.008 -18.22,3.977 -24,12.04 -6.855,9.563 -10.34,24.64 -10.34,45.07 0,18.95 2.547,33.44 7.551,43.34 4.934,9.75 12.05,15.56 21.19,17.5 1.989,9.641 5.09,16.16 9.297,19.54 3.176,2.559 7.403,3.824 12.62,3.824 0.098,0 0.199,0 0.297,-0.004 h 5.539 c -3.406,-0.05 -6.383,-0.66 -8.906,-1.828 L 82.498,178.28 z M 128.4,145.6 c -2.73,-3.051 -4.09,-7.949 -4.09,-14.67 V 79.57 l -6.226,-0.285 v -13.59 h -6.016 v 3.035 c 0.871,3.273 1.555,6.82 2.063,10.64 l 4.164,0.192 v 51.36 c 0,6.723 1.367,11.62 4.09,14.67 2.343,2.633 5.765,3.934 10.25,3.934 h 6.015 c -4.48,0 -7.906,-1.301 -10.25,-3.934 z m 2.043,-99.66 -6.016,0 -4.668,19.88 5.911,0.422 4.773,-20.3 z"
+         style="fill:#006225"
+         id="path21"
+         inkscape:connector-curvature="0" />
+    </g>
+    <path
+       style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:5.24121141;stroke-linecap:round;stroke-linejoin:round;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
+       d="M 96.506224,434.65407 L 166.20801,434.65407 L 166.20801,490.10429 L 96.506224,490.10429 L 96.506224,434.65407 z"
+       id="rect7265" />
+  </g>
+</svg>
diff --git a/examples/quick/window/resources/icon64.png b/examples/quick/window/resources/icon64.png
new file mode 100644 (file)
index 0000000..0fa3244
Binary files /dev/null and b/examples/quick/window/resources/icon64.png differ
diff --git a/examples/quick/window/resources/window.rc b/examples/quick/window/resources/window.rc
new file mode 100644 (file)
index 0000000..4de84d2
--- /dev/null
@@ -0,0 +1,32 @@
+#include "winver.h"
+
+IDI_ICON1               ICON    DISCARDABLE     "icon.ico"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,0
+ PRODUCTVERSION 1,0,0,0
+ FILEFLAGS 0x0L
+ FILEFLAGSMASK 0x3fL
+ FILEOS 0x00040004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "000004b0"
+        BEGIN
+            VALUE "CompanyName", "Digia Plc and/or its subsidiary(-ies)"
+            VALUE "FileDescription", "QtQuick Window Example"
+            VALUE "FileVersion", "1.0.0.0"
+            VALUE "LegalCopyright", "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies)."
+            VALUE "InternalName", "window"
+            VALUE "OriginalFilename", "window.exe"
+            VALUE "ProductName", "QtQuick Window Example"
+            VALUE "ProductVersion", "1.0.0.0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x0, 1200
+    END
+END
index 93e43fc..be35b24 100644 (file)
@@ -1,6 +1,16 @@
-TEMPLATE = subdirs
-SUBDIRS += \
-    window
+TEMPLATE = app
 
+QT += quick qml
+SOURCES += main.cpp
+RESOURCES += \
+    window.qrc \
+    ../shared/shared.qrc
 EXAMPLE_FILES = \
-    screen
+    window.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/window
+INSTALLS += target
+
+ICON = resources/icon64.png
+macx: ICON = resources/icon.icns
+win32: RC_FILE = resources/window.rc
diff --git a/examples/quick/window/window.qml b/examples/quick/window/window.qml
new file mode 100644 (file)
index 0000000..1d7282f
--- /dev/null
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+**     of its contributors may be used to endorse or promote products derived
+**     from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Window 2.1
+import "../shared" as Shared
+
+QtObject {
+    property real defaultSpacing: 10
+    property SystemPalette palette: SystemPalette { }
+
+    property var splashWindow: Splash { }
+
+    property var controlWindow: Window {
+        width: 400
+        height: col.implicitHeight + defaultSpacing * 2
+        color: palette.window
+        title: "Control Window"
+        visible: true
+        Column {
+            id: col
+            anchors.fill: parent
+            anchors.margins: defaultSpacing
+            spacing: defaultSpacing
+            property real cellWidth: col.width / 3 - spacing
+            Text { text: "Control the second window:" }
+            Grid {
+                id: grid
+                columns: 3
+                spacing: defaultSpacing
+                width: parent.width
+                Shared.Button {
+                    id: showButton
+                    width: col.cellWidth
+                    text: testWindow.visible ? "Hide" : "Show"
+                    onClicked: testWindow.visible = !testWindow.visible
+                }
+                //! [windowedCheckbox]
+                Shared.CheckBox {
+                    text: "Windowed"
+                    height: showButton.height
+                    width: col.cellWidth
+                    Binding on checked { value: testWindow.visibility === Window.Windowed }
+                    onClicked: testWindow.visibility = Window.Windowed
+                }
+                //! [windowedCheckbox]
+                Shared.CheckBox {
+                    height: showButton.height
+                    width: col.cellWidth
+                    text: "Full Screen"
+                    Binding on checked { value: testWindow.visibility === Window.FullScreen }
+                    onClicked: testWindow.visibility = Window.FullScreen
+                }
+                Shared.Button {
+                    id: autoButton
+                    width: col.cellWidth
+                    text: "Automatic"
+                    onClicked: testWindow.visibility = Window.AutomaticVisibility
+                }
+                Shared.CheckBox {
+                    height: autoButton.height
+                    text: "Minimized"
+                    Binding on checked { value: testWindow.visibility === Window.Minimized }
+                    onClicked: testWindow.visibility = Window.Minimized
+                }
+                Shared.CheckBox {
+                    height: autoButton.height
+                    text: "Maximized"
+                    Binding on checked { value: testWindow.visibility === Window.Maximized }
+                    onClicked: testWindow.visibility = Window.Maximized
+                }
+            }
+            function visibilityToString(v) {
+                switch (v) {
+                case Window.Windowed:
+                    return "windowed";
+                case Window.Minimized:
+                    return "minimized";
+                case Window.Maximized:
+                    return "maximized";
+                case Window.FullScreen:
+                    return "fullscreen";
+                case Window.AutomaticVisibility:
+                    return "automatic";
+                case Window.Hidden:
+                    return "hidden";
+                }
+                return "unknown";
+            }
+            Text {
+                text: "second window is " + (testWindow.visible ? "visible" : "invisible") +
+                      " and has visibility " + parent.visibilityToString(testWindow.visibility)
+            }
+            Rectangle {
+                id: horizontalRule
+                color: "black"
+                width: parent.width
+                height: 1
+            }
+            ScreenInfo { }
+        }
+    }
+
+    property var testWindow: Window {
+        width: 320
+        height: 240
+        color: "#215400"
+        title: "Test Window with color " + color
+        Rectangle {
+            anchors.fill: parent
+            anchors.margins: defaultSpacing
+            Text {
+                anchors.centerIn: parent
+                text: "Second Window"
+            }
+            MouseArea {
+                anchors.fill: parent
+                onClicked: testWindow.color = "#e0c31e"
+            }
+            Shared.Button {
+                anchors.right: parent.right
+                anchors.top: parent.top
+                anchors.margins: defaultSpacing
+                text: testWindow.visibility === Window.FullScreen ? "exit fullscreen" : "go fullscreen"
+                width: 150
+                onClicked: {
+                    if (testWindow.visibility === Window.FullScreen)
+                        testWindow.visibility = Window.AutomaticVisibility
+                    else
+                        testWindow.visibility = Window.FullScreen
+                }
+            }
+            Shared.Button {
+                anchors.left: parent.left
+                anchors.top: parent.top
+                anchors.margins: defaultSpacing
+                text: "X"
+                width: 30
+                onClicked: testWindow.visible = false
+            }
+        }
+    }
+}
diff --git a/examples/quick/window/window.qrc b/examples/quick/window/window.qrc
new file mode 100644 (file)
index 0000000..dc211bd
--- /dev/null
@@ -0,0 +1,7 @@
+<RCC>
+    <qresource prefix="/window">
+        <file>window.qml</file>
+        <file>Splash.qml</file>
+        <file>ScreenInfo.qml</file>
+    </qresource>
+</RCC>
diff --git a/examples/quick/window/window/nogui.qml b/examples/quick/window/window/nogui.qml
deleted file mode 100644 (file)
index 2a5734c..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQml 2.0
-
-/*
-    This object's only functionality is to exist as a root object and
-    display nothing, proving that qmlscene can run without windows.
-    (A QtObject can't even have Component.onCompleted)
-*/
-QtObject {
-    property string philosophy: "hello bleak windowless world"
-}
diff --git a/examples/quick/window/window/standalone.qml b/examples/quick/window/window/standalone.qml
deleted file mode 100644 (file)
index db73bf6..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-
-Item {
-    width: 320
-    height: 240
-    // It's not possible to set an Item's windowTitle.  If you want to modify
-    // window properties, you need to explicitly create a Window.
-    Text {
-        id: text1
-        anchors.centerIn: parent
-        text: "First Window\n" + (Qt.application.supportsMultipleWindows ?
-            "click the button to open a second window" : "only one window is allowed")
-    }
-    Rectangle {
-        border.color: "black"
-        radius: 4
-        anchors.top: text1.bottom
-        anchors.horizontalCenter: text1.horizontalCenter
-        width: 100
-        height: 30
-        TextInput {
-            id: ti1
-            focus: true // but the modal popup will prevent input while it is open
-            anchors.centerIn: parent
-        }
-    }
-    Rectangle {
-        border.color: "black"
-        color: childWindow.visible ? "goldenrod" : "beige"
-        radius: height / 4
-        anchors.bottom: parent.bottom
-        anchors.right: parent.right
-        anchors.margins: 10
-        width: text.implicitWidth + 20
-        height: text.implicitHeight + 20
-        visible: Qt.application.supportsMultipleWindows
-        Text {
-            id: text
-            text: "Pop up window"
-            anchors.centerIn: parent
-        }
-        MouseArea {
-            anchors.fill: parent
-            onClicked: childWindow.visible = !childWindow.visible
-        }
-    }
-
-    Window {
-        id: childWindow
-        width: 320
-        height: 240
-        x: 220
-        y: 120
-        color: "beige"
-        title: "Second Window"
-        modality: Qt.ApplicationModal
-        flags: Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint
-        Text {
-            id: text2
-            anchors.centerIn: parent
-            text: "Modal Frameless Stay-on-Top Window"
-        }
-        Text {
-            anchors.top: parent.top
-            anchors.right: parent.right
-            anchors.margins: 10
-            text: "X"
-            MouseArea{
-                anchors.fill: parent
-                onClicked: childWindow.visible = false
-            }
-        }
-        Rectangle {
-            border.color: "black"
-            radius: 4
-            anchors.top: text2.bottom
-            anchors.horizontalCenter: text2.horizontalCenter
-            width: 100
-            height: 30
-            TextInput {
-                id: ti2
-                focus: true
-                anchors.centerIn: parent
-            }
-        }
-    }
-}
diff --git a/examples/quick/window/window/twowindows.qml b/examples/quick/window/window/twowindows.qml
deleted file mode 100644 (file)
index 4a8d2f4..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-**   * Redistributions of source code must retain the above copyright
-**     notice, this list of conditions and the following disclaimer.
-**   * Redistributions in binary form must reproduce the above copyright
-**     notice, this list of conditions and the following disclaimer in
-**     the documentation and/or other materials provided with the
-**     distribution.
-**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
-**     of its contributors may be used to endorse or promote products derived
-**     from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Window 2.0
-
-QtObject {
-    property var win1: Window {
-        width: 320
-        height: 240
-        x: 0
-        y: 0
-        visible: true
-        color: "#ccffff"
-        title: "First Window"
-        Text {
-            anchors.centerIn: parent
-            text: "First Window"
-            Text {
-                id: statusText
-                anchors.top: parent.bottom
-                anchors.horizontalCenter: parent.horizontalCenter
-            }
-        }
-        MouseArea {
-            anchors.fill: parent
-            onClicked: win2.visible = !win2.visible
-        }
-    }
-    property var win2: Window {
-        width: 320
-        height: 240
-        x: 220
-        y: 120
-        visible: true
-        color: "green"
-        title: "Second Window: " + color
-        Rectangle {
-            anchors.fill: parent
-            anchors.margins: 10
-            Text {
-                anchors.centerIn: parent
-                text: "Second Window"
-            }
-            MouseArea {
-                anchors.fill: parent
-                onClicked: win2.color = "#ffffcc"
-            }
-        }
-        onVisibleChanged: statusText.text = "second window is " + (visible ? "visible" : "invisible")
-    }
-}
diff --git a/examples/quick/window/window/window.pro b/examples/quick/window/window/window.pro
deleted file mode 100644 (file)
index 3525a89..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = app
-QT += qml
-
-SOURCES += window.cpp
-RESOURCES += window.qrc
-
-EXAMPLE_FILES = \
-    nogui.qml \
-    standalone.qml \
-    twowindows.qml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/quick/window/window
-INSTALLS = target
diff --git a/examples/quick/window/window/window.qrc b/examples/quick/window/window/window.qrc
deleted file mode 100644 (file)
index c203c14..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
-    <qresource prefix="/window/window">
-        <file>Window.qml</file>
-    </qresource>
-</RCC>