Changeset View
Changeset View
Standalone View
Standalone View
applets/devicenotifier/package/contents/ui/devicenotifier.qml
Show All 37 Lines | 37 | property string devicesType: { | |||
---|---|---|---|---|---|
38 | if (plasmoid.configuration.allDevices) { | 38 | if (plasmoid.configuration.allDevices) { | ||
39 | return "all" | 39 | return "all" | ||
40 | } else if (plasmoid.configuration.removableDevices) { | 40 | } else if (plasmoid.configuration.removableDevices) { | ||
41 | return "removable" | 41 | return "removable" | ||
42 | } else { | 42 | } else { | ||
43 | return "nonRemovable" | 43 | return "nonRemovable" | ||
44 | } | 44 | } | ||
45 | } | 45 | } | ||
46 | property string expandedDevice | | |||
47 | property string popupIcon: "device-notifier" | 46 | property string popupIcon: "device-notifier" | ||
48 | 47 | | |||
49 | property bool itemClicked: false | 48 | property bool itemClicked: false | ||
50 | property int currentIndex: -1 | 49 | property int currentIndex: -1 | ||
51 | property var connectedRemovables: [] | 50 | property var connectedRemovables: [] | ||
52 | property int mountedRemovables: 0 | 51 | property int mountedRemovables: 0 | ||
53 | 52 | | |||
54 | // QTBUG-50380: As soon as the item gets removed from the model, all of ListView's | 53 | // QTBUG-50380: As soon as the item gets removed from the model, all of ListView's | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 118 | onSourceAdded: { | |||
120 | disconnectSource(source); | 119 | disconnectSource(source); | ||
121 | connectSource(source); | 120 | connectSource(source); | ||
122 | last = source; | 121 | last = source; | ||
123 | processLastDevice(true); | 122 | processLastDevice(true); | ||
124 | if (data[source].Removable) { | 123 | if (data[source].Removable) { | ||
125 | devicenotifier.connectedRemovables.push(source); | 124 | devicenotifier.connectedRemovables.push(source); | ||
126 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | 125 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | ||
127 | } | 126 | } | ||
127 | devicenotifier.popupIcon = "preferences-desktop-notification"; | ||||
128 | expandTimer.restart(); | ||||
129 | popupIconTimer.restart() | ||||
128 | } | 130 | } | ||
129 | 131 | | |||
130 | onSourceRemoved: { | 132 | onSourceRemoved: { | ||
131 | if (expandedDevice == source) { | | |||
132 | expandedDevice = ""; | | |||
133 | } | | |||
134 | disconnectSource(source); | 133 | disconnectSource(source); | ||
135 | var index = devicenotifier.connectedRemovables.indexOf(source); | 134 | var index = devicenotifier.connectedRemovables.indexOf(source); | ||
136 | if (index >= 0) { | 135 | if (index >= 0) { | ||
137 | devicenotifier.connectedRemovables.splice(index, 1); | 136 | devicenotifier.connectedRemovables.splice(index, 1); | ||
138 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | 137 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | ||
139 | } | 138 | } | ||
140 | } | 139 | } | ||
141 | 140 | | |||
Show All 27 Lines | 159 | function isViableDevice(udi) { | |||
169 | 168 | | |||
170 | return (devicesType === "removable" && device.Removable) | 169 | return (devicesType === "removable" && device.Removable) | ||
171 | || (devicesType === "nonRemovable" && !device.Removable); | 170 | || (devicesType === "nonRemovable" && !device.Removable); | ||
172 | } | 171 | } | ||
173 | 172 | | |||
174 | function processLastDevice(expand) { | 173 | function processLastDevice(expand) { | ||
175 | if (last) { | 174 | if (last) { | ||
176 | if (isViableDevice(last)) { | 175 | if (isViableDevice(last)) { | ||
177 | if (expand && hpSource.data[last].added) { | | |||
178 | expandDevice(last); | | |||
179 | } | | |||
180 | last = ""; | 176 | last = ""; | ||
181 | } | 177 | } | ||
182 | } | 178 | } | ||
183 | } | 179 | } | ||
184 | } | 180 | } | ||
185 | 181 | | |||
186 | PlasmaCore.SortFilterModel { | 182 | PlasmaCore.SortFilterModel { | ||
187 | id: filterModel | 183 | id: filterModel | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 243 | Plasmoid.onExpandedChanged: { | |||
248 | popupEventSlot(plasmoid.expanded); | 244 | popupEventSlot(plasmoid.expanded); | ||
249 | } | 245 | } | ||
250 | 246 | | |||
251 | function popupEventSlot(popped) { | 247 | function popupEventSlot(popped) { | ||
252 | if (!popped) { | 248 | if (!popped) { | ||
253 | // reset the property that lets us remember if an item was clicked | 249 | // reset the property that lets us remember if an item was clicked | ||
254 | // (versus only hovered) for autohide purposes | 250 | // (versus only hovered) for autohide purposes | ||
255 | devicenotifier.itemClicked = true; | 251 | devicenotifier.itemClicked = true; | ||
256 | expandedDevice = ""; | | |||
257 | devicenotifier.currentIndex = -1; | 252 | devicenotifier.currentIndex = -1; | ||
258 | } | 253 | } | ||
259 | } | 254 | } | ||
260 | 255 | | |||
261 | function expandDevice(udi) { | | |||
262 | if (hpSource.data[udi]["actions"].length > 1) { | | |||
263 | expandedDevice = udi | | |||
264 | } | | |||
265 | | ||||
266 | // reset the property that lets us remember if an item was clicked | | |||
267 | // (versus only hovered) for autohide purposes | | |||
268 | devicenotifier.itemClicked = false; | | |||
269 | | ||||
270 | devicenotifier.popupIcon = "preferences-desktop-notification"; | | |||
271 | //plasmoid.expanded = true; | | |||
272 | expandTimer.restart(); | | |||
273 | popupIconTimer.restart() | | |||
274 | } | | |||
275 | | ||||
276 | function isMounted(udi) { | 256 | function isMounted(udi) { | ||
277 | if (!sdSource.data[udi]) { | 257 | if (!sdSource.data[udi]) { | ||
278 | return false; | 258 | return false; | ||
279 | } | 259 | } | ||
280 | 260 | | |||
281 | var types = sdSource.data[udi]["Device Types"]; | 261 | var types = sdSource.data[udi]["Device Types"]; | ||
282 | if (types.indexOf("Storage Access") >= 0) { | 262 | if (types.indexOf("Storage Access") >= 0) { | ||
283 | return sdSource.data[udi]["Accessible"]; | 263 | return sdSource.data[udi]["Accessible"]; | ||
Show All 23 Lines |