KXMLGUI - User definable toolbars and actions

Milian Wolff mail at milianw.de
Mon Jun 14 17:30:57 BST 2010


On Monday, 14. June 2010 18:01:45 Andras Mantia wrote:
> On Monday 14 June 2010, Andreas Pakulat wrote:
> > How did Quanta do this in KDE3? I mean xmlgui isn't a KDE4 feature,
> > its been in there in KDE3 times as well and there's not been that
> > many changes either.
> 
> It used XMLGUI. It is not static only, you can modify the UI
> dynamically. After all plugins do it all the time.
>  When a toolbar file (an XML file, similar to the xmlgui rc files) is
> loaded, a new KXmlGuiClient (based) object is created and added to the
> application's guiFactory. Now when a new client is added, the
> createContainer() method is called, where depending on the  (XML)
> element that is processed from the GUI file, you can create your own
> widgets. This part was used to put a KTabWidget inside a toolbar and
> here was some magic, in the sense the code you see is like that because
> tests shown that works the best.
>  In the KDE4 port it is all in the plugins/usertoolbars. For KDE4 I even
> did two implementations:
> - create a real toolbar for every user toolbar loaded (this is the
> simple case, createContainer doesn't do anything)
> - do it like in Quanta 3 and put them into a tabwidget, and the
> tabwidget into the toolbar.  This is better IMO since otherwise
> switching between two different kind of XML documents would trigger a
> relayout of the main toolbars, which is not that nice.
> 
> The other magic was to get the actions in Configure Toolbars & Shortcuts
> right. In KDE3 and at the porting point in KDE4, it was needed to add
> the actions from a loaded toolbar to the main actionCollection object of
> the gui client as well. And vice versa, add all actions to the toolbar's
> actioncollection. Otherwise it is not possible to create custom toolbars
> with actions defined in the application itself or actions that were
> created from other toolbars (or with the Configure Actions dialog).
> 
> There is some extra code to handle translation of the toolbar names, so
> Standard/Style and to make sure the same toolbar is not loaded more than
> once, actions are not duplicated.
> 
> I think most of the used code is documented in the KDE api docs, but it
> isn't heavily used in other apps.

Still, what I think this shows is: 

It's lots of code and everything but straight forward. Hence I'd still like to 
see it handled properly inside KDELibs for reuse by applications.
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100614/8f5698d3/attachment.sig>


More information about the kde-core-devel mailing list