本文整理汇总了C++中KLibFactory类的典型用法代码示例。如果您正苦于以下问题:C++ KLibFactory类的具体用法?C++ KLibFactory怎么用?C++ KLibFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KLibFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RKMDIWindow
RKCommandEditorWindow::RKCommandEditorWindow (QWidget *parent, bool use_r_highlighting) : RKMDIWindow (parent, RKMDIWindow::CommandEditorWindow) {
RK_TRACE (COMMANDEDITOR);
KLibFactory *factory = KLibLoader::self()->factory( "libkatepart" );
if (factory) {
// Create the part
m_doc = (Kate::Document *) factory->create( this, "katepart", "KParts::ReadWritePart" );
RK_ASSERT (m_doc);
m_view = (Kate::View *) m_doc->widget();
}
// strip down the khtmlpart's GUI. remove some stuff we definitely don't need.
RKCommonFunctions::removeContainers (m_doc, QStringList::split (',', "bookmarks,tools_spelling,tools_spelling_from_cursor,tools_spelling_selection,switch_to_cmd_line"), true);
RKCommonFunctions::moveContainer (m_doc, "Menu", "tools", "edit", true);
m_doc->insertChildClient (new RKCommandEditorWindowPart (m_view, this));
QHBoxLayout *pLayout = new QHBoxLayout( this, 0, -1, "layout");
pLayout->addWidget(m_view);
setIcon (SmallIcon ("source"));
connect (m_doc, SIGNAL (fileNameChanged ()), this, SLOT (updateCaption ()));
connect (m_doc, SIGNAL (modifiedChanged ()), this, SLOT (updateCaption ())); // of course most of the time this causes a redundant call to updateCaption. Not if a modification is undone, however.
if (use_r_highlighting) setRHighlighting ();
updateCaption (); // initialize
}
示例2: setCentralWidget
KFileReplace::KFileReplace()
: KParts::MainWindow(0L, "KFileReplace")
{
KLibFactory *factory = KLibLoader::self()->factory("libkfilereplacepart");
if (factory)
{
m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,
"kfilereplace_part", "KParts::ReadOnlyPart" ));
if (m_part)
{
setCentralWidget(m_part->widget());
KStdAction::quit(this, SLOT(close()), actionCollection());
KStdAction::keyBindings(this, SLOT(slotConfigureKeys()), actionCollection());
KStdAction::configureToolbars(this, SLOT(slotConfigureToolbars()), actionCollection());
setStandardToolBarMenuEnabled(true);
createGUI(m_part);
removeDuplicatedActions();
}
}
else
{
KMessageBox::error(this, i18n("Could not find the KFileReplace part."));
close();
return;
}
}
示例3: strcpy
void KstJS::showConsole() {
#ifdef KST_HAVE_READLINE
if (!_konsolePart) {
strcpy(shellStr, "SHELL=kstcmd");
putenv(shellStr);
KLibFactory *f = KLibLoader::self()->factory("libkonsolepart");
if (!f) {
KMessageBox::sorry(app(), i18n("Could not load konsole part. Please install kdebase."));
_showAction->setChecked(false);
return;
}
if (!_splitter) {
_splitter = new QSplitter(Qt::Vertical, app());
_oldCentralWidget = app()->centralWidget();
_oldCentralWidget->reparent(_splitter, QPoint(0, 0));
_splitter->show();
app()->setCentralWidget(_splitter);
}
KParts::Part *p = dynamic_cast<KParts::Part*>(f->create(_splitter, "kstcmd"));
if (!p) {
KMessageBox::sorry(app(), i18n("Konsole part appears to be incompatible. Please install kdebase correctly."));
_showAction->setChecked(false);
return;
}
_splitter->moveToLast(p->widget());
connect(p, SIGNAL(destroyed()), this, SLOT(shellExited()));
_konsolePart = p;
}
_konsolePart->widget()->show();
#endif
}
示例4: QVBox
void AdminDatabase::queryButtonClicked()
{
if ( ! m_listView->currentItem() )
return;
QVBox *widget = new QVBox(this);
KTrader::OfferList offers = KTrader::self()->query("text/plain", "'KParts/ReadOnlyPart' in ServiceTypes");
KLibFactory *factory = 0;
KTrader::OfferList::Iterator it(offers.begin());
for( ; it != offers.end(); ++it)
{
KService::Ptr ptr = (*it);
factory = KLibLoader::self()->factory( ptr->library() );
if (factory)
{
m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(widget, ptr->name(), "KParts::ReadOnlyPart"));
m_part->openURL("file://"+m_dumpDir->absPath()+"/"+m_listView->getText(0)+".sql");
break;
}
}
if (!factory)
{
KMessageBox::error(this, i18n("Could not find a suitable component"));
return;
}
emit sendWidget(widget,i18n("View dump"));
}
示例5: QWidget
TextEditor::TextEditor(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout l;
KLibFactory *factory = KLibLoader::self()->factory("katepart");
if (factory) {
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
KParts::ReadWritePart *m_part = static_cast<KParts::ReadWritePart *>(factory->create(this, "KatePart" ));
if (m_part) {
// tell the KParts::MainWindow that this is indeed
// the main widget
l.addWidget(m_part->widget());
// setCentralWidget(m_part->widget());
// setupGUI(ToolBar | Keys | StatusBar | Save);
// and integrate the part's GUI with the shell's
// createGUI(m_part);
}
}
setLayout(&l);
}
示例6: kDebug
MainWindow::MainWindow( const QString &icsfile )
: KParts::MainWindow( )
{
kDebug(5970) << "Entering function, icsfile is " << icsfile;
// Setup our actions
setupActions();
// this routine will find and load our Part.
KLibFactory *factory = KLibLoader::self()->factory("ktimetrackerpart");
if (factory)
{
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
m_part = static_cast<ktimetrackerpart *>(factory->create(this, "ktimetrackerpart" ));
if (m_part)
{
// tell the KParts::MainWindow that this is indeed
// the main widget
setCentralWidget(m_part->widget());
m_part->openFile(icsfile);
slotSetCaption( icsfile ); // set the window title to our iCal file
connect(configureAction, SIGNAL(triggered(bool)),
m_part->widget(), SLOT(showSettingsDialog()));
((TimetrackerWidget *) (m_part->widget()))->setupActions( actionCollection() );
setupGUI();
}
}
else
{
示例7: QWidget
ksimoptsView::ksimoptsView(QWidget *parent)
: QWidget(parent),
DCOPObject("ksimoptsIface")
{
// setup our layout manager to automatically add our widgets
QHBoxLayout *top_layout = new QHBoxLayout(this);
top_layout->setAutoAdd(true);
// we want to look for all components that satisfy our needs. the
// trader will actually search through *all* registered KDE
// applications and components -- not just KParts. So we have to
// specify two things: a service type and a constraint
//
// the service type is like a mime type. we say that we want all
// applications and components that can handle HTML -- 'text/html'
//
// however, by itself, this will return such things as Netscape..
// not what we wanted. so we constrain it by saying that the
// string 'KParts/ReadOnlyPart' must be found in the ServiceTypes
// field. with this, only components of the type we want will be
// returned.
KTrader::OfferList offers = KTrader::self()->query("text/html", "'KParts/ReadWritePart' in ServiceTypes");
KLibFactory *factory = 0;
// in theory, we only care about the first one.. but let's try all
// offers just in case the first can't be loaded for some reason
KTrader::OfferList::Iterator it(offers.begin());
for( ; it != offers.end(); ++it)
{
KService::Ptr ptr = (*it);
// we now know that our offer can handle HTML and is a part.
// since it is a part, it must also have a library... let's try to
// load that now
factory = KLibLoader::self()->factory( ptr->library() );
if (factory)
{
m_html = static_cast<KParts::ReadWritePart *>(factory->create(this, ptr->name(), "KParts::ReadWritePart"));
break;
}
}
// if our factory is invalid, then we never found our component
// and we might as well just exit now
if (!factory)
{
KMessageBox::error(this, i18n("Could not find a suitable HTML component"));
return;
}
connect(m_html, SIGNAL(setWindowCaption(const QString&)),
this, SLOT(slotSetTitle(const QString&)));
connect(m_html, SIGNAL(setStatusBarText(const QString&)),
this, SLOT(slotOnURL(const QString&)));
}
示例8: loadKonsole
void ac::loadKonsole()
{
KLibFactory* factory = KLibLoader::self()->factory( "libsanekonsolepart" );
if (!factory)
factory = KLibLoader::self()->factory( "libkonsolepart" );
konsole = static_cast<KParts::Part*>( factory->create( konsoleFrame, "konsolepart", "QObject", "KParts::ReadOnlyPart" ) );
terminal()->setAutoDestroy( true );
terminal()->setAutoStartShell( false );
konsole->widget()->setGeometry(0, 0, konsoleFrame->width(), konsoleFrame->height());
}
示例9:
// static
KPreviewWidgetBase * KFileMetaPreview::createAudioPreview( TQWidget *parent )
{
KLibFactory *factory = KLibLoader::self()->factory( "tdefileaudiopreview" );
if ( !factory )
{
s_tryAudioPreview = false;
return 0L;
}
return dynamic_cast<KPreviewWidgetBase*>( factory->create( TQT_TQOBJECT(parent), "tdefileaudiopreview" ));
}
示例10: closeURL
bool KPartSaver::openURL( KURL url )
{
closeURL();
// find mime type
TQString mime = KMimeType::findByURL( url )->name();
// find fitting kparts
KTrader::OfferList offers;
offers = KTrader::self()->query( mime, "'KParts/ReadOnlyPart' in ServiceTypes" );
if( offers.count()==0 ) {
kdDebug() << "Can't find proper kpart for " << mime << endl;
return false;
}
// load kpart library
TQString lib = offers.first()->library();
KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() );
if( !factory ) {
kdDebug() << "Library " << lib << " not found." << endl;
return false;
}
// create kpart
m_part = (KParts::ReadOnlyPart *)factory->create( TQT_TQOBJECT(this), "kpart", "KParts::ReadOnlyPart" );
if( !m_part ) {
kdDebug() << "Part for " << url.url() << " can't be constructed" << endl;
return false;
} else
embed( m_part->widget() );
// show kpart
delete m_back;
m_back = 0;
show();
m_part->widget()->show();
// load url
if( !m_part->openURL( url ) ) {
kdDebug() << "Can't load " << url.url() << endl;
closeURL();
return false;
}
return true;
}
示例11: DCOPObject
KXsldbg::KXsldbg()
: DCOPObject("KXsldbg"), KParts::MainWindow( 0L, "kxsldbg" )
{
// set the shell's ui resource file
setXMLFile("kxsldbg_shell.rc");
// then, setup our actions
setupActions();
// and a status bar
statusBar()->show();
statusBar()->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
// this routine will find and load our Part. it finds the Part by
// name which is a bad idea usually.. but it's alright in this
// case since our Part is made for this Shell
KLibFactory *factory = KLibLoader::self()->factory("libkxsldbgpart");
if (factory)
{
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this,
"kxsldbg_part", "KParts::ReadOnlyPart" ));
if (m_part)
{
// tell the KParts::MainWindow that this is indeed the main widget
setCentralWidget(m_part->widget());
// and integrate the part's GUI with the shell's
createGUI(m_part);
// connect up signals
kapp->dcopClient()->attach();
connectDCOPSignal(0, 0, "debuggerPositionChanged(QString,int)", "newDebuggerPosition(QString,int)", false );
connectDCOPSignal(0, 0, "editorPositionChanged(QString,int,int)", "newCursorPosition(QString,int,int)", false );
}
}
else
{
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Could not find our part."));
kapp->quit();
}
}
示例12: setupActions
KPlistEditor::KPlistEditor()
: KParts::MainWindow( )
{
// set the shell's ui resource file
//setXMLFile("kplisteditor_shell.rc");
// then, setup our actions
setupActions();
// this routine will find and load our Part. it finds the Part by
// name which is a bad idea usually.. but it's alright in this
// case since our Part is made for this Shell
KLibFactory *factory = KLibLoader::self()->factory("libkplisteditorpart");
if (factory)
{
// now that the Part is loaded, we cast it to a Part to get
// our hands on it
m_part = static_cast<KParts::ReadWritePart *>(factory->create(this,
"KPlistEditorPart" ));
if (m_part)
{
// tell the KParts::MainWindow that this is indeed the main widget
setCentralWidget(m_part->widget());
// and integrate the part's GUI with the shell's
setupGUI();
}
}
else
{
// if we couldn't find our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Could not find our Part!"));
qApp->quit();
// we return here, cause qApp->quit() only means "exit the
// next time we enter the event loop...
return;
}
// apply the saved mainwindow settings, if any, and ask the mainwindow
// to automatically save settings if changed: window size, toolbar
// position, icon size, etc.
setAutoSaveSettings();
}
示例13: kdDebug
static KDevCompilerOptions *createCompilerOptions( const QString &name, QObject *parent )
{
KService::Ptr service = KService::serviceByDesktopName( name );
if ( !service )
{
kdDebug( 9020 ) << "Can't find service " << name << endl;
return 0;
}
KLibFactory *factory = KLibLoader::self()->factory(QFile::encodeName(service->library()));
if (!factory) {
QString errorMessage = KLibLoader::self()->lastErrorMessage();
kdDebug(9020) << "There was an error loading the module " << service->name() << endl <<
"The diagnostics is:" << endl << errorMessage << endl;
exit(1);
}
QStringList args;
QVariant prop = service->property("X-KDevelop-Args");
if (prop.isValid())
args = QStringList::split(" ", prop.toString());
QObject *obj = factory->create(parent, service->name().latin1(),
"KDevCompilerOptions", args);
if (!obj->inherits("KDevCompilerOptions")) {
kdDebug(9020) << "Component does not inherit KDevCompilerOptions" << endl;
return 0;
}
KDevCompilerOptions *dlg = (KDevCompilerOptions*) obj;
return dlg;
/*
QStringList args;
QVariant prop = service->property( "X-KDevelop-Args" );
if ( prop.isValid() )
args = QStringList::split( " ", prop.toString() );
return KParts::ComponentFactory
::createInstanceFromService<KDevCompilerOptions>( service, parent,
service->name().latin1(), args );*/
}
示例14: Contents
Contents *KonsoleApplet::createContents( Card *c )
{
Contents *contents = new Contents(c);
_contentsWidget = new QWidget(0, "TrayTestApplet-ContentsWidget");
QVBoxLayout *layout = new QVBoxLayout(_contentsWidget);
KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
if (!factory) return contents;
part = (KParts::ReadOnlyPart *) factory->create(_contentsWidget);
if (!part) return contents;
if (part->widget()->inherits("QFrame"))
((QFrame*)part->widget())->setFrameStyle(QFrame::Panel|QFrame::Sunken);
layout->addWidget(part->widget());
contents->setContents(_contentsWidget);
connect(part, SIGNAL(destroyed()),this, SLOT(destroy()) );
return contents;
}
示例15: TQString
KFilterBase * KFilterBase::findFilterByMimeType( const TQString & mimeType )
{
TDETrader::OfferList offers = TDETrader::self()->query( "TDECompressionFilter",
TQString("'") + mimeType + "' in ServiceTypes" );
TDETrader::OfferList::ConstIterator it = offers.begin();
TDETrader::OfferList::ConstIterator end = offers.end();
kdDebug(7005) << "KFilterBase::findFilterByMimeType(" << mimeType << ") got " << offers.count() << " offers" << endl;
for (; it != end; ++it )
{
if ((*it)->library().isEmpty()) { continue; }
KLibFactory *factory = KLibLoader::self()->factory((*it)->library().latin1());
if (!factory) { continue; }
KFilterBase *filter = static_cast<KFilterBase*>( factory->create(0, (*it)->desktopEntryName().latin1() ) );
if ( filter )
return filter;
}
if ( mimeType == "application/x-bzip2" || mimeType == "application/x-gzip" ) // #88574
kdWarning(7005) << "KFilterBase::findFilterByMimeType : no filter found for " << mimeType << endl;
return 0L;
}