~mutse-young/ubuntu-docviewer-app/trunk

« back to all changes in this revision

Viewing changes to src/app/qml/WelcomePage.qml

  • Committer: Tarmac
  • Author(s): Stefano Verzegnassi
  • Date: 2014-11-07 22:02:18 UTC
  • mfrom: (36.3.6 content-hub-support)
  • Revision ID: tarmac-20141107220218-gpy3rrsdl8lgierw
Added ContentHub support. Fixes: https://bugs.launchpad.net/bugs/1387025, https://bugs.launchpad.net/bugs/1387026.

Approved by Arthur Mello, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.0
 
2
import Ubuntu.Components 1.1
 
3
import Ubuntu.Content 1.1
 
4
 
 
5
Page {
 
6
    id: picker
 
7
 
 
8
    property var activeTransfer
 
9
 
 
10
    ContentTransferHint {
 
11
        id: transferHint
 
12
        anchors.fill: parent
 
13
        activeTransfer: picker.activeTransfer
 
14
    }
 
15
 
 
16
    title: i18n.tr("Open with...")
 
17
    head.sections.model: [i18n.tr("Pictures"), i18n.tr("Documents"), i18n.tr("Unknown")]
 
18
    head.backAction: Action {
 
19
        iconName: "close"
 
20
        text: i18n.tr("Close")
 
21
        onTriggered: Qt.quit()
 
22
    }
 
23
 
 
24
    ContentPeerPicker {
 
25
        showTitle: false
 
26
 
 
27
        contentType: {
 
28
            switch (picker.head.sections.selectedIndex) {
 
29
            case 0:
 
30
                return ContentType.Pictures
 
31
            case 1:
 
32
                return ContentType.Documents
 
33
            case 2:
 
34
                return ContentType.Unknown
 
35
            }
 
36
        }
 
37
        handler: ContentHandler.Source
 
38
 
 
39
        onPeerSelected: picker.activeTransfer = peer.request();
 
40
    }
 
41
 
 
42
    Connections {
 
43
        target: picker.activeTransfer ? picker.activeTransfer : null
 
44
        onStateChanged: {
 
45
            if (picker.activeTransfer.state === ContentTransfer.Charged) {
 
46
                file.path = picker.activeTransfer.items[0].url.toString().replace("file://", "")
 
47
                console.log("[CONTENT-HUB] Content imported!")
 
48
            }
 
49
        }
 
50
    }
 
51
}