Bug 466115 - Custom horizontal lines/bars in context menu no longer possible
Summary: Custom horizontal lines/bars in context menu no longer possible
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: git master
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2023-02-20 00:30 UTC by schickele
Modified: 2024-05-11 11:07 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Context sub-menu with and without horizontal lines in Dolphin 19.12.3 and 21.12.3 (75.70 KB, image/png)
2023-02-20 00:30 UTC, schickele
Details
Before fix (240.30 KB, image/jpeg)
2024-04-07 20:22 UTC, Robert-André Mauchin
Details
After fix (287.40 KB, image/jpeg)
2024-04-07 20:22 UTC, Robert-André Mauchin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schickele 2023-02-20 00:30:18 UTC
Created attachment 156516 [details]
Context sub-menu with and without horizontal lines in Dolphin 19.12.3 and 21.12.3

For as long as I can remember, a personalized service sub-menu in Dolphin could contain horizontal lines to separate items. To do so, you had to add _SEPARATOR_ in the semicolon separated action list of your service file, for example

Actions=action_a;action_b;_SEPARATOR_;action_c;action_d;_SEPARATOR_;action_e;

This feature disappeared between Dolphin 19.12.3 (Kubuntu 20.04) and Dolphin 21.12.3 (Kubuntu 22.04). The code above does not produce lines/bars anymore (see attachment). I was not able to pinpoint the exact release that came with the regression.

These horizontal lines are very handy and quite frankly irreplaceable when it comes to add visual clarity to custom sub-menus, especially long ones.

My guess is that this is not a conscious design choice but rather a side-effect of some code optimization. That's why I'm reporting this as minor bug. I would love to see them back and I suspect others would too.
Comment 1 alan.n.davies 2023-10-09 14:13:30 UTC
It seems that actions now get sorted by the action ID.  Because you have to specify the separator as _SEPARATOR_, it begins with an underscore, which comes after all the uppers letters in ASCII order, but before the lowercase letters.  I think KDE then ignores any separators that appear at the start or end of the menu.

If you only need a single separator, you can ID your actions like this, which will fix the issue (note the uppercase `A` in the IDs of the actions before the separator)...

Actions=Action_a;Action_b;_SEPARATOR_;action_c;action_d;action_e;

Unfortunately, you cannot have multiple separators, as they will all get ordered into the same position.

I'm not sure why KDE is now ordering the actions by action ID, it seems very strange.  The actions used to appear in the order they appeared in the action list.  Ordering by action ID is completely arbitrary.  If you are trying to make the menus more usable by putting stuff in alphabetical order, you should be ordering by the "Name" parameter, not the ID.  The ID does not take any localization into account, and anyway, you may not want stuff in alphabetical order anyway.
Comment 2 schickele 2023-10-09 15:32:37 UTC
Thank a lot for these clarifications. You're perfectly right. I've noticed the new alphabetical sorting too, but failed to make the connection. Having one separator is better than none (thanks for that trick too), but I'm still hoping Dolphin will let us organize sub-menus with multiple separators again.
Comment 3 Ignacio Serantes 2024-04-07 18:17:33 UTC
In Dolphin 24.02.1 this behavior is worst because service menu is ordered using name instead of action name.
Comment 4 Robert-André Mauchin 2024-04-07 20:22:10 UTC
Created attachment 168265 [details]
Before fix
Comment 5 Robert-André Mauchin 2024-04-07 20:22:29 UTC
Created attachment 168266 [details]
After fix
Comment 6 Robert-André Mauchin 2024-04-07 20:23:26 UTC
Fix proposal:

https://invent.kde.org/frameworks/kio/-/merge_requests/1608


Commit 33785332 has purposely ordered actions by their name. However, this break separators in service context menus.

For example:

Actions=progressive;optimize;SEPARATOR;compress_50;compress_70;compress_75

The separator would end up at the end of the list:

Actions=compress_50;compress_70;compress_75;progressive|optimize;SEPARATOR

And since the logic check is the separator is the last item to add it:

!actions.last()->isSeparator()

separators basically disappear from service context menus.

The purpose of this commit is then to create groups of actions between each separator. Actions will be sorted withing these groups, but it will keep service menus original organisation.
Comment 7 schickele 2024-04-07 20:55:01 UTC
Thanks a lot, Monsieur Mauchin! I hope your fix can find its way to master and to us soon.
Comment 8 Ignacio Serantes 2024-04-07 21:36:18 UTC
(In reply to Robert-André Mauchin from comment #6)
> Fix proposal:
> 
> https://invent.kde.org/frameworks/kio/-/merge_requests/1608
> 
> 
> Commit 33785332 has purposely ordered actions by their name. However, this
> break separators in service context menus.
> 
> For example:
> 
> Actions=progressive;optimize;SEPARATOR;compress_50;compress_70;compress_75
> 
> The separator would end up at the end of the list:
> 
> Actions=compress_50;compress_70;compress_75;progressive|optimize;SEPARATOR
> 
> And since the logic check is the separator is the last item to add it:
> 
> !actions.last()->isSeparator()
> 
> separators basically disappear from service context menus.
> 
> The purpose of this commit is then to create groups of actions between each
> separator. Actions will be sorted withing these groups, but it will keep
> service menus original organisation.

I don't understand the main reason for 33785332 commit, previous behavior, the sort is the one in Actions property, seems the right one behavior for me.
Comment 9 Alexander Lohnau 2024-04-27 15:24:52 UTC
Git commit b154c9d2f4fc86e6efdcf50bd11bba1f4a365033 by Alexander Lohnau, on behalf of Robert-André Mauchin.
Committed on 27/04/2024 at 15:24.
Pushed by alex into branch 'master'.

KFileItemActions: Add logic to order actions between separators

Commit 337853329c61c9cfe5e369acf65a8eca94e5e7fd has purposedly ordered
actions by their name. However, this breaks separators in service context
menus.

For example:

Actions=progressive;optimize;\_SEPARATOR\_;compress_50;compress_70;compress_75

The separator would end up at the end of the list:

Actions=compress_50;compress_70;compress_75;progressive|optimize;\_SEPARATOR\_

And since the logic check if the separator is the last item to add it:

!actions.last()->isSeparator()

separators basically disappear from service context menus.

The purpose of this commit is then to create groups of actions between
each separator. Actions will be sorted within these groups, but it will
keep service menus original order.

M  +47   -18   src/widgets/kfileitemactions.cpp

https://invent.kde.org/frameworks/kio/-/commit/b154c9d2f4fc86e6efdcf50bd11bba1f4a365033
Comment 10 Ignacio Serantes 2024-05-11 11:07:29 UTC
Thank you so much to Robert-André Mauchin for it's fix