void KMMainView::slotToolSelected(int ID) { KMTimer::self()->hold(); QString libname = m_toollist[ID]; libname.prepend("kdeprint_tool_"); if(m_current && !m_current->device().isEmpty() && !libname.isEmpty()) { KLibFactory *factory = KLibLoader::self()->factory(libname.local8Bit()); if(factory) { QStringList args; args << m_current->device() << m_current->printerName(); KDialogBase *dlg = static_cast< KDialogBase * >(factory->create(this, "Tool", 0, args)); if(dlg) dlg->exec(); delete dlg; } } else KMessageBox::error(this, i18n("Unable to start printer tool. Possible reasons are: " "no printer selected, the selected printer doesn't have " "any local device defined (printer port), or the tool library " "could not be found.")); KMTimer::self()->release(); }
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 }
void Runner::loadModules(const QString &folder, const QString &query) { QRegExp reQuery(query); QDir dir(folder, "kunittest_*.la"); // Add the folder to the "module" resource such that the KLibLoader can // find the modules in this folder. KGlobal::dirs()->addResourceDir("module", folder); kdDebug() << "Looking in folder: " << dir.absPath() << endl; // Get a list of all modules. QStringList modules = dir.entryList(); for ( uint i = 0; i < modules.count(); ++i ) { QString module = modules[i]; kdDebug() << "Module: " << dir.absPath() + "/" + module << endl; if ( reQuery.search(module) != -1 ) { // strip the .la extension module.truncate(module.length()-3); KLibFactory *factory = KLibLoader::self()->factory(module.local8Bit()); if ( factory ) factory->create(); else { kdWarning() << "\tError loading " << module << " : " << KLibLoader::self()->lastErrorMessage() << endl; ::exit( 1 ); } } else kdDebug() << "\tModule doesn't match." << endl; } }
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; } }
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")); }
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); }
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 }
KFDMainWindow::KFDMainWindow() : KParts::MainWindow() { setXMLFile("kfd_mainwindow.rc"); setupActions(); //statusBar()->show(); KLibFactory *factory = KLibLoader::self()->factory("libkformdesigner_part"); if (factory) { QStringList list; list << "shell" << "multipleMode"; m_part = static_cast<KParts::ReadWritePart *>( factory->create(this, "kformdesigner_part", "KParts::ReadWritePart", list) ); if(m_part) { setCentralWidget(m_part->widget()); createGUI(m_part); } } else { KMessageBox::error(this, i18n("Could not find the KFormDesigner part. Please check your installation.")); kapp->quit(); return; } setAutoSaveSettings(); }
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 {
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&))); }
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()); }
// 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" )); }
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; }
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(); } }
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(); }
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 );*/ }
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; }
// static factory method KOCRDialog * KOCRDialog::getOCRDialog( QWidget *parent, const char *name, bool modal ) { KTrader::OfferList offers = KTrader::self()->query("KScan/KOCRDialog"); if ( offers.isEmpty() ) return 0L; KService::Ptr ptr = *(offers.begin()); KLibFactory *factory = KLibLoader::self()->factory( QFile::encodeName(ptr->library()) ); if ( !factory ) return 0; QStringList args; args << QString::number( (int)modal ); QObject *res = factory->create( parent, name, "KOCRDialog", args ); return dynamic_cast<KOCRDialog *>( res ); }
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; }
kgitView::kgitView(QWidget *parent) : kgitViewbase(parent), DCOPObject("kgitIface") { // 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/plain", "'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/*(QWidget *)layout4->parent()*/, 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; } //layout4->addWidget(m_html->widget()); m_html->widget()->hide(); connect(m_html, SIGNAL(setWindowCaption(const QString&)), this, SLOT(slotSetTitle(const QString&))); connect(m_html, SIGNAL(setStatusBarText(const QString&)), this, SLOT(slotOnURL(const QString&))); gitProc = new KProcIO; connect((QObject *)CommitButton,SIGNAL(clicked()),this,SLOT(slotCommitCurrent())); connect((QObject *)DiscardChangesButton,SIGNAL(clicked()),this,SLOT(slotDiscardChanges())); connect((QObject *)UndoCommitButton,SIGNAL(clicked()),this,SLOT(slotUndoLastCommit())); connect((QObject *)RevertCommitButton,SIGNAL(clicked()),this,SLOT(slotRevertCommit())); connect((QObject *)CherryPickFromOtherButton,SIGNAL(clicked()),this,SLOT(slotCherryPickFromOther())); connect((QObject *)SendPatchButton,SIGNAL(clicked()),this,SLOT(slotSendPatch())); connect(comboBoxBranches, SIGNAL(activated(const QString&)),this,SLOT(slotGitChangeBranch(const QString&))); connect(ShortLogList, SIGNAL(doubleClicked( QListViewItem *, const QPoint &, int ) ),this,SLOT(slotGitShowCommitDiff())); ShortLogList->setSorting(-1); connect(RepoTreeList, SIGNAL(selectionChanged()),this,SLOT(slotUpdateFilesToCommit())); connect(FileListFilterText, SIGNAL(textChanged ( const QString & )),this,SLOT(slotFileFilter(const QString &))); commit_files = new QStringList; branches = new QStringList; busyWaiting=0; }
Plugin * PluginLoader::loadPlugin(const QString &name) { KLibrary *lib = NULL; KLibFactory *factory = NULL; Plugin *plugin = NULL; PluginMap::iterator it; bool success = true; // if the plugin has already been loaded, increment // its reference and return. if((it = _plugins.find(name)) != _plugins.end()) { plugin = it.data(); plugin->ref(); return plugin; } // use KLibLoader to get a reference to the library lib = KLibLoader::self()->library(name.latin1()); if(!lib) { kdError() << "failed loading plugin library " << name << endl; success = false; } // get the factory from the library if(success) { factory = lib->factory(); if(!factory) { kdError() << "failed to find factory for " << name << endl; success = false; } } // use the factory to create the plugin if(success) { plugin = dynamic_cast<Plugin *>(factory->create((QObject*)0, name.latin1())); if(!plugin) { kdError() << "failed to create a plugin object for " << name << endl; success = false; } else { // we have to register the plugin here, otherwise, we can get // recursive loads _plugins[name] = plugin; _categories[plugin->category()].append(plugin); } } // initialize the plugin if(success && plugin) { success = plugin->init(); if(!success) { // on failure, delete the plugin. this should cause the // library to unload. kdError() << "failure initializing " << name << endl; _categories[plugin->category()].remove(plugin); _plugins.remove(name); delete plugin; } } // finally, finally connect to the destroyed signal and keep a // reference to it if(success) { plugin->ref(); connect(plugin, SIGNAL(destroyed(QObject *)), SLOT(slotDestroyed(QObject *))); } return plugin; }