summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-10-30 01:35:50 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-10-30 01:35:50 (GMT)
commitff1a4e75056b200b7eb9117ddfd5b6cd27f4e92e (patch)
tree26879f90c913f5b9890e8857d4447787d9f4c19c /examples
parent2f4675f0a21b82bff7de165619664b7c2b09c585 (diff)
downloadQt-ff1a4e75056b200b7eb9117ddfd5b6cd27f4e92e.zip
Qt-ff1a4e75056b200b7eb9117ddfd5b6cd27f4e92e.tar.gz
Qt-ff1a4e75056b200b7eb9117ddfd5b6cd27f4e92e.tar.bz2
improve clock example
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/clock/Clock.qml69
-rwxr-xr-xexamples/declarative/clock/center.pngbin0 -> 765 bytes
-rwxr-xr-xexamples/declarative/clock/clock.pngbin0 -> 21780 bytes
-rw-r--r--examples/declarative/clock/display.qml9
-rwxr-xr-x[-rw-r--r--]examples/declarative/clock/hour.pngbin391 -> 625 bytes
-rwxr-xr-x[-rw-r--r--]examples/declarative/clock/minute.pngbin445 -> 625 bytes
-rwxr-xr-x[-rw-r--r--]examples/declarative/clock/second.pngbin345 -> 303 bytes
7 files changed, 41 insertions, 37 deletions
diff --git a/examples/declarative/clock/Clock.qml b/examples/declarative/clock/Clock.qml
index a061488..636c99f 100644
--- a/examples/declarative/clock/Clock.qml
+++ b/examples/declarative/clock/Clock.qml
@@ -2,79 +2,76 @@ import Qt 4.6
Item {
id: clock
- width: 200; height: 200
- property var time
+ width: 200; height: 230
+
+ property alias city: cityLabel.text
property var hours
property var minutes
property var seconds
- onTimeChanged: {
+ property int shift : 0
+
+ function timeChanged() {
var date = new Date;
- hours = date.getHours();
- minutes = date.getMinutes();
- seconds = date.getSeconds();
+ hours = date.getUTCHours() + clock.shift
+ minutes = date.getUTCMinutes();
+ seconds = date.getUTCSeconds();
}
+
Timer {
- interval: 100; running: true; repeat: true; triggeredOnStart: true
- onTriggered: clock.time = new Date()
+ interval: 1000; running: true; repeat: true; triggeredOnStart: true
+ onTriggered: clock.timeChanged()
}
- Image { source: "background.png" }
+ Image { id: background; source: "clock.png" }
+
Image {
- x: 95
- y: 54
+ x: 92.5; y: 27
source: "hour.png"
smooth: true
transform: Rotation {
id: hourRotation
- origin.x: 4; origin.y: 45
- angle: 0
+ origin.x: 7.5; origin.y: 73; angle: 0
angle: SpringFollow {
- spring: 2
- damping: .2
- source: clock.hours * 50 * 3 + clock.minutes / 2
+ spring: 2; damping: 0.2; modulus: 360
+ source: (clock.hours * 30) + (clock.minutes * 0.5)
}
}
}
+
Image {
- x: 95
- y: 30
+ x: 93.5; y: 17
source: "minute.png"
smooth: true
transform: Rotation {
id: minuteRotation
- origin.x: 4; origin.y: 70
- angle: 0
+ origin.x: 6.5; origin.y: 83; angle: 0
angle: SpringFollow {
- spring: 2
- damping: .2
+ spring: 2; damping: 0.2; modulus: 360
source: clock.minutes * 6
}
}
}
+
Image {
- x: 96
- y: 40
+ x: 97.5; y: 20
source: "second.png"
smooth: true
transform: Rotation {
id: secondRotation
- origin.x: 2; origin.y: 60
- angle: 0
+ origin.x: 2.5; origin.y: 80; angle: 0
angle: SpringFollow {
- spring: 5
- damping: .25
- modulus: 360
+ spring: 5; damping: 0.25; modulus: 360
source: clock.seconds * 6
}
}
}
- Rectangle {
- x: 93
- y: 94
- width: 11
- height: 11
- radius: 5
- color: "black"
+ Image {
+ anchors.centerIn: background; source: "center.png"
+ }
+
+ Text {
+ id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white"
+ anchors.horizontalCenter: parent.horizontalCenter
}
}
diff --git a/examples/declarative/clock/center.png b/examples/declarative/clock/center.png
new file mode 100755
index 0000000..7fbd802
--- /dev/null
+++ b/examples/declarative/clock/center.png
Binary files differ
diff --git a/examples/declarative/clock/clock.png b/examples/declarative/clock/clock.png
new file mode 100755
index 0000000..30bc577
--- /dev/null
+++ b/examples/declarative/clock/clock.png
Binary files differ
diff --git a/examples/declarative/clock/display.qml b/examples/declarative/clock/display.qml
index 20e254d..927adfa 100644
--- a/examples/declarative/clock/display.qml
+++ b/examples/declarative/clock/display.qml
@@ -3,5 +3,12 @@ import Qt 4.6
Rectangle {
width: childrenRect.width
height: childrenRect.height
- Clock { id: clock }
+ color: "#646464"
+
+ Grid {
+ columns: 3
+ Clock { city: "New York"; shift: -4 }
+ Clock { city: "London" }
+ Clock { city: "Brisbane"; shift: 10 }
+ }
}
diff --git a/examples/declarative/clock/hour.png b/examples/declarative/clock/hour.png
index 603466b..f8061a1 100644..100755
--- a/examples/declarative/clock/hour.png
+++ b/examples/declarative/clock/hour.png
Binary files differ
diff --git a/examples/declarative/clock/minute.png b/examples/declarative/clock/minute.png
index 0207405..1297ec7 100644..100755
--- a/examples/declarative/clock/minute.png
+++ b/examples/declarative/clock/minute.png
Binary files differ
diff --git a/examples/declarative/clock/second.png b/examples/declarative/clock/second.png
index bfcef68..4aa9fb5 100644..100755
--- a/examples/declarative/clock/second.png
+++ b/examples/declarative/clock/second.png
Binary files differ