summaryrefslogtreecommitdiffstats
path: root/examples/declarative/toys/dial-example
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/toys/dial-example')
-rw-r--r--examples/declarative/toys/dial-example/content/Dial.qml43
-rw-r--r--examples/declarative/toys/dial-example/content/background.pngbin0 -> 35876 bytes
-rw-r--r--examples/declarative/toys/dial-example/content/needle.pngbin0 -> 342 bytes
-rw-r--r--examples/declarative/toys/dial-example/content/needle_shadow.pngbin0 -> 632 bytes
-rw-r--r--examples/declarative/toys/dial-example/content/overlay.pngbin0 -> 3564 bytes
-rw-r--r--examples/declarative/toys/dial-example/dial-example.qml50
-rw-r--r--examples/declarative/toys/dial-example/dial.qmlproject16
7 files changed, 109 insertions, 0 deletions
diff --git a/examples/declarative/toys/dial-example/content/Dial.qml b/examples/declarative/toys/dial-example/content/Dial.qml
new file mode 100644
index 0000000..6f24801
--- /dev/null
+++ b/examples/declarative/toys/dial-example/content/Dial.qml
@@ -0,0 +1,43 @@
+import Qt 4.7
+
+Item {
+ id: root
+ property real value : 0
+
+ width: 210; height: 210
+
+ Image { source: "background.png" }
+
+//! [needle_shadow]
+ Image {
+ x: 93
+ y: 35
+ source: "needle_shadow.png"
+ transform: Rotation {
+ origin.x: 11; origin.y: 67
+ angle: needleRotation.angle
+ }
+ }
+//! [needle_shadow]
+//! [needle]
+ Image {
+ id: needle
+ x: 95; y: 33
+ smooth: true
+ source: "needle.png"
+ transform: Rotation {
+ id: needleRotation
+ origin.x: 7; origin.y: 65
+ angle: -130
+ SpringFollow on angle {
+ spring: 1.4
+ damping: .15
+ to: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ }
+ }
+ }
+//! [needle]
+//! [overlay]
+ Image { x: 21; y: 18; source: "overlay.png" }
+//! [overlay]
+}
diff --git a/examples/declarative/toys/dial-example/content/background.png b/examples/declarative/toys/dial-example/content/background.png
new file mode 100644
index 0000000..75d555d
--- /dev/null
+++ b/examples/declarative/toys/dial-example/content/background.png
Binary files differ
diff --git a/examples/declarative/toys/dial-example/content/needle.png b/examples/declarative/toys/dial-example/content/needle.png
new file mode 100644
index 0000000..2d19f75
--- /dev/null
+++ b/examples/declarative/toys/dial-example/content/needle.png
Binary files differ
diff --git a/examples/declarative/toys/dial-example/content/needle_shadow.png b/examples/declarative/toys/dial-example/content/needle_shadow.png
new file mode 100644
index 0000000..8d8a928
--- /dev/null
+++ b/examples/declarative/toys/dial-example/content/needle_shadow.png
Binary files differ
diff --git a/examples/declarative/toys/dial-example/content/overlay.png b/examples/declarative/toys/dial-example/content/overlay.png
new file mode 100644
index 0000000..3860a7b
--- /dev/null
+++ b/examples/declarative/toys/dial-example/content/overlay.png
Binary files differ
diff --git a/examples/declarative/toys/dial-example/dial-example.qml b/examples/declarative/toys/dial-example/dial-example.qml
new file mode 100644
index 0000000..900954f
--- /dev/null
+++ b/examples/declarative/toys/dial-example/dial-example.qml
@@ -0,0 +1,50 @@
+import Qt 4.7
+import "content"
+
+//! [0]
+Rectangle {
+ color: "#545454"
+ width: 300; height: 300
+
+ // Dial with a slider to adjust it
+ Dial {
+ id: dial
+ anchors.centerIn: parent
+ value: slider.x * 100 / (container.width - 34)
+ }
+
+ Rectangle {
+ id: container
+ anchors { bottom: parent.bottom; left: parent.left
+ right: parent.right; leftMargin: 20; rightMargin: 20
+ bottomMargin: 10
+ }
+ height: 16
+
+ radius: 8
+ opacity: 0.7
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "gray" }
+ GradientStop { position: 1.0; color: "white" }
+ }
+
+ Rectangle {
+ id: slider
+ x: 1; y: 1; width: 30; height: 14
+ radius: 6
+ smooth: true
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#424242" }
+ GradientStop { position: 1.0; color: "black" }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ drag.target: parent; drag.axis: Drag.XAxis
+ drag.minimumX: 2; drag.maximumX: container.width - 32
+ }
+ }
+ }
+}
+//! [0] \ No newline at end of file
diff --git a/examples/declarative/toys/dial-example/dial.qmlproject b/examples/declarative/toys/dial-example/dial.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/toys/dial-example/dial.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}