Changeset View
Changeset View
Standalone View
Standalone View
applets/devicenotifier/package/contents/ui/FullRepresentation.qml
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com> | 2 | * Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com> | ||
3 | * Copyright 2012 Jacopo De Simoi <wilderkde@gmail.com> | 3 | * Copyright 2012 Jacopo De Simoi <wilderkde@gmail.com> | ||
4 | * Copyright 2014 David Edmundson <davidedmundson@kde.org> | 4 | * Copyright 2014 David Edmundson <davidedmundson@kde.org> | ||
5 | * Copyright 2014 Marco Martin <mart@kde.org> | 5 | * Copyright 2014 Marco Martin <mart@kde.org> | ||
6 | * Copyright 2020 Nate Graham <nate@kde.org> | ||||
6 | * | 7 | * | ||
7 | * | 8 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU Library General Public License as | 10 | * it under the terms of the GNU Library General Public License as | ||
10 | * published by the Free Software Foundation; either version 2 or | 11 | * published by the Free Software Foundation; either version 2 or | ||
11 | * (at your option) any later version. | 12 | * (at your option) any later version. | ||
12 | * | 13 | * | ||
13 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 130 | PlasmaExtras.ScrollArea { | |||
132 | 133 | | |||
133 | ListView { | 134 | ListView { | ||
134 | id: notifierDialog | 135 | id: notifierDialog | ||
135 | focus: true | 136 | focus: true | ||
136 | boundsBehavior: Flickable.StopAtBounds | 137 | boundsBehavior: Flickable.StopAtBounds | ||
137 | 138 | | |||
138 | model: filterModel | 139 | model: filterModel | ||
139 | 140 | | |||
140 | delegate: deviceItem | 141 | delegate: DeviceItem { | ||
142 | udi: DataEngineSource | ||||
143 | } | ||||
141 | highlight: PlasmaComponents.Highlight { } | 144 | highlight: PlasmaComponents.Highlight { } | ||
142 | highlightMoveDuration: 0 | | |||
143 | highlightResizeDuration: 0 | | |||
144 | spacing: units.smallSpacing | | |||
145 | 145 | | |||
146 | currentIndex: devicenotifier.currentIndex | 146 | currentIndex: devicenotifier.currentIndex | ||
147 | 147 | | |||
148 | //this is needed to make SectionScroller actually work | 148 | //this is needed to make SectionScroller actually work | ||
149 | //acceptable since one doesn't have a billion of devices | 149 | //acceptable since one doesn't have a billion of devices | ||
150 | cacheBuffer: 1000 | 150 | cacheBuffer: 1000 | ||
151 | 151 | | |||
152 | section { | 152 | section { | ||
153 | property: "Type Description" | 153 | property: "Type Description" | ||
154 | delegate: Item { | 154 | delegate: Item { | ||
155 | height: childrenRect.height | 155 | height: childrenRect.height | ||
156 | width: notifierDialog.width | 156 | width: notifierDialog.width | ||
157 | PlasmaExtras.Heading { | 157 | PlasmaExtras.Heading { | ||
158 | level: 3 | 158 | level: 3 | ||
159 | opacity: 0.6 | 159 | opacity: 0.6 | ||
160 | text: section | 160 | text: section | ||
161 | } | 161 | } | ||
162 | } | 162 | } | ||
163 | } | 163 | } | ||
164 | } | 164 | } | ||
165 | } | 165 | } | ||
166 | } | 166 | } | ||
167 | | ||||
168 | Component { | | |||
169 | id: deviceItem | | |||
170 | | ||||
171 | DeviceItem { | | |||
172 | width: notifierDialog.width | | |||
173 | udi: DataEngineSource | | |||
174 | Binding on icon { | | |||
175 | when: sdSource.data[udi] !== undefined | | |||
176 | value: sdSource.data[udi].Icon | | |||
177 | } | | |||
178 | Binding on deviceName { | | |||
179 | when: sdSource.data[udi] !== undefined | | |||
180 | value: sdSource.data[udi].Description | | |||
181 | } | | |||
182 | emblemIcon: Emblems && Emblems[0] ? Emblems[0] : "" | | |||
183 | state: sdSource.data[udi] ? sdSource.data[udi].State : 0 | | |||
184 | isRoot: sdSource.data[udi]["File Path"] === "/" | | |||
185 | | ||||
186 | percentUsage: { | | |||
187 | if (!sdSource.data[udi]) { | | |||
188 | return 0 | | |||
189 | } | | |||
190 | var freeSpace = new Number(sdSource.data[udi]["Free Space"]); | | |||
191 | var size = new Number(sdSource.data[udi]["Size"]); | | |||
192 | var used = size-freeSpace; | | |||
193 | return used*100/size; | | |||
194 | } | | |||
195 | freeSpaceText: sdSource.data[udi] && sdSource.data[udi]["Free Space Text"] ? sdSource.data[udi]["Free Space Text"] : "" | | |||
196 | | ||||
197 | actionIcon: mounted ? "media-eject" : "media-mount" | | |||
198 | actionVisible: model["Device Types"].indexOf("Portable Media Player") === -1 | | |||
199 | actionToolTip: { | | |||
200 | var types = model["Device Types"]; | | |||
201 | if (!mounted) { | | |||
202 | return i18n("Click to access this device from other applications.") | | |||
203 | } else if (types && types.indexOf("OpticalDisc") !== -1) { | | |||
204 | return i18n("Click to eject this disc.") | | |||
205 | } else { | | |||
206 | return i18n("Click to safely remove this device.") | | |||
207 | } | | |||
208 | } | | |||
209 | mounted: devicenotifier.isMounted(udi) | | |||
210 | | ||||
211 | onActionTriggered: { | | |||
212 | var operationName = mounted ? "unmount" : "mount"; | | |||
213 | var service = sdSource.serviceForSource(udi); | | |||
214 | var operation = service.operationDescription(operationName); | | |||
215 | service.startOperationCall(operation); | | |||
216 | } | | |||
217 | property int operationResult: (model["Operation result"]) | | |||
218 | | ||||
219 | onOperationResultChanged: { | | |||
220 | if (operationResult == 1) { | | |||
221 | devicenotifier.popupIcon = "dialog-ok" | | |||
222 | popupIconTimer.restart() | | |||
223 | } else if (operationResult == 2) { | | |||
224 | devicenotifier.popupIcon = "dialog-error" | | |||
225 | popupIconTimer.restart() | | |||
226 | } | | |||
227 | } | | |||
228 | Behavior on height { NumberAnimation { duration: units.shortDuration } } | | |||
229 | } | | |||
230 | } | | |||
231 | } | 167 | } |