[KFileItemActions] Allow specifying the number of selected files required for an action
ClosedPublic

Authored by broulik on Jan 8 2018, 3:04 PM.

Details

Summary

This was mostly prompted by D9698 since Kompare can only compare two files and it makes no sense to offer this option for less or more than that.
It is done as a QStringList so you could specify multiple criteria, e.g. only show for 2 or 4 files.
If the need should arise, this could be made more sophisticated by adding support for e.g. ranges and less than/more than operators, but let's keep it simple for now.

CHANGELOG: KonqPopupMenu/Plugin can now use the X-KDE-RequiredNumberOfUrls key to require a certain number of files to be selected before being shown

Test Plan

Added

X-KDE-RequiredNumberOfUrls=2

to the desktop file, action showed up only when I selected two files.
Also tested 2,4 where it would show up if 2 or 4 files are selected

Older KIO versions would just ignore that key and always show the action, which is fine.

Diff Detail

Repository
R241 KIO
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Jan 8 2018, 3:04 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 8 2018, 3:04 PM
broulik requested review of this revision.Jan 8 2018, 3:04 PM
dfaure accepted this revision.Jan 10 2018, 8:03 AM
This revision is now accepted and ready to land.Jan 10 2018, 8:03 AM
This revision was automatically updated to reflect the committed changes.

+1 This looks like a *very* good idea to me.

How can I fetch this? I want to try it.

I overlooked that this was commited today.
The general question remains: How can I fetch a diff that has not been committed yet?

How can I fetch a diff that has not been committed yet?

It has been :) Either "Download Raw Diff" and then git apply or use arc patch D1234 using arcanist

Just tried it. Great!

If the need should arise, this could be made more sophisticated by adding support for e.g. ranges and less than/more than operators, but let's keep it simple for now.

Yes. E.g. I have a ServiceMenu to concatenate files. So something like this

X-KDE-RequiredNumberOfUrls=2-

would be nice.

juansimon reopened this revision.Mar 5 2020, 12:15 PM
juansimon added a subscriber: juansimon.
Operating System: Arch Linux 
KDE Plasma Version: 5.18.2
KDE Frameworks Version: 5.67.0
Qt Version: 5.14.1

Besides the lack of documentation regarding this and other relevant options for the creation of, for example, services for Dolphin.
The X-KDE-RequiredNumberOfUrls option allows me to set an exact number of occurrences but not a minimum and a maximum or just a minimum, as pointed out by @michaelh.
For example, I want to create an option to move n files to a new sub-folder, but I only want this option to appear if the minimum number of files selected is 2.
Another example, I want to create an option to compress several image files and create a comic book. I want at least 4 images selected for this option to appear.
These 2 examples I have given are real cases that I have recently encountered when switching to KDE.

This revision is now accepted and ready to land.Mar 5 2020, 12:15 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald TranscriptMar 5 2020, 12:15 PM
ngraham closed this revision.Mar 5 2020, 5:36 PM
ngraham added a subscriber: ngraham.

Please file a bug report with your concerns. :)

dfaure added a comment.Mar 6 2020, 9:25 PM

Or upload a patch :)

Please file a bug report with your concerns. :)

Done: https://bugs.kde.org/show_bug.cgi?id=418518 ;-)