kdevelop: prevent empty dockwidget context menuitems
ClosedPublic

Authored by rjvbb on Nov 22 2017, 4:49 PM.

Details

Summary

This patch prevents dock widgets (toolviews) from having empty items in their context menus. Most the corresponding actions can probably not be represented in menus anyway and are thus unlikely to do anything when triggered through a menu. The average user doesn't know that though.

The patch achieves this by filtering out QActions that would not have a title in IdealDockWidget::contextMenuRequested() but also adds a menu item text to two actions which I think make sense to include in the context menu. (Doing this makes it possible to hide the toolview's toolbar in more situations, gaining a bit of vertical space.)

BUG: 386911

Test Plan

Works as intended on Mac and Linux/X11 .

I understand there may be another way to detect QActions that cannot be represented in menus but haven't yet found such an alternative. Such an alternative could be used in addition to the empty text check which I think should be done as argued in the summary.

Individual plugins can also override IToolViewFactor::contextMenuActions().

Diff Detail

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
rjvbb created this revision.Nov 22 2017, 4:49 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptNov 22 2017, 4:49 PM
kfunk accepted this revision.Nov 22 2017, 5:04 PM

Well, fair enough. I can't think of another solution either.

Please add FIXED-IN: 5.2.1 then feel free to push to 5.2 branch.

This revision is now accepted and ready to land.Nov 22 2017, 5:04 PM
This revision was automatically updated to reflect the committed changes.
mwolff added a subscriber: mwolff.Nov 23 2017, 12:37 PM

wouldn't the actual problem fix be setting proper texts on all actions? this probably is also a usability issue btw. I vote for reverting this patch and adding proper texts to all actions

rjvbb added a comment.Nov 23 2017, 1:08 PM

Take the outline toolview example. There I managed to do this and get a sensible menu entry for the filter widget of the toolview's toolbar. But as Kevin said, not all the concerned QActions can be represented in menus in a way that makes sense and for those the only proper text would be something like "this menu item doesn't do anything (don't ask why)".

I considered proposing to let such entries activate/unhide the toolbar and where relevant move focus to the widget, but there is already a toolbar control menu action.

A real proper fix would be a redesign that separates menu-compatible QActions from those that shouldn't appear in the context menu. Alternatively, implement the plugin method that returns the actions to be put in the context menu. But both fixes boil down to what is done now so I see nothing wrong with applying an equivalent filter at a shared, central location.

kfunk added a comment.Nov 23 2017, 3:03 PM

wouldn't the actual problem fix be setting proper texts on all actions? this probably is also a usability issue btw. I vote for reverting this patch and adding proper texts to all actions

You can still set the text propery of an action where needed. They're just hidden by default now (which makes sense, since showing a blank line in the menu doesn't help either).

This patch aims at hiding certain widget actions which are not representable at all in a menu. One example: The search line edit in the problems tool view.