Commit 2a80911b authored by Nate Graham's avatar Nate Graham
Browse files

[applets/devicenotifier] Improve default actions for removable devices

Right now for removable devices, the default action is either "Mount" or
"Unmount" (depending on whether you have automount turned on or off).

For the common case where you want to mount a device and then
immediately view its contents in the file manager, this requires a
two-step process: mount it, then expand the expandable list item, then
click on "Show in File Manager.

This commit changes the "Mount" action to "Mount and Open", collapsing
the three-step action into just one.

For people who really do want to just mount a disk without opening it, a
"Mount" action that does not also open the file manager is added to the
expandable section of the list item.

Additionally, because the "Show in File Manager" action that's already
in the expandable section of the list item would be redundant with the
one used as the primary action, it is now only shown for mounted

This mirrors a similar proposed change in the Plasma Vault applet:
parent 78539c49
......@@ -120,14 +120,14 @@ PlasmaExtras.ExpandableListItem {
var service
var operationName
var operation
if (![udi].Removable) {
var wasMounted = isMounted;
if (![udi].Removable || !isMounted) {
service = hpSource.serviceForSource(udi);
operation = service.operationDescription('invokeAction');
operation.predicate = "test-predicate-openinwindow.desktop";
} else {
var wasMounted = isMounted;
service = sdSource.serviceForSource(udi);
operation = service.operationDescription(wasMounted ? "unmount" : "mount");
operation = service.operationDescription("unmount");
if (wasMounted) {
......@@ -195,7 +195,7 @@ PlasmaExtras.ExpandableListItem {
if (![udi].Removable) {
return "document-open-folder"
} else {
return isMounted ? "media-eject" : "media-mount"
return isMounted ? "media-eject" : "document-open-folder"
text: {
......@@ -204,7 +204,7 @@ PlasmaExtras.ExpandableListItem {
} else {
var types = model["Device Types"];
if (!isMounted) {
return i18n("Mount")
return i18n("Mount and Open")
} else if (types && types.indexOf("OpticalDisc") !== -1) {
return i18n("Eject")
} else {
......@@ -224,6 +224,15 @@ PlasmaExtras.ExpandableListItem {
delegate: QQC2.Action {
text: modelData.text modelData.icon
// We only want to show the "Show in file manager" action for
// mounted removable disks (for everything else, this action is
// already the primary one shown on the list item)
enabled: {
if (modelData.predicate != "test-predicate-openinwindow.desktop") {
return true;
return[udi].Removable && deviceItem.isMounted;
onTriggered: {
var service = hpSource.serviceForSource(udi);
var operation = service.operationDescription('invokeAction');
......@@ -234,4 +243,25 @@ PlasmaExtras.ExpandableListItem {
onObjectAdded: contextualActionsModel.push(object)
// "Mount" action that does not open it in the file manager
QQC2.Action {
id: mountWithoutOpeningAction
text: i18n("Mount") "media-mount"
// Only show for unmounted removable devices
enabled:[udi].Removable && !deviceItem.isMounted
onTriggered: {
var service = sdSource.serviceForSource(udi);
var operation = service.operationDescription("mount");
Component.onCompleted: {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment