summaryrefslogtreecommitdiffstats
path: root/tests/image-asynchronous.qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/image-asynchronous.qml')
-rw-r--r--tests/image-asynchronous.qml71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/image-asynchronous.qml b/tests/image-asynchronous.qml
new file mode 100644
index 0000000..b1c441e
--- /dev/null
+++ b/tests/image-asynchronous.qml
@@ -0,0 +1,71 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 800
+ height: 600
+
+ color: "red"
+
+ Image {
+ id: image
+ source: state == 1 || state == 3 ? "/Users/gunnar/Pictures/big.jpg" : ""
+ width: 100
+ height: 100
+ asynchronous: true
+
+ opacity: source == "" ? 0.01 : 1
+
+ property int state: 0
+
+ Behavior on opacity {
+ NumberAnimation { duration: 250 }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ image.state = (image.state + 1) % 4;
+ }
+ }
+
+ }
+
+ Rectangle {
+ anchors.fill: text
+ anchors.margins: -10
+ color: "black"
+ radius: 5
+ }
+
+ Text {
+ id: text
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.margins: 20
+ color: "white"
+ text: image.asynchronous ? "Loading in a thread" : "Not loading in a thread"
+ }
+
+
+ Rectangle {
+
+ anchors.centerIn: parent
+
+ width: 200
+ height: 200
+
+ border.width: 4
+ border.color: "black"
+ color: "white"
+
+ NumberAnimation on rotation {
+ from: 0
+ to: 360
+ duration: 2500
+ loops: Animation.Infinite
+ }
+ }
+
+
+
+}