How can I remove Kate Part actions from the main toolbar?

Sometimes, developers do not want some actions like copy/paste to appear in the toolbar, as the application looks too cluttered for example.

To remove an action from the toolbar, you have to first lookup its name in the xmlgui file katepartui.rc. To remove the copy action do the following everytime the current view changed:

QWidget* w = mainWindow()->factory()->container("mainToolBar", mainWindow());
if(w && view->actionCollection()->action("edit_copy"))
    view->actionCollection()->action("edit_copy")->unplug(w);

Drawback: The configure dialog “Configure Toolbars” will not work for this specific action anymore, as your code forces a removal of it everytime.