setupGUI and kparts

David Faure faure at kde.org
Fri Jul 2 20:54:00 BST 2004


On Friday 02 July 2004 21:47, Benjamin Meyer wrote:
> I noticed that in kmainwindow the configureToolbars function doesn't work if
> you are using kparts.  I played around with it and come up with this
> solution, but I don't know if there are edge cases that I am missing as I
> don't know the kparts system well enough.  Can someone with more expertease
> in this area take a quick glance at this and let me know if it is good to
> commit?
> 
> -Benjamin Meyer
> 
> 
> Index: kmainwindow.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/kdeui/kmainwindow.cpp,v
> retrieving revision 1.132
> diff -u -3 -p -r1.132 kmainwindow.cpp
> --- kmainwindow.cpp   10 Jun 2004 14:12:14 -0000        1.132
> +++ kmainwindow.cpp   2 Jul 2004 19:38:19 -0000
> @@ -426,7 +426,12 @@ KXMLGUIFactory *KMainWindow::guiFactory(
>  int KMainWindow::configureToolbars()
>  {
>      saveMainWindowSettings(KGlobal::config());
> -    KEditToolbar dlg(guiFactory(), this, "KEditToolbar");
> +    if(!(actionCollection()->isEmpty())){

Tihs looks wrong to me. A kparts-based application can have actions in
its mainwindow - actually most of them do, like konqueror or koffice apps.

> +       KEditToolbar dlg(actionCollection(), xmlFile(), this, false,
> "KEditToolbar");
> +       connect(&dlg, SIGNAL(newToolbarConfig()),
> SLOT(saveNewToolbarConfig()));
> +       return dlg.exec();

This is going to miss all kparts plugins etc.

Looking at e.g. konqueror, the right KEditToolbar constructor for 
a kparts-based application is KEditToolbar dlg(factory());   which 
basically gets the factory where the mainwindow is plugged in,
which AFAICS should be the same as the factory created by the mainwindow
using guiFactory().
So... AFAICS the original method was fine; what's not fine is KMainWindow::saveNewToolbarConfig().
It should be reimplemented in KParts::MainWindow (ouch, needs virtual_hook)
to call createGUI( m_activePart ) instead.
This is more complex to explain than to do myself, so for once I'll offer to do it :)
Stay tuned.

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