1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1
import Ubuntu.Content 0.1
MainView {
applicationName: "import-qml"
width: 300
height: 200
property list<ContentItem> importItems
property var activeTransfer
Button {
id: importButton
text: "Import from default"
onClicked: {
var peer = ContentHub.defaultSourceForType(ContentType.Pictures);
var transfer = ContentHub.importContent(ContentType.Pictures, peer);
var store = ContentHub.defaultStoreForType(ContentType.Pictures);
console.log("Store is: " + store.uri);
if (transfer !== null) {
transfer.selectionType = ContentTransfer.Multiple;
transfer.setStore(store);
activeTransfer = transfer;
activeTransfer.start();
}
}
}
Button {
anchors.left: importButton.right
text: "Finalize import"
enabled: activeTransfer.state === ContentTransfer.Collected
onClicked: activeTransfer.finalize()
}
ListView {
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
top: importButton.bottom
}
model: importItems
delegate: Empty {
id: result
height: 128
UbuntuShape {
anchors.horizontalCenter: parent.horizontalCenter
width: image.width
height: image.height
image: Image {
id: image
source: url
height: result.height
fillMode: Image.PreserveAspectFit
smooth: true
}
}
}
}
Connections {
target: activeTransfer
onStateChanged: {
console.log("StateChanged: " + activeTransfer.state);
if (activeTransfer.state === ContentTransfer.Charged)
importItems = activeTransfer.items;
}
}
}
|