[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: KoPluginLoader to KPluginLoader transition (was: koffice/kspread)
From: Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date: 2008-07-07 19:46:16
Message-ID: 200807072146.20683.stefan.nikolaus () kdemail ! net
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/alternative)]
On Monday 07 July 2008 20:56:09 Thomas Zander wrote:
> On Monday 7. July 2008 19:02:47 Stefan Nikolaus wrote:
> > Functions Switch from KoPluginLoader to KPluginLoader in order to
> > use KPluginSelector. ;)
>
> Could you write up your experiences? I certainly want to use the
> KPluginSelector one day, so I'm wondering what the difference between the
> KPluginLoader and the KoPluginLoader is :)
What prevent using the KPluginSelector with KoPluginLoader are just the config
entries, that mark the plugins as enabled/disabled. While KoPluginLoader
stores a list for the enabled plugins and another one for the disabled ones,
KPluginSelector expects one entry per plugin.
The only downside is that those entries are always stored in the config group
"Plugins". It is possible, that one would get name clashes there. There are
other KPluginSelector::addPlugin methods, which obviously are designed for
KParts as they use the group "KParts Plugins". Maybe one could add another
method, that takes a KConfigGroup.
Besides, it would be possible to use KPluginLoader for loading shapes/tools.
The FooPlugin simply becomes a plugin factory:
K_PLUGIN_FACTORY(FooPluginFactory,
registerPlugin<FooShape>();
registerPlugin<FooTool>();
)
K_EXPORT_PLUGIN(FooPluginFactory("FooPlugin"))
The macro creates a KPluginFactory derived class. The name "FooPlugin" has to
be the "X-KDE-PluginInfo-Name" in the desktop file. You also have to add
"KPluginInfo" to "X-KDE-ServiceTypes" there and may add the several "X-KDE-
PluginInfo-*" entries. For examples of the desktop files look in
koffice/kspread/functions.
On the loading side: Query the KServiceTypeTrader as before, do some
conversions, iterate over each service/plugininfo (see
koffice/kspread/FunctionModuleRegistry.cpp), and you can get first the plugin
factory by:
KPluginFactory *factory = KPluginLoader(*pluginInfo.service()).factory();
And then from this factory the shape and tool can be created by:
KoShape* shape = factory->create<KoShape>(parentQObject);
KoTool* tool = factory->create<KoTool>(parentQObject);
That's it. :)
--
Stefan Nikolaus
[Attachment #7 (text/html)]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" \
"http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" \
content="1" /><style type="text/css">p, li { white-space: pre-wrap; \
}</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:9pt; \
font-weight:400; font-style:normal;">On Monday 07 July 2008 20:56:09 Thomas Zander \
wrote:<br> > On Monday 7. July 2008 19:02:47 Stefan Nikolaus wrote:<br>
> > Functions Switch from KoPluginLoader to KPluginLoader in order to<br>
> > use KPluginSelector. ;)<br>
><br>
> Could you write up your experiences? I certainly want to use the<br>
> KPluginSelector one day, so I'm wondering what the difference between the<br>
> KPluginLoader and the KoPluginLoader is :)<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p>What prevent using the KPluginSelector with KoPluginLoader are \
just the config entries, that mark the plugins as enabled/disabled. While \
KoPluginLoader stores a list for the enabled plugins and another one for the disabled \
ones, KPluginSelector expects one entry per plugin.<br> The only downside is that \
those entries are always stored in the config group "Plugins". It is possible, that \
one would get name clashes there. There are other KPluginSelector::addPlugin methods, \
which obviously are designed for KParts as they use the group "KParts Plugins". Maybe \
one could add another method, that takes a KConfigGroup.<br> Besides, it would be \
possible to use KPluginLoader for loading shapes/tools.<br> The FooPlugin simply \
becomes a plugin factory:<br> <p style="-qt-paragraph-type:empty; margin-top:0px; \
margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; \
text-indent:0px; -qt-user-state:0;"></p>K_PLUGIN_FACTORY(FooPluginFactory,<br> \
registerPlugin<FooShape>();<br> registerPlugin<FooTool>();<br>
)<br>
K_EXPORT_PLUGIN(FooPluginFactory("FooPlugin"))<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p>The macro creates a KPluginFactory derived class. The name \
"FooPlugin" has to be the "X-KDE-PluginInfo-Name" in the desktop file. You also have \
to add "KPluginInfo" to "X-KDE-ServiceTypes" there and may add the several \
"X-KDE-PluginInfo-*" entries. For examples of the desktop files look in \
koffice/kspread/functions. <br> On the loading side: Query the KServiceTypeTrader as \
before, do some conversions, iterate over each service/plugininfo (see \
koffice/kspread/FunctionModuleRegistry.cpp), and you can get first the plugin factory \
by:<br> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p>KPluginFactory *factory = \
KPluginLoader(*pluginInfo.service()).factory();<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p>And \
then from this factory the shape and tool can be created by:<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p>KoShape* shape = \
factory->create<KoShape>(parentQObject);<br> KoTool* tool = \
factory->create<KoTool>(parentQObject);<br> <p \
style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; \
margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"></p>That's \
it. :)<br> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; \
margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; \
-qt-user-state:0;"></p>-- <br> Stefan Nikolaus</p></body></html>
["signature.asc" (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic