summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-11-23 04:27:54 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-11-23 04:27:54 (GMT)
commit2a93f7ce631702ec17b87e23d7efa8a0ae6f5458 (patch)
treeafb8d35c97140c6bb83118339f883613b945d5f7 /examples/declarative
parent8ac4581718767c498192cdffdfc97211d0030e7b (diff)
parentd07d71ff11c522cd5401e97b3231b037c38bbd9f (diff)
downloadQt-2a93f7ce631702ec17b87e23d7efa8a0ae6f5458.zip
Qt-2a93f7ce631702ec17b87e23d7efa8a0ae6f5458.tar.gz
Qt-2a93f7ce631702ec17b87e23d7efa8a0ae6f5458.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/slideswitch/Switch.qml58
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml63
-rw-r--r--examples/declarative/slideswitch/content/background.svg (renamed from examples/declarative/slideswitch/background.svg)0
-rw-r--r--examples/declarative/slideswitch/content/knob.svg (renamed from examples/declarative/slideswitch/knob.svg)0
-rw-r--r--examples/declarative/slideswitch/slideswitch.qml (renamed from examples/declarative/slideswitch/display.qml)5
5 files changed, 66 insertions, 60 deletions
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
deleted file mode 100644
index 4e13976..0000000
--- a/examples/declarative/slideswitch/Switch.qml
+++ /dev/null
@@ -1,58 +0,0 @@
-import Qt 4.6
-
-Item {
- id: mySwitch
- width: groove.width; height: groove.height
-
- property var on
-
- Script {
-
- function toggle() {
- if(mySwitch.state == "On")
- mySwitch.state = "Off";
- else
- mySwitch.state = "On";
- }
- function dorelease() {
- if(knob.x == 1) {
- if(mySwitch.state == "Off")
- return;
- }
-
- if(knob.x == 78) {
- if(mySwitch.state == "On")
- return;
- }
-
- toggle();
- }
-
- }
- Image { id: groove; source: "background.svg" }
- MouseRegion { anchors.fill: groove; onClicked: { toggle() } }
- Image { id: knob; source: "knob.svg"; x: 1; y: 2 }
- MouseRegion {
- anchors.fill: knob
- onClicked: { toggle() }
- onReleased: { dorelease() }
- drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
- }
- states: [
- State {
- name: "On"
- PropertyChanges { target: knob; x: 78 }
- PropertyChanges { target: mySwitch; on: true }
- },
- State {
- name: "Off"
- PropertyChanges { target: knob; x: 1 }
- PropertyChanges { target: mySwitch; on: false }
- }
- ]
- transitions: [
- Transition {
- NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 }
- }
- ]
-}
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
new file mode 100644
index 0000000..b65936a
--- /dev/null
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -0,0 +1,63 @@
+import Qt 4.6
+
+Item {
+ id: mySwitch
+ width: background.width; height: background.height
+
+ property bool on: false
+
+ Script {
+ function toggle() {
+ if (mySwitch.state == "On")
+ mySwitch.state = "Off";
+ else
+ mySwitch.state = "On";
+ }
+
+ function dorelease() {
+ if (knob.x == 1) {
+ if (mySwitch.state == "Off")
+ return;
+ }
+
+ if (knob.x == 78) {
+ if (mySwitch.state == "On")
+ return;
+ }
+ toggle();
+ }
+ }
+
+ Image {
+ id: background; source: "background.svg"
+ MouseRegion { anchors.fill: parent; onClicked: toggle() }
+ }
+
+ Image {
+ id: knob; source: "knob.svg"; x: 1; y: 2
+
+ MouseRegion {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: dorelease()
+ }
+ }
+
+ states: [
+ State {
+ name: "On"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: mySwitch; on: true }
+ },
+ State {
+ name: "Off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: mySwitch; on: false }
+ }
+ ]
+
+ transitions: Transition {
+ NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 }
+ }
+}
diff --git a/examples/declarative/slideswitch/background.svg b/examples/declarative/slideswitch/content/background.svg
index f920d3e..f920d3e 100644
--- a/examples/declarative/slideswitch/background.svg
+++ b/examples/declarative/slideswitch/content/background.svg
diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/content/knob.svg
index fb69337..fb69337 100644
--- a/examples/declarative/slideswitch/knob.svg
+++ b/examples/declarative/slideswitch/content/knob.svg
diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/slideswitch.qml
index 346ffb1..9b46cd1 100644
--- a/examples/declarative/slideswitch/display.qml
+++ b/examples/declarative/slideswitch/slideswitch.qml
@@ -1,9 +1,10 @@
import Qt 4.6
+import "content"
Rectangle {
color: "white"
- width: 150
- height: 150
+ width: 400; height: 250
+
Switch {
anchors.centerIn: parent
}