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 @@ -35,7 +35,7 @@ property string emblemIcon property int state - property bool mounted + property bool mounted: false property bool expanded: devicenotifier.expandedDevice == udi property alias percentUsage: freeSpaceBar.value property string freeSpaceText @@ -87,6 +87,18 @@ } } + function unMount() { + if (mounted) { + actionTriggered(); + } + } + + ListView.onAdd: { + if (model["Removable"]) { + unmountAll.clicked.connect(unMount) + } + } + // 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: { @@ -104,6 +116,10 @@ ++devicenotifier.pendingDelegateRemoval // QTBUG-50380 } + + if (model["Removable"]) { + unmountAll.clicked.disconnect(unMount) + } } Timer { 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,21 @@ } } - ColumnLayout { + Item { anchors.fill: parent + PlasmaComponents.ToolButton { + id: unmountAll + enabled: true + visible: devicenotifier.mountedRemouvables.length > 0; + anchors.right: parent.right + iconSource: "media-eject" + tooltip: i18n("Click to safely remove all devices") + } + PlasmaExtras.ScrollArea { - Layout.fillWidth: true - Layout.fillHeight: true + anchors.fill: parent + anchors.top: unmountAll.top ListView { id: notifierDialog @@ -188,6 +197,19 @@ } mounted: devicenotifier.isMounted(udi) + onMountedChanged: { + if (sdSource.data[udi]["Removable"]) { + var index = devicenotifier.mountedRemouvables.indexOf(udi); + if (mounted && index < 0) { + devicenotifier.mountedRemouvables.push(udi); + devicenotifier.mountedRemouvables = devicenotifier.mountedRemouvables; + } else if (!mounted && index >= 0) { + devicenotifier.mountedRemouvables.splice(index, 1); + devicenotifier.mountedRemouvables = devicenotifier.mountedRemouvables; + } + } + } + onActionTriggered: { var operationName = mounted ? "unmount" : "mount"; var service = sdSource.serviceForSource(udi); 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 mountedRemouvables: [] // 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