[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Loading plugins from koView subclass
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2005-10-28 8:58:37
Message-ID: 200510281058.41120.boud () valdyas ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
I wanted to load Krita's kxmlgui-based plugins myself so I can check for
version numbers. However, I've got two or three problems:
* Either I use mainWindow()->guiFactory() to add the plugins to my view, but
then the plugins construct the gui first, messing up the menu layout, and I
get an error saying that krita.so doesn't have an init_krita funciton
* Or I use the factory() function of the KoView subclass (KisView) to add the
plugins, but then I get the crash.
The plugins are found correctly, as are rc files. This is what I do in
KisView:
KisView::KisView(...)
{
...
setInstance(KisFactory::instance());
setClientBuilder( this );
if (!doc -> isReadWrite())
setXMLFile("krita_readonly.rc");
else
setXMLFile("krita.rc");
KStdAction::keyBindings( mainWindow()->guiFactory(),
SLOT( configureShortcuts() ), actionCollection() );
...
// Load all plugins
KTrader::OfferList offers =
KTrader::self() -> query(QString::fromLatin1("Krita/ViewPlugin"),
QString::fromLatin1("(Type == 'Service')
and "([X-KDE-Version] == 2)"));
KTrader::OfferList::ConstIterator iter;
for(iter = offers.begin(); iter != offers.end(); ++iter)
{
KService::Ptr service = *iter;
int errCode = 0;
KParts::Plugin* plugin =
KParts::ComponentFactory::createInstanceFromService<KParts::Plugin>
( service, this, 0, QStringList(), &errCode);
if ( plugin ) {
factory()->addClient(plugin);
// mainWindow()->guiFactory()->addClient(plugin)
}
And a typical plugin looks like this:
KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(QObject *parent, const
char *name, const QStringList &)
: KParts::Plugin(parent, name)
{
if ( parent->inherits("KisView") ) {
kdDebug () << "instantiating separate channels plugin\n";
setInstance(KGenericFactory<KisSeparateChannelsPlugin>::instance());
setXMLFile(locate("data","kritaplugins/imageseparate.rc"), true);
}
}
Now what am I doing wrong? I'm at my wits end...
--
Boudewijn Rempt
http://www.valdyas.org/fading/index.cgi
[Attachment #5 (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