From a42f90483e0adc0199f54fde66ab17b2fb019954 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Mon, 23 Nov 2009 13:43:33 +1000 Subject: cleanup slideswitch example --- examples/declarative/slideswitch/Switch.qml | 58 -- examples/declarative/slideswitch/background.svg | 23 - .../declarative/slideswitch/content/Switch.qml | 63 ++ .../declarative/slideswitch/content/background.svg | 23 + examples/declarative/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ examples/declarative/slideswitch/display.qml | 10 - examples/declarative/slideswitch/knob.svg | 867 --------------------- examples/declarative/slideswitch/slideswitch.qml | 11 + 8 files changed, 964 insertions(+), 958 deletions(-) delete mode 100644 examples/declarative/slideswitch/Switch.qml delete mode 100644 examples/declarative/slideswitch/background.svg create mode 100644 examples/declarative/slideswitch/content/Switch.qml create mode 100644 examples/declarative/slideswitch/content/background.svg create mode 100644 examples/declarative/slideswitch/content/knob.svg delete mode 100644 examples/declarative/slideswitch/display.qml delete mode 100644 examples/declarative/slideswitch/knob.svg create mode 100644 examples/declarative/slideswitch/slideswitch.qml 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/background.svg b/examples/declarative/slideswitch/background.svg deleted file mode 100644 index f920d3e..0000000 --- a/examples/declarative/slideswitch/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - 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/content/background.svg b/examples/declarative/slideswitch/content/background.svg new file mode 100644 index 0000000..f920d3e --- /dev/null +++ b/examples/declarative/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/declarative/slideswitch/content/knob.svg b/examples/declarative/slideswitch/content/knob.svg new file mode 100644 index 0000000..fb69337 --- /dev/null +++ b/examples/declarative/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/display.qml deleted file mode 100644 index 346ffb1..0000000 --- a/examples/declarative/slideswitch/display.qml +++ /dev/null @@ -1,10 +0,0 @@ -import Qt 4.6 - -Rectangle { - color: "white" - width: 150 - height: 150 - Switch { - anchors.centerIn: parent - } -} diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/knob.svg deleted file mode 100644 index fb69337..0000000 --- a/examples/declarative/slideswitch/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml new file mode 100644 index 0000000..9b46cd1 --- /dev/null +++ b/examples/declarative/slideswitch/slideswitch.qml @@ -0,0 +1,11 @@ +import Qt 4.6 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + + Switch { + anchors.centerIn: parent + } +} -- cgit v0.12