Changeset View
Changeset View
Standalone View
Standalone View
applets/devicenotifier/package/contents/ui/DeviceItem.qml
Show All 29 Lines | 29 | MouseArea { | |||
---|---|---|---|---|---|
30 | id: deviceItem | 30 | id: deviceItem | ||
31 | 31 | | |||
32 | property string udi | 32 | property string udi | ||
33 | property alias icon: deviceIcon.source | 33 | property alias icon: deviceIcon.source | ||
34 | property alias deviceName: deviceLabel.text | 34 | property alias deviceName: deviceLabel.text | ||
35 | property string emblemIcon | 35 | property string emblemIcon | ||
36 | property int state | 36 | property int state | ||
37 | 37 | | |||
38 | property bool mounted | 38 | property bool mounted: false | ||
broulik: Isn't this overridden anyway? It's also the default anyway | |||||
39 | property bool expanded: devicenotifier.expandedDevice == udi | 39 | property bool expanded: devicenotifier.expandedDevice == udi | ||
40 | property alias percentUsage: freeSpaceBar.value | 40 | property alias percentUsage: freeSpaceBar.value | ||
41 | property string freeSpaceText | 41 | property string freeSpaceText | ||
42 | 42 | | |||
43 | signal actionTriggered | 43 | signal actionTriggered | ||
44 | 44 | | |||
45 | property alias actionIcon: actionButton.iconName | 45 | property alias actionIcon: actionButton.iconName | ||
46 | property alias actionToolTip: actionButton.tooltip | 46 | property alias actionToolTip: actionButton.tooltip | ||
Show All 35 Lines | 80 | if (actions.length === 1) { | |||
82 | var operation = service.operationDescription("invokeAction") | 82 | var operation = service.operationDescription("invokeAction") | ||
83 | operation.predicate = actions[0].predicate | 83 | operation.predicate = actions[0].predicate | ||
84 | service.startOperationCall(operation) | 84 | service.startOperationCall(operation) | ||
85 | } else { | 85 | } else { | ||
86 | devicenotifier.expandedDevice = (expanded ? "" : udi) | 86 | devicenotifier.expandedDevice = (expanded ? "" : udi) | ||
87 | } | 87 | } | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | function unMount() { | ||||
broulik: `unmount`? | |||||
91 | if (mounted) { | ||||
92 | actionTriggered(); | ||||
broulik: Can we assume "action" is always unmount? | |||||
If the device is removable and mounted, than the action can only be unmounting, yes. thsurrel: If the device is removable and mounted, than the action can only be unmounting, yes. | |||||
93 | } | ||||
94 | } | ||||
95 | | ||||
96 | ListView.onAdd: { | ||||
It looks like you instead want to use Connections { target: unmountAll onClicked: ... } broulik: It looks like you instead want to use
```
Connections {
target: unmountAll
onClicked: .. | |||||
97 | if (model["Removable"]) { | ||||
98 | unmountAll.clicked.connect(unMount) | ||||
99 | } | ||||
100 | } | ||||
101 | | ||||
90 | // this keeps the delegate around for 5 seconds after the device has been | 102 | // this keeps the delegate around for 5 seconds after the device has been | ||
91 | // removed in case there was a message, such as "you can now safely remove this" | 103 | // removed in case there was a message, such as "you can now safely remove this" | ||
92 | ListView.onRemove: { | 104 | ListView.onRemove: { | ||
93 | if (devicenotifier.expandedDevice == udi) { | 105 | if (devicenotifier.expandedDevice == udi) { | ||
94 | devicenotifier.expandedDevice = "" | 106 | devicenotifier.expandedDevice = "" | ||
95 | } | 107 | } | ||
96 | 108 | | |||
97 | if (deviceItem.hasMessage) { | 109 | if (deviceItem.hasMessage) { | ||
98 | ListView.delayRemove = true | 110 | ListView.delayRemove = true | ||
99 | keepDelegateTimer.restart() | 111 | keepDelegateTimer.restart() | ||
100 | 112 | | |||
101 | statusMessage.opacity = 1 // HACK seems the Column animation breaksf | 113 | statusMessage.opacity = 1 // HACK seems the Column animation breaksf | ||
102 | freeSpaceBar.visible = false | 114 | freeSpaceBar.visible = false | ||
103 | actionButton.visible = false | 115 | actionButton.visible = false | ||
104 | 116 | | |||
105 | ++devicenotifier.pendingDelegateRemoval // QTBUG-50380 | 117 | ++devicenotifier.pendingDelegateRemoval // QTBUG-50380 | ||
106 | } | 118 | } | ||
119 | | ||||
120 | if (model["Removable"]) { | ||||
Careful about accessing model properties after the item has been removed from the model, I don't think this works? broulik: Careful about accessing model properties after the item has been removed from the model, I… | |||||
121 | unmountAll.clicked.disconnect(unMount) | ||||
122 | } | ||||
107 | } | 123 | } | ||
108 | 124 | | |||
109 | Timer { | 125 | Timer { | ||
110 | id: keepDelegateTimer | 126 | id: keepDelegateTimer | ||
111 | interval: 3000 // same interval as the auto hide / passive timer | 127 | interval: 3000 // same interval as the auto hide / passive timer | ||
112 | onTriggered: { | 128 | onTriggered: { | ||
113 | deviceItem.ListView.delayRemove = false | 129 | deviceItem.ListView.delayRemove = false | ||
114 | // otherwise the last message will show again when this device reappears | 130 | // otherwise the last message will show again when this device reappears | ||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |
Isn't this overridden anyway? It's also the default anyway