1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the examples of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
20 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 ** the names of its contributors may be used to endorse or promote
22 ** products derived from this software without specific prior written
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import Qt.labs.particles 1.0
48 property int activeSuns: 0
50 //This is a desktop-sized example
51 width: 800; height: 480
56 onClicked: window.focus = false;
59 //This is the message box that pops up when there's an error
64 anchors.centerIn: parent
65 width: dialogText.width + 6; height: dialogText.height + 6
67 color: 'lightsteelblue'
68 z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
71 dialogText.text = str;
83 NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 }
84 PauseAnimation { duration: 5000 }
85 NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 }
92 anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter }
94 GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" }
95 GradientStop { id: gradientStopB; position: 1.0; color: "#437284" }
99 // stars (when there's no sun)
102 x: 0; y: 0; width: parent.width; height: parent.height / 2
103 source: "images/star.png"
105 velocity: 0; velocityDeviation: 0
106 count: parent.width / 10
114 z: 2 // just above the sun so that the sun can set behind it
115 anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom }
117 GradientStop { position: 0.0; color: "ForestGreen" }
118 GradientStop { position: 1.0; color: "DarkGreen" }
122 SystemPalette { id: activePalette }
129 color: activePalette.window
130 anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
133 anchors.centerIn: parent
136 Text { text: "Drag an item into the scene." }
139 width: palette.width + 10; height: palette.height + 10
140 border.color: "black"
144 anchors.centerIn: parent
148 anchors.verticalCenter: parent.verticalCenter
149 componentFile: "Sun.qml"
150 image: "../images/sun.png"
153 anchors.verticalCenter: parent.verticalCenter
154 componentFile: "GenericSceneItem.qml"
155 image: "../images/moon.png"
158 anchors.verticalCenter: parent.verticalCenter
159 componentFile: "PerspectiveItem.qml"
160 image: "../images/tree_s.png"
163 anchors.verticalCenter: parent.verticalCenter
164 componentFile: "PerspectiveItem.qml"
165 image: "../images/rabbit_brown.png"
168 anchors.verticalCenter: parent.verticalCenter
169 componentFile: "PerspectiveItem.qml"
170 image: "../images/rabbit_bw.png"
175 Text { text: "Active Suns: " + activeSuns }
177 Rectangle { width: parent.width; height: 1; color: "black" }
179 Text { text: "Arbitrary QML:" }
182 width: 360; height: 240
186 anchors.fill: parent; anchors.margins: 5
189 wrapMode: TextEdit.WordWrap
191 text: "import QtQuick 1.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
199 Qt.createQmlObject(qmlText.text, window, 'CustomObject');
201 dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
208 //Day state, for when a sun is added to the scene
211 when: window.activeSuns > 0
213 PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
214 PropertyChanges { target: gradientStopB; color: "SkyBlue" }
215 PropertyChanges { target: stars; opacity: 0 }
218 //! [top-level transitions]
219 transitions: Transition {
220 PropertyAnimation { duration: 3000 }
221 ColorAnimation { duration: 3000 }
223 //! [top-level transitions]