[OT] plugins and QDockWidget

Andreas Pakulat apaku at gmx.de
Sat Mar 24 19:43:50 UTC 2007


On 25.03.07 00:57:06, kitts wrote:
> On Sunday 25 Mar 2007 IST, Andreas Pakulat wrote:
> > > So generally speaking, i assume that every plugin instance maintains a
> > > pointer to the mainwindow passed to it in the constructor, holds the
> > > responsibility of providing its own mainwidget (if applicable) and
> > > receives activation signals to show/hide associated dockwidgets.
> >
> > No, at least not in KDevelop4. We'd like to hide the mainwindow from any
> > plugins as we will have multiple mainwindows but only 1 instance of a
> > plugin. The plugin just provides a factory to create widgets for the
> > dockwidgets and hopefully it'll also provide a way to create a central
> > widget if it needs to.
> >
> > However there are also plugins in KDev4 that don't provide any of the
> > two and just "do some work", like the project managers or project
> > builders.
> 
> So the plugin itself cannot initiate the creation of a new dockwidget but 
> will list them out when queried by the main app? The 'scope' of the plugin 
> is set by the main app. I have in mind the situation where perhaps a new 
> dockwidget is created/modified by the plugin based on the selection within 
> its view. Of course, this could also be achieved by it rising a signal that 
> is understood by the main app.

No, you misunderstood. The plugin will have a QWidget derived class
(which may know about the plugin class itself, even connected to its
signals) and the plugin will provide a factory which can create an
instance of this qwidget derived class. The application then asks the
factory to create a new widget when the plugin is loaded and embeds that
widget into a qdockwidget. Later on the user can decide to create
another toolview and then the factory is asked to create another such
qwidget derived class and its embedded in a new qdockwidget.

The plugin still somewhat controls when the first qdockwidget shows up,
because it needs to call addToolView to make the factory known to the
main app. But after that the mainwindow/uicontroller in KDev4 controls
when to create new dockwidgets.

The communication between plugin's view, plugin and toolview would need
to be done via signal/slots, i.e. if the view signals some change to the
plugin this one can send out a signal which is catched by all
toolview-widgets and they act accordingly.

Andreas

-- 
Try to have as good a life as you can under the circumstances.




More information about the KDevelop-devel mailing list