Changeset View
Changeset View
Standalone View
Standalone View
applets/devicenotifier/package/contents/ui/devicenotifier.qml
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 42 | } else { | |||
---|---|---|---|---|---|
43 | return "nonRemovable" | 43 | return "nonRemovable" | ||
44 | } | 44 | } | ||
45 | } | 45 | } | ||
46 | property string expandedDevice | 46 | property string expandedDevice | ||
47 | property string popupIcon: "device-notifier" | 47 | property string popupIcon: "device-notifier" | ||
48 | 48 | | |||
49 | property bool itemClicked: false | 49 | property bool itemClicked: false | ||
50 | property int currentIndex: -1 | 50 | property int currentIndex: -1 | ||
51 | property var connectedRemovables: [] | ||||
ngraham: mountedRemouvables -> mountedRemovables (and change all other instances, obviously) | |||||
thsurrel: I put too much French into this one ;) | |||||
En Anglais, les mots n'utilisent pas la lettre «u» aussi souvent qu'en Français. :) ngraham: En Anglais, les mots n'utilisent pas la lettre «u» aussi souvent qu'en Français. :) | |||||
thsurrel: Je ne savais pas que tu parlais français ! 👍 | |||||
Can this be done more declaratively? I'm not a huge fan of having the delegate (which may not even be created in case it is scrolled out of view) programmatically do this. I would at least opt for updating it in onDataChanged of the DataSource or onRowsAdded/onRowsRemoved or something along the lines of that broulik: Can this be done more declaratively? I'm not a huge fan of having the delegate (which may not… | |||||
52 | property int mountedRemovables: 0 | ||||
51 | 53 | | |||
52 | // QTBUG-50380: As soon as the item gets removed from the model, all of ListView's | 54 | // QTBUG-50380: As soon as the item gets removed from the model, all of ListView's | ||
53 | // properties (count, contentHeight) pretend the delegate doesn't exist anymore | 55 | // properties (count, contentHeight) pretend the delegate doesn't exist anymore | ||
54 | // causing our "No devices" heading to overlap with the remaining device | 56 | // causing our "No devices" heading to overlap with the remaining device | ||
55 | property int pendingDelegateRemoval: 0 | 57 | property int pendingDelegateRemoval: 0 | ||
56 | 58 | | |||
57 | Plasmoid.switchWidth: units.gridUnit * 10 | 59 | Plasmoid.switchWidth: units.gridUnit * 10 | ||
58 | Plasmoid.switchHeight: units.gridUnit * 10 | 60 | Plasmoid.switchHeight: units.gridUnit * 10 | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 110 | PlasmaCore.DataSource { | |||
111 | connectedSources: hpSource.sources | 113 | connectedSources: hpSource.sources | ||
112 | interval: 0 | 114 | interval: 0 | ||
113 | property string last | 115 | property string last | ||
114 | onSourceAdded: { | 116 | onSourceAdded: { | ||
115 | disconnectSource(source); | 117 | disconnectSource(source); | ||
116 | connectSource(source); | 118 | connectSource(source); | ||
117 | last = source; | 119 | last = source; | ||
118 | processLastDevice(true); | 120 | processLastDevice(true); | ||
121 | if (data[source].Removable) { | ||||
122 | devicenotifier.connectedRemovables.push(source); | ||||
123 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | ||||
broulik: This is for having the bindings refresh, right? | |||||
thsurrel: Yes indeed. Any better ways ? | |||||
Should be fine, I thought one needed to put it in a variable first var removables = devicenotifier.connectedRemovables; removables.push(source); devicenotifier.connectedRemovables = removables; broulik: Should be fine, I thought one needed to put it in a variable first
```
var removables =… | |||||
124 | } | ||||
119 | } | 125 | } | ||
120 | 126 | | |||
121 | onSourceRemoved: { | 127 | onSourceRemoved: { | ||
122 | if (expandedDevice == source) { | 128 | if (expandedDevice == source) { | ||
123 | expandedDevice = ""; | 129 | expandedDevice = ""; | ||
124 | } | 130 | } | ||
125 | disconnectSource(source); | 131 | disconnectSource(source); | ||
132 | var index = devicenotifier.connectedRemovables.indexOf(source); | ||||
133 | if (index >= 0) { | ||||
134 | devicenotifier.connectedRemovables.splice(index, 1); | ||||
135 | devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; | ||||
136 | } | ||||
126 | } | 137 | } | ||
127 | 138 | | |||
128 | onDataChanged: { | 139 | onDataChanged: { | ||
129 | processLastDevice(true); | 140 | processLastDevice(true); | ||
141 | var counter = 0; | ||||
142 | for (var i = 0; i < devicenotifier.connectedRemovables.length; i++) { | ||||
143 | if (isMounted(devicenotifier.connectedRemovables[i])) { | ||||
144 | counter++; | ||||
145 | } | ||||
146 | } | ||||
147 | if (counter != devicenotifier.mountedRemovables) { | ||||
148 | devicenotifier.mountedRemovables = counter; | ||||
149 | } | ||||
130 | } | 150 | } | ||
131 | 151 | | |||
132 | onNewData: { | 152 | onNewData: { | ||
133 | last = sourceName; | 153 | last = sourceName; | ||
134 | processLastDevice(false); | 154 | processLastDevice(false); | ||
135 | } | 155 | } | ||
136 | 156 | | |||
137 | function isViableDevice(udi) { | 157 | function isViableDevice(udi) { | ||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
mountedRemouvables -> mountedRemovables (and change all other instances, obviously)