summaryrefslogtreecommitdiff
path: root/rockwork/qml/ScreenshotsPage.qml
blob: fdbeb9afcafb1574f4b5cdcfaaf1da9bcf2de1fd (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import QtQuick 2.4
import QtQuick.Layouts 1.1
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import Ubuntu.Content 1.3
import RockWork 1.0

Page {
    id: root

    title: i18n.tr("Screenshots")

    property var pebble: null

    head {
        actions: [
            Action {
                iconName: "camera-app-symbolic"
                onTriggered: root.pebble.requestScreenshot()
            }
        ]
    }

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: units.gu(1)
        spacing: units.gu(1)

        GridView {
            id: grid
            Layout.fillHeight: true
            Layout.fillWidth: true
            clip: true

            property int columns: 2

            cellWidth: width / columns
            cellHeight: cellWidth

            model: root.pebble.screenshots

            displaced: Transition {
                UbuntuNumberAnimation { properties: "x,y" }
            }

            delegate: Item {
                width: grid.cellWidth
                height: grid.cellHeight
                Image {
                    anchors.fill: parent
                    anchors.margins: units.gu(.5)
                    fillMode: Image.PreserveAspectFit
                    source: "file://" + model.filename
                }
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        PopupUtils.open(dialogComponent, root, {filename: model.filename})
                    }
                }
            }
        }
    }

    Component {
        id: dialogComponent
        Dialog {
            id: dialog
            title: i18n.tr("Screenshot options")

            property string filename

            Button {
                text: i18n.tr("Share")
                color: UbuntuColors.blue
                onClicked: {
                    pageStack.push(Qt.resolvedUrl("ContentPeerPickerPage.qml"), {itemName: i18n.tr("Pebble screenshot"), handler: ContentHandler.Share, contentType: ContentType.Pictures, filename: filename })
                    PopupUtils.close(dialog)
                }
            }
            Button {
                text: i18n.tr("Save")
                color: UbuntuColors.green
                onClicked: {
                    pageStack.push(Qt.resolvedUrl("ContentPeerPickerPage.qml"), {itemName: i18n.tr("Pebble screenshot"),handler: ContentHandler.Destination, contentType: ContentType.Pictures, filename: filename })
                    PopupUtils.close(dialog)
                }
            }

            Button {
                text: i18n.tr("Delete")
                color: UbuntuColors.red
                onClicked: {
                    root.pebble.removeScreenshot(filename)
                    PopupUtils.close(dialog)
                }
            }
            Button {
                text: i18n.tr("Cancel")
                onClicked: {
                    PopupUtils.close(dialog)
                }
            }
        }
    }
}