[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: How to get KMenuBar instance?
From:       Paul Giannaros <ceruleanblaze () gmail ! com>
Date:       2007-11-19 1:55:17
Message-ID: 200711190155.17254.ceruleanblaze () gmail ! com
[Download RAW message or body]

On Sunday 18 November 2007 19:18:47 Christopher J. Bottaro wrote:
> On Nov 18, 2007 7:37 AM, Paul Giannaros <paul@giannaros.org> wrote:
> > On 18/11/2007, Anders Lund <anders@alweb.dk> wrote:
> > > On Sunday 18 November 2007, Christopher J. Bottaro wrote:
> > > > I can't find anything about how to get an app's KMenuBar instance.
> > >
> > > You shouldn't use the menubar object. Instead, add your menu using the
> > > XMLGui framework, like other plugins does it.
> > >
> > > You should read the documentation for KXMLGUIClient, inherited by
> > > Kate::Plugin inherits.
> > >
> > > There are three steps:
> > >
> > > 1) write an XML file using the kpartgui.dtd, placing your actions in
> > > the menubar.
> > > 2) create the actions.
> > > 3) set the xml file using setXMLFile().
> > >
> > > If you want to manipulate your menu often, you can keep a pointer to it
> > > in your plugin view, or you can get one using KXMLGUIClient::action().
> > >
> > > For examples, look at the existing plugins. Hint about the XML file: If
> > > you want an own menu, simply put it there. The XML plugin does that for
> > > example.
> >
> > Anders, I think the main issue for Christopher is that he is using
> > Pate, but as Pate gives full access to KDE and Qt, what you suggested
> > should work just fine.
> > As I said to Christopher off the list, it should be possible to get a
> > reference to the menu bar using topLevelWidget on Kate::MainWindow's
> > centralWidget and casting to a KMainWindow or whatever accordingly, if
> > that's what he wants to use.
>
> Ahh, I was barking up the wrong tree this whole time.  I looked at
> kate.application.mainWindow()
> kate.mainWidget()
> qt.qApp.mainWidget()
>
> I never thought to use topLevelWidget() to get the QMainWindow().
>
> Btw, kate.mainWidget().topLevelWidget().menuBar() returns a KMenuBar,
> no need to use sip.cast().
>
> > You should read the documentation for KXMLGUIClient, inherited by
> > Kate::Plugin inherits.
>
> Anders, thanks for the pointer.
>
> Paul, could you explain to me how KXMLGUIClient works in Pate?

I assume it works no different that it does in any other KDE application: just 
create your KXMLGUIClient, hook it up to your XML file (setXMLFile), and then 
use the KMainWindow KXMLGUIFactory's addClient method 
(e.g "myMainWindow.guiFactory().addClient(myClient)").

>
> Thanks everyone.
> _______________________________________________
> KWrite-Devel mailing list
> KWrite-Devel@kde.org
> https://mail.kde.org/mailman/listinfo/kwrite-devel


_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic