Item {
id: root;
+
+ property var snow: [];
+ readonly property int snowCount: 100;
+ readonly property int screenWidth: Qt.application.screens[0].width;
+ readonly property int screenHeight: Qt.application.screens[0].height;
+
Button {
+
+ id: letitsnow;
+
anchors.centerIn: parent;
text: "Let it snow!";
onClicked: {
- var snow = [];
- for (var i = 0; i < 10; i++) {
+
+ //var screenWidth = Qt.application.screens[0].width;
+ //var screenHeight = Qt.application.screens[0].height;
+
+ for (var i = 0; i < snowCount; i++) {
+
+ var component = Qt.createComponent("snowWindow.qml");
+
+ snow[i] = component.createObject(root);
- snow[i] = Qt.createComponent("snowWindow.qml");
- var snowWindow = snow[i].createObject(root);
- snowWindow.x = Math.random() * 500;
- snowWindow.y = Math.random() * 500;
- //snowWindow.opacity = 0.9;
- //snowWindow.flags = Qt.WA_TransparentForMouseEvents | Qt.X11BypassWindowManagerHint;
-
- //snowWindow.flags = Qt.WA_TransparentForMouseEvents| Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint;
- snowWindow.showMaximized();
+ snow[i].x = Math.random() * screenWidth;
+ snow[i].y = Math.random() * screenHeight;
+
+ snow[i].showMaximized();
}
- }
- }
+
+ snowFalling.running = true;
+ }
+ }
+
+ Timer {
+
+ id: snowFalling
+
+ function test() {
+ }
+
+ interval: 50; running: false; repeat: true
+
+ onTriggered: {
+
+ for (var i = 0; i < snowCount; i++) {
+ if(snow[i].dir == 0) {
+ snow[i].x += 2;
+ } else {
+ snow[i].x -= 2;
+ }
+
+ if (snow[i].disposition++ % snow[i].swirl == 0) {
+ snow[i].dir = !snow[i].dir;
+ }
+
+ if(snow[i].x > screenWidth) {
+ snow[i].x = 0;
+ } else if (snow[i].x < 0) {
+ snow[i].x = 1440;
+ }
+
+ snow[i].y += 2;
+
+ if (snow[i].y > screenHeight) {
+ snow[i].y = 0;
+ }
+ }
+ }
+ }
+
}