summaryrefslogtreecommitdiff
path: root/app/qml/pages/InstallAppDialog.qml
blob: debb48ffa96001a57f6330681f4b72a07fd10a42 (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
import QtQuick 2.0
import QtQml 2.1
import Sailfish.Silica 1.0

Dialog {
    id: installAppPage

    property string selectedUuid;

    SilicaListView {
        id: appList
        anchors.fill: parent

        header: DialogHeader {
           title: qsTr("Install app")
           defaultAcceptText: qsTr("Install")
        }

        VerticalScrollDecorator { flickable: flickable }

        currentIndex: -1

        delegate: ListItem {
            id: appDelegate
            contentHeight: modelData.isLocal ? Theme.itemSizeSmall : 0

            visible: modelData.isLocal

            property string uuid: modelData.uuid
            property bool alreadyInstalled: pebbled.isAppInstalled(uuid)

            Item {
                id: appIcon
                width: Theme.itemSizeSmall
                height: Theme.itemSizeSmall

                anchors {
                    top: parent.top
                    left: parent.left
                    leftMargin: Theme.paddingLarge
                }

                Image {
                    id: appImage
                    anchors.centerIn: parent
                    source: appDelegate.visible ? "image://pebble-app-icon/" + uuid : ""
                    scale: 2
                }
            }

            Label {
                id: appName
                anchors {
                    left: appIcon.right
                    leftMargin: Theme.paddingMedium
                    right: parent.right
                    rightMargin: Theme.paddingLarge
                    verticalCenter: parent.verticalCenter
                }
                text: modelData.longName
                color: appDelegate.highlighted ? Theme.highlightColor : Theme.primaryColor
            }

            onClicked: {
                appList.currentIndex = index
                if (!alreadyInstalled) {
                    selectedUuid = uuid
                    accept();
                }
            }
        }

        model: pebbled.allApps
    }

    canAccept: appList.currentIndex >= 0 && !appList.currentItem.alreadyInstalled
}