From 8a1217fc0e2746088f796d73e506e9a29eea1a07 Mon Sep 17 00:00:00 2001 From: Eugene Popov Date: Tue, 23 Mar 2021 14:28:59 +0000 Subject: [PATCH] Add action to unmount all devices This patch adds an action to unmount all mounted devices. Also it fixes the issue where an additional header appears if more than one device is mounted. BUG: 434805 --- .../devicenotifier/package/contents/ui/DeviceItem.qml | 9 +++++++++ .../package/contents/ui/devicenotifier.qml | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/applets/devicenotifier/package/contents/ui/DeviceItem.qml b/applets/devicenotifier/package/contents/ui/DeviceItem.qml index f4259a6e1..7aaa011fa 100644 --- a/applets/devicenotifier/package/contents/ui/DeviceItem.qml +++ b/applets/devicenotifier/package/contents/ui/DeviceItem.qml @@ -73,6 +73,15 @@ PlasmaExtras.ExpandableListItem { } } + Connections { + target: plasmoid.action("unmountAllDevices") + function onTriggered() { + if (model["Removable"] && isMounted) { + 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/devicenotifier.qml b/applets/devicenotifier/package/contents/ui/devicenotifier.qml index f4bc400d7..ac7c6cc2b 100644 --- a/applets/devicenotifier/package/contents/ui/devicenotifier.qml +++ b/applets/devicenotifier/package/contents/ui/devicenotifier.qml @@ -235,6 +235,13 @@ Item { Plasmoid.status = PlasmaCore.Types.PassiveStatus; } + plasmoid.setAction("unmountAllDevices", i18n("Remove All"), "media-eject"); + plasmoid.action("unmountAllDevices").visible = Qt.binding(() => { + return devicenotifier.mountedRemovables > 1; + }); + + plasmoid.setActionSeparator("sep0"); + plasmoid.setAction("showRemovableDevices", i18n("Removable Devices"), "drive-removable-media"); devicenotifier.showRemovableDevicesAction = plasmoid.action("showRemovableDevices"); devicenotifier.showRemovableDevicesAction.checkable = true;