KStandardAction::showMenubar() lacks collection->addAction()

David Faure faure at kde.org
Fri Jun 22 13:26:19 BST 2007


On Wednesday 20 June 2007, Christian Esken wrote:
> kstandardaction.cpp looks guilty, as it calls KStandardAction::create() (and this calls collection->addAction() ) for virtually all actions, except showMenubar(), showToolbar() and fullScreen().
> 
> It works, if I call addAction() manually in my application code.
>    KAction *a = KStandardAction::showMenubar( this, SLOT(toggleMenuBar()), actionCollection());
>    actionCollection()->addAction( a->objectName(), a );   # <<< added
> 
> Is this intendend behaviour or a bug?

I think what's happening is that the new way of thinking (create action, then add action to collection)
meant changing too much code, so instead KStandardAction preserved the old behavior: automatically
adding the action to the parent when the parent is a collection. To minimize the porting effort.
So what's "right" depends on whether we're speaking in theory or in practice :-)

Anyhow I agree, kstandardaction should be consistent so please add the missing addAction
calls to the special actions that are missing it.

The documentation of kstandardaction should also mention the automatic addition to the collection, too.

> But it also has to be done for showToolbar() and fullScreen()
Yes.

> , and I wonder why there is a switch case for ShowMenubar in KStandardAction::create(), if it isn't called. 
Historical reasons; initially it was a plain KAction then it became a toggle action with more behavior
(setCheckedState).... hehe and then the setCheckedState calls were removed...
Maybe it can be retrofitted into KStandardAction::create() again :-)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list