1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the examples of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import QtQuick.Particles 2.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)
106 source: "content/images/star.png"
114 emitRate: parent.width / 50
123 z: 2 // just above the sun so that the sun can set behind it
124 anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom }
126 GradientStop { position: 0.0; color: "ForestGreen" }
127 GradientStop { position: 1.0; color: "DarkGreen" }
131 SystemPalette { id: activePalette }
138 color: activePalette.window
139 anchors { right: parent.right; top: parent.top; bottom: parent.bottom }
142 anchors.centerIn: parent
145 Text { text: "Drag an item into the scene." }
148 width: palette.width + 10; height: palette.height + 10
149 border.color: "black"
153 anchors.centerIn: parent
157 anchors.verticalCenter: parent.verticalCenter
158 componentFile: "Sun.qml"
159 source: "content/images/sun.png"
160 image: "images/sun.png"
163 anchors.verticalCenter: parent.verticalCenter
164 componentFile: "GenericSceneItem.qml"
165 source: "content/images/moon.png"
166 image: "images/moon.png"
169 anchors.verticalCenter: parent.verticalCenter
170 componentFile: "PerspectiveItem.qml"
171 source: "content/images/tree_s.png"
172 image: "images/tree_s.png"
175 anchors.verticalCenter: parent.verticalCenter
176 componentFile: "PerspectiveItem.qml"
177 source: "content/images/rabbit_brown.png"
178 image: "images/rabbit_brown.png"
181 anchors.verticalCenter: parent.verticalCenter
182 componentFile: "PerspectiveItem.qml"
183 source: "content/images/rabbit_bw.png"
184 image: "images/rabbit_bw.png"
189 Text { text: "Active Suns: " + activeSuns }
191 Rectangle { width: parent.width; height: 1; color: "black" }
193 Text { text: "Arbitrary QML:" }
196 width: 360; height: 240
200 anchors.fill: parent; anchors.margins: 5
203 wrapMode: TextEdit.WordWrap
205 text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}"
213 Qt.createQmlObject(qmlText.text, window, 'CustomObject');
215 dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message);
222 //Day state, for when a sun is added to the scene
225 when: window.activeSuns > 0
227 PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" }
228 PropertyChanges { target: gradientStopB; color: "SkyBlue" }
229 PropertyChanges { target: stars; opacity: 0 }
232 //! [top-level transitions]
233 transitions: Transition {
234 PropertyAnimation { duration: 3000 }
235 ColorAnimation { duration: 3000 }
237 //! [top-level transitions]