blob: ecc3d78934ed6ed0bba6815c0c915fbd0c8fa48f (
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
import QtQuick 2.0
import QtQml 2.1
import Sailfish.Silica 1.0
import QtDocGallery 5.0
import Sailfish.Pickers 1.0
Dialog {
id: installAppPage
property string selectedUuid;
Component {
id: appPicker
PickerDialog {
id: appPickerDialog
title: qsTr("Select App files")
SilicaListView {
id: listView
currentIndex: -1
anchors.fill: parent
model: documentModel.model
DocumentModel {
id: documentModel
selectedModel: _selectedModel
contentFilter: GalleryStartsWithFilter {
property: "filePath"
value: StandardPaths.documents + "/../Downloads"
}
}
header: PageHeader {
id: pageHeader
title: appPickerDialog.title
}
delegate: DocumentItem {
id: documentItem
baseName: Theme.highlightText(documentModel.baseName(model.fileName), documentModel.filter, Theme.highlightColor)
extension: Theme.highlightText(documentModel.extension(model.fileName), documentModel.filter, Theme.highlightColor)
selected: model.selected
ListView.onAdd: AddAnimation { target: documentItem; duration: _animationDuration }
ListView.onRemove: RemoveAnimation { target: documentItem; duration: _animationDuration }
onClicked: documentModel.updateSelected(index, !selected)
}
VerticalScrollDecorator {}
}
}
}
SilicaListView {
id: appList
anchors.fill: parent
header: DialogHeader {
title: qsTr("Install App")
defaultAcceptText: qsTr("Install")
}
VerticalScrollDecorator { flickable: flickable }
PullDownMenu {
MenuItem {
text: qsTr("Add App file...")
onClicked: {
var addApps = function() {
for(var i=0; i < picker.selectedContent.count; ++i) {
var appPath = picker.selectedContent.get(i).filePath
console.log(appPath)
pebbled.registerAppFile(appPath)
}
picker.selectedContentChanged.disconnect(addApps)
}
var picker = pageStack.push(appPicker)
picker.selectedContentChanged.connect(addApps)
}
}
}
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
}
|