summaryrefslogtreecommitdiff
path: root/nekowatchlet
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-11 19:17:07 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-11 19:17:07 +0200
commitbf083973efd101e05d75882b63aad9bdfa37dfbc (patch)
treec07769c2a82e4b5bba8d3d02558eb4c69a531001 /nekowatchlet
parentbc899047089079dde323e84a57efe46ce6af653d (diff)
downloadsowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.tar.gz
sowatch-bf083973efd101e05d75882b63aad9bdfa37dfbc.zip
store watchlets in model
Diffstat (limited to 'nekowatchlet')
-rw-r--r--nekowatchlet/liveview.qml48
-rw-r--r--nekowatchlet/nekowatchlet.pro3
2 files changed, 51 insertions, 0 deletions
diff --git a/nekowatchlet/liveview.qml b/nekowatchlet/liveview.qml
new file mode 100644
index 0000000..a9c5712
--- /dev/null
+++ b/nekowatchlet/liveview.qml
@@ -0,0 +1,48 @@
+import QtQuick 1.0
+
+Item {
+ 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;
+ }
+ }
+ }
+}
diff --git a/nekowatchlet/nekowatchlet.pro b/nekowatchlet/nekowatchlet.pro
index b45979a..fd9321a 100644
--- a/nekowatchlet/nekowatchlet.pro
+++ b/nekowatchlet/nekowatchlet.pro
@@ -24,3 +24,6 @@ unix:!symbian {
}
INSTALLS += target qml_files
}
+
+OTHER_FILES += \
+ liveview.qml