summaryrefslogtreecommitdiff
path: root/nekowatchlet/metawatch-digital.qml
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-17 02:29:28 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-17 02:29:28 +0200
commit9c44782c5eab5635ca6adf4717409bf2ffb6c694 (patch)
tree99f774bccb6e964864168b346155bbd5a52bf3b2 /nekowatchlet/metawatch-digital.qml
parentf9ac9d207025fb8d40d1be753cde78beb77aa202 (diff)
downloadsowatch-9c44782c5eab5635ca6adf4717409bf2ffb6c694.tar.gz
sowatch-9c44782c5eab5635ca6adf4717409bf2ffb6c694.zip
new nekowatchlet and minor graphics/performance changes
Diffstat (limited to 'nekowatchlet/metawatch-digital.qml')
-rw-r--r--nekowatchlet/metawatch-digital.qml49
1 files changed, 49 insertions, 0 deletions
diff --git a/nekowatchlet/metawatch-digital.qml b/nekowatchlet/metawatch-digital.qml
new file mode 100644
index 0000000..b1e16c8
--- /dev/null
+++ b/nekowatchlet/metawatch-digital.qml
@@ -0,0 +1,49 @@
+import QtQuick 1.0
+import com.javispedro.sowatch.metawatch 1.0
+
+MWPage {
+ Neko {
+ id: neko
+ running: watch.active
+
+ targetX: goal.x
+ targetY: goal.y
+ }
+
+ Rectangle {
+ id: goal
+ width: 2
+ height: 2
+ color: "black"
+
+ Behavior on x { SmoothedAnimation { velocity: 80; }}
+ Behavior on y { SmoothedAnimation { velocity: 80; }}
+ }
+
+ function goToRandomPosition() {
+ goal.x = 16 + Math.floor(Math.random() * (width - 32));
+ goal.y = 16 + Math.floor(Math.random() * (height - 32));
+ }
+
+ function goToSleep() {
+ neko.state = "SLEEPING";
+ }
+
+ Connections {
+ target: watch
+ onActiveChanged: {
+ if (watch.active) {
+ goToSleep();
+ }
+ }
+
+ onButtonPressed : {
+ switch (button) {
+ case 1:
+ case 2:
+ goToRandomPosition();
+ break;
+ }
+ }
+ }
+}