diff --git a/applets/devicenotifier/package/contents/ui/DeviceItem.qml b/applets/devicenotifier/package/contents/ui/DeviceItem.qml --- a/applets/devicenotifier/package/contents/ui/DeviceItem.qml +++ b/applets/devicenotifier/package/contents/ui/DeviceItem.qml @@ -88,6 +88,15 @@ } } + Connections { + target: unmountAll + onClicked: { + if (model["Removable"] && mounted) { + actionTriggered(); + } + } + } + // this keeps the delegate around for 5 seconds after the device has been // removed in case there was a message, such as "you can now safely remove this" ListView.onRemove: { diff --git a/applets/devicenotifier/package/contents/ui/FullRepresentation.qml b/applets/devicenotifier/package/contents/ui/FullRepresentation.qml --- a/applets/devicenotifier/package/contents/ui/FullRepresentation.qml +++ b/applets/devicenotifier/package/contents/ui/FullRepresentation.qml @@ -110,12 +110,22 @@ } } - ColumnLayout { + Item { anchors.fill: parent + PlasmaComponents.ToolButton { + id: unmountAll + visible: devicenotifier.connectedRemovables.length > 1; + anchors.right: parent.right + iconSource: "media-eject" + tooltip: i18n("Click to safely remove all devices") + text: i18n("Remove all") + implicitWidth: minimumWidth + } + PlasmaExtras.ScrollArea { - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill: parent + anchors.top: unmountAll.top ListView { id: notifierDialog diff --git a/applets/devicenotifier/package/contents/ui/devicenotifier.qml b/applets/devicenotifier/package/contents/ui/devicenotifier.qml --- a/applets/devicenotifier/package/contents/ui/devicenotifier.qml +++ b/applets/devicenotifier/package/contents/ui/devicenotifier.qml @@ -48,6 +48,7 @@ property bool itemClicked: false property int currentIndex: -1 + property var connectedRemovables: [] // QTBUG-50380: As soon as the item gets removed from the model, all of ListView's // properties (count, contentHeight) pretend the delegate doesn't exist anymore @@ -116,13 +117,22 @@ connectSource(source); last = source; processLastDevice(true); + if (data[source].Removable) { + devicenotifier.connectedRemovables.push(source); + devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; + } } onSourceRemoved: { if (expandedDevice == source) { expandedDevice = ""; } disconnectSource(source); + var index = devicenotifier.connectedRemovables.indexOf(source); + if (index >= 0) { + devicenotifier.connectedRemovables.splice(index, 1); + devicenotifier.connectedRemovables = devicenotifier.connectedRemovables; + } } onDataChanged: {