~mhall119/+junk/imageviewer

« back to all changes in this revision

Viewing changes to Main.qml

  • Committer: Michael Hall
  • Date: 2015-05-03 01:28:07 UTC
  • Revision ID: mhall119@ubuntu.com-20150503012807-335fia56x4zoee3p
Initial version

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 0.1
 
4
 
 
5
/*!
 
6
    \brief MainView with a Label and Button elements.
 
7
*/
 
8
 
 
9
MainView {
 
10
    id: imgViewer
 
11
    // objectName for functional testing purposes (autopilot-qt5)
 
12
    objectName: "mainView"
 
13
 
 
14
    // Note! applicationName needs to match the "name" field of the click manifest
 
15
    applicationName: "imageviewer.mhall119"
 
16
 
 
17
    /*
 
18
     This property enables the application to change orientation
 
19
     when the device is rotated. The default is false.
 
20
    */
 
21
    //automaticOrientation: true
 
22
 
 
23
    // Removes the old toolbar and enables new features of the new header.
 
24
    useDeprecatedToolbar: false
 
25
 
 
26
    width: units.gu(100)
 
27
    height: units.gu(75)
 
28
 
 
29
    Arguments {
 
30
        id: args
 
31
 
 
32
        Argument {
 
33
            name: "url"
 
34
            help: i18n.tr("Image to open")
 
35
            required: false
 
36
            valueNames: ["URL"]
 
37
        }
 
38
    }
 
39
 
 
40
    PageStack {
 
41
        id: mainStack
 
42
        onDepthChanged: {
 
43
            if (depth == 0) {
 
44
                Qt.quit()
 
45
            }
 
46
        }
 
47
    }
 
48
 
 
49
    Component.onCompleted: {
 
50
        if (args.values.url) {
 
51
            openImage(args.values.url)
 
52
        }
 
53
    }
 
54
    function openImage(url) {
 
55
        console.log("Opening image: "+url)
 
56
        var filepath = url.replace("file://", "");
 
57
        var fileparts = filepath.split("/");
 
58
        var filename = fileparts.pop();
 
59
        mainStack.push(Qt.resolvedUrl("ImageViewPage.qml"), {"name": filename, "source": filepath})
 
60
 
 
61
    }
 
62
 
 
63
    // Content Exporter
 
64
    property list<ContentItem> selectedItems
 
65
    Connections {
 
66
        target: ContentHub
 
67
        onExportRequested: {
 
68
            // show content picker
 
69
            mainStack.push(Qt.resolvedUrl("ExportPage.qml"), {"activeTransfer": transfer})
 
70
        }
 
71
        onImportRequested: {
 
72
            // show content
 
73
            if (transfer.state === ContentTransfer.Charged) {
 
74
                openImage(transfer.items[0].url.toString())
 
75
            }
 
76
        }
 
77
    }
 
78
}
 
79