Adding actions to KDevelop::ContextMenuExtension after menu is displayed

Maciej Poleski d82ks8djf82msd83hf8sc02lqb5gh5 at gmail.com
Thu Jul 23 00:24:20 UTC 2015


Dnia środa, 22 lipca 2015 17:21:29 piszesz:
> Hi,
> 
> If I add additional actions to KDevelop::ContextMenuExtension after IPlugin::contextMenuExtension(KDevelop::Context* context) finished, then KDevelop crashes. How to add actions to already-displayed context menu?
> 
> Best Regards
> Maciej Poleski

deprecated

How to do that:
1. make placeholder (QAction)
2. add placeholder to ContextMenuExtension on time (in IPlugin::contextMenuExtension() implementation)
3. retain reference to this placeholder

when new actions are ready:
1. take placeholder
2. ask for widgets which embed this placeholder action (QAction::associatedWidgets())
3. take menu from this list
4. add new actions to this menu
5. delete placeholder

other stuff:
- placeholder may contain information to user "wait a moment, there are going to be more options here soon" (but much shorter)
- menu to which placeholder was added may be disposed before list of additional actions is ready
- menu may not be populated with placeholder action at the time new actions are ready (unlikely, can populate ContextMenuExtension instead)
- placeholder may land in other widgets as well
- logic which creates submenus for groups of actions is bypassed - it may be considerable to analyze structure of menu and make submenu if necessary

Best Regards
Maciej Poleski


More information about the KDevelop-devel mailing list