Icon choosing in kedittoolbar

David Faure faure at kde.org
Thu Apr 29 15:44:19 BST 2004


On Thursday 29 April 2004 16:12, Andras Mantia wrote:
> This is how they are created (in quanta.cpp,
> QuantaApp::slotLoadToolbarFile(const KURL& url)):
>     if (! actionCollection()->action(actionName))
>     {
>       TagAction *tagAction = new TagAction(&el, actionCollection() );
> 	...
>     }

OK so this action is in the actionCollection of the _mainwindow_,
not of the right kxmlguiclient.
You create other xmlguiclients and add them to the factory yourself,
BUT you don't use the xmlgui mechanism, you plug the actions by hand!
No wonder kedittoolbar is confused....

From quanta.cpp:

   for (uint i = 0; i < nodeList.count(); i++)
   {
     action = actionCollection()->action(nodeList.item(i).cloneNode().toElement().attribute("name") );
     if (action)
     {
       toolbarGUI->actionCollection()->insert(action);
       action->plug(menu);
     }
   }
   m_tagsMenu->insertItem(name,menu);
   p_toolbar->menu = menu;

   factory()->addClient(toolbarGUI);

Plugging actions by hand into an xmlgui is a very bad idea IMHO.
You should let the GUI merging do its work - but for that you need to create
the actions with the right parent and let addClient handle the plugging.

The actionCollection()->insert() above is a nice try, but a bad idea :)
  (it's like having a QObject with two parents....)
Hmm in fact it looks like it doesn't work, since I see 0 actions in the
guiclient's collection.
Isn't it possible to create the action with the right action collection as parent in the first place?

-- 
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