本文整理汇总了C++中kservice::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotCapturedShortcut
void BasicTab::slotCapturedShortcut(const KShortcut &cut)
{
if(signalsBlocked())
return;
if(KKeyChooser::checkGlobalShortcutsConflict(cut, true, topLevelWidget())
|| KKeyChooser::checkStandardShortcutsConflict(cut, true, topLevelWidget()))
return;
if(KHotKeys::present())
{
if(!_menuEntryInfo->isShortcutAvailable(cut))
{
KService::Ptr service;
emit findServiceShortcut(cut, service);
if(!service)
service = KHotKeys::findMenuEntry(cut.toString());
if(service)
{
KMessageBox::sorry(this, i18n("<qt>The key <b>%1</b> can not be used here because it is already used to activate <b>%2</b>.")
.arg(cut.toString(), service->name()));
return;
}
else
{
KMessageBox::sorry(this, i18n("<qt>The key <b>%1</b> can not be used here because it is already in use.").arg(cut.toString()));
return;
}
}
_menuEntryInfo->setShortcut(cut);
}
_keyEdit->setShortcut(cut, false);
if(_menuEntryInfo)
emit changed(_menuEntryInfo);
}
示例2: createEditor
KTextEditor::Editor *EditorChooser::createEditor(QWidget *parentWidget, QObject *parent, const char *widgetName, const char *name,
const QString &postfix, bool fallBackToKatePart)
{
KTextEditor::Editor *tmpEd = 0;
KConfig *cfg = kapp->config();
QString previousGroup = cfg->group();
cfg->setGroup("KTEXTEDITOR:" + postfix);
QString editor = cfg->readPathEntry("editor");
cfg->setGroup(previousGroup);
if(editor.isEmpty())
{
KConfig *config = new KConfig("default_components");
config->setGroup("KTextEditor");
editor = config->readPathEntry("embeddedEditor", "katepart");
delete config;
}
KService::Ptr serv = KService::serviceByDesktopName(editor);
if(serv)
{
tmpEd = KTextEditor::createEditor(serv->library().latin1(), parentWidget, widgetName, parent, name);
if(tmpEd)
return tmpEd;
}
if(fallBackToKatePart)
return KTextEditor::createEditor("libkatepart", parentWidget, widgetName, parent, name);
return 0;
}
示例3: KService
void
KCustomMenuEditor::load(KConfigBase *cfg)
{
cfg->setGroup(QString::null);
int count = cfg->readNumEntry("NrOfItems");
QListViewItem *last = 0;
for(int i = 0; i < count; i++)
{
QString entry = cfg->readPathEntry(QString("Item%1").arg(i+1));
if (entry.isEmpty())
continue;
// Try KSycoca first.
KService::Ptr menuItem = KService::serviceByDesktopPath( entry );
if (!menuItem)
menuItem = KService::serviceByDesktopName( entry );
if (!menuItem)
menuItem = new KService( entry );
if (!menuItem->isValid())
continue;
QListViewItem *item = new Item(m_listView, menuItem);
item->moveItem(last);
last = item;
}
}
示例4: KaffeineDVBsection
DVBevents::DVBevents( QString devType, int anum, int tnum, const QString &charset, EventTable *table )
: KaffeineDVBsection( anum, tnum, charset )
{
events = table;
KaffeineEpgPlugin *plug;
QString plugName;
int error;
KTrader::OfferList offers = KTrader::self()->query("KaffeineEpgPlugin");
KTrader::OfferList::Iterator end( offers.end() );
for ( KTrader::OfferList::Iterator it=offers.begin(); it!=end; ++it ) {
error = 0;
KService::Ptr ptr = (*it);
if ( !ptr->name().contains(devType) )
continue;
plug = KParts::ComponentFactory::createPartInstanceFromService<KaffeineEpgPlugin>(ptr, 0, ptr->name().ascii(), 0, 0, 0, &error );
plugName = ptr->desktopEntryName();
if (error > 0) {
fprintf( stderr, "Loading of EPG plugin %s failed: %s\n", plugName.ascii(), KLibLoader::self()->lastErrorMessage().ascii() );
plug = NULL;
}
else {
plugs.append( plug );
plug->setTable( table );
plug->initSection( anum, tnum, charset );
plugNames.append( plugName );
}
}
fprintf( stderr, "%d EPG plugins loaded for device %d:%d.\n", plugs.count(), anum, tnum );
}
示例5: loadPlugins
void PluginManager::loadPlugins()
{
KService::List offers = KServiceTypeTrader::self()->query(QLatin1String("KTpAccountsKCM/AccountUiPlugin"));
KService::List::const_iterator iter;
for (iter = offers.constBegin(); iter < offers.constEnd(); ++iter) {
QString error;
KService::Ptr service = *iter;
KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!factory) {
qWarning() << "KPluginFactory could not load the plugin:" << service->library();
continue;
}
AbstractAccountUiPlugin *plugin = factory->create<AbstractAccountUiPlugin>(this);
if (plugin) {
qDebug() << "Loaded plugin:" << service->name();
m_plugins.append(plugin);
} else {
qDebug() << error;
}
}
}
示例6: installButton
bool
EngineController::installDistroCodec()
{
KService::List services = KServiceTypeTrader::self()->query( "Amarok/CodecInstall"
, QString( "[X-KDE-Amarok-codec] == 'mp3' and [X-KDE-Amarok-engine] == 'phonon-%1'").arg( "xine" ) );
//todo - figure out how to query Phonon for the current backend loaded
if( !services.isEmpty() )
{
KService::Ptr service = services.first(); //list is not empty
QString installScript = service->exec();
if( !installScript.isNull() ) //just a sanity check
{
KGuiItem installButton( i18n( "Install MP3 Support" ) );
if(KMessageBox::questionYesNo( The::mainWindow()
, i18n("Amarok currently cannot play MP3 files. Do you want to install support for MP3?")
, i18n( "No MP3 Support" )
, installButton
, KStandardGuiItem::no()
, "codecInstallWarning" ) == KMessageBox::Yes )
{
KRun::runCommand(installScript, 0);
return true;
}
}
}
return false;
}
示例7: handleAppsDialog
bool Helper::handleAppsDialog()
{
if( !readArguments( 1 ))
return false;
QString title = getArgument();
long wid = getArgumentParent();
if( !allArgumentsUsed())
return false;
KOpenWithDialog dialog( NULL );
if( !title.isEmpty())
dialog.setWindowTitle( title );
dialog.hideNoCloseOnExit();
dialog.hideRunInTerminal(); // TODO
if( wid != 0 )
KWindowSystem::setMainWindow( &dialog, wid );
if( dialog.exec())
{
KService::Ptr service = dialog.service();
QString command;
if( service )
command = service->exec();
else if( !dialog.text().isEmpty())
command = dialog.text();
else
return false;
command = command.split( " " ).first(); // only the actual command
command = QStandardPaths::findExecutable(command);
if( command.isEmpty())
return false;
outputLine( QUrl::fromUserInput( command ).url());
return true;
}
return false;
}
示例8: urlSelected
bool DocumentationViewer::urlSelected(const QString &url, int button, int state, const QString &_target, const KParts::OpenUrlArguments &args, const KParts::BrowserArguments & /* browserArgs */)
{
KUrl cURL = completeURL(url);
QString mime = KMimeType::findByUrl(cURL).data()->name();
//load this URL in the embedded viewer if KHTML can handle it, or when mimetype detection failed
KService::Ptr service = KService::serviceByDesktopName("khtml");
if(( mime == KMimeType::defaultMimeType() ) || (service && service->hasServiceType(mime))) {
KHTMLPart::urlSelected(url, button, state, _target, args);
openUrl(cURL);
addToHistory(cURL.url());
}
//KHTML can't handle it, look for an appropriate application
else {
KService::List offers = KMimeTypeTrader::self()->query(mime, "Type == 'Application'");
if(offers.isEmpty()) {
KMessageBox::error(view(), i18n("No KDE service found for the MIME type \"%1\".", mime));
return false;
}
KUrl::List lst;
lst.append(cURL);
KRun::run(*(offers.first()), lst, view());
}
return true;
}
示例9: document
MainWindow::MainWindow(KTextEditor::Document* doc)
: document(0),
view(0)
{
if(!doc) {
KTextEditor::Editor* editor = NULL;
KService::Ptr serv = KService::serviceByDesktopName("yzispart");
if(!serv) {
KMessageBox::error(this, "Could not find yzispart!");
kapp->exit(-1);
} else {
editor = KTextEditor::editor(serv->library().toLatin1());
if(!editor) {
KMessageBox::error(this, "Could not create yziskpart editor component");
kapp->exit(-1);
}
}
document = editor->createDocument(0);
} else {
document = doc;
}
view = qobject_cast< KTextEditor::View* >(document->createView(this));
setCentralWidget(view);
guiFactory()->addClient(view);
show();
}
示例10: instantiatePluginForDevice
PluginData PluginLoader::instantiatePluginForDevice(const QString& name, Device* device) const
{
PluginData ret;
KService::Ptr service = plugins[name];
if (!service) {
kDebug(kdeconnect_kded()) << "Plugin unknown" << name;
return ret;
}
KPluginFactory *factory = KPluginLoader(service->library()).factory();
if (!factory) {
kDebug(kdeconnect_kded()) << "KPluginFactory could not load the plugin:" << service->library();
return ret;
}
ret.interfaces = service->property("X-KdeConnect-SupportedPackageType", QVariant::StringList).toStringList();
QVariant deviceVariant = QVariant::fromValue<Device*>(device);
//FIXME any reason to use QObject in template param instead KdeConnectPlugin?
ret.plugin = factory->create<KdeConnectPlugin>(device, QVariantList() << deviceVariant);
if (!ret.plugin) {
kDebug(kdeconnect_kded()) << "Error loading plugin";
return ret;
}
kDebug(kdeconnect_kded()) << "Loaded plugin:" << service->name();
return ret;
}
示例11: slotFixOpenWithMenu
void KateFileTree::slotFixOpenWithMenu()
{
QMenu *menu = (QMenu*)sender();
menu->clear();
KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if (!doc) return;
// get a list of appropriate services.
KMimeType::Ptr mime = KMimeType::mimeType(doc->mimeType());
//kDebug(13001) << "mime type: " << mime->name();
QAction *a = 0;
KService::List offers = KMimeTypeTrader::self()->query(mime->name(), "Application");
// for each one, insert a menu item...
for(KService::List::Iterator it = offers.begin(); it != offers.end(); ++it)
{
KService::Ptr service = *it;
if (service->name() == "Kate") continue;
a = menu->addAction(KIcon(service->icon()), service->name());
a->setData(service->entryPath());
}
// append "Other..." to call the KDE "open with" dialog.
a = menu->addAction(i18n("&Other..."));
a->setData(QString());
}
示例12: initApplication
void SettingsBase::initApplication()
{
// Prepare the menu of all modules
categories = KServiceTypeTrader::self()->query("SystemSettingsCategory");
modules = KServiceTypeTrader::self()->query("KCModule", "[X-KDE-System-Settings-Parent-Category] != ''");
modules += KServiceTypeTrader::self()->query("SystemSettingsExternalApp");
rootModule = new MenuItem( true, 0 );
initMenuList(rootModule);
// Handle lost+found modules...
if (lostFound) {
for (int i = 0; i < modules.size(); ++i) {
const KService::Ptr entry = modules.at(i);
MenuItem * infoItem = new MenuItem(false, lostFound);
infoItem->setService( entry );
qDebug() << "Added " << entry->name();
}
}
// Prepare the Base Data
BaseData::instance()->setMenuItem( rootModule );
// Load all possible views
const KService::List pluginObjects = KServiceTypeTrader::self()->query( "SystemSettingsView" );
const int nbPlugins = pluginObjects.count();
for( int pluginsDone = 0; pluginsDone < nbPlugins ; ++pluginsDone ) {
KService::Ptr activeService = pluginObjects.at( pluginsDone );
QString error;
BaseMode * controller = activeService->createInstance<BaseMode>(this, QVariantList(), &error);
if( error.isEmpty() ) {
possibleViews.insert( activeService->library(), controller );
controller->init( activeService );
connect(controller, SIGNAL(changeToolBarItems(BaseMode::ToolBarItems)), this, SLOT(changeToolBar(BaseMode::ToolBarItems)));
connect(controller, SIGNAL(actionsChanged()), this, SLOT(updateViewActions()));
connect(searchText, SIGNAL(textChanged(QString)), controller, SLOT(searchChanged(QString)));
connect(controller, SIGNAL(viewChanged(bool)), this, SLOT(viewChange(bool)));
} else {
示例13: stat
void ApplicationsProtocol::stat(const KUrl& url)
{
KIO::UDSEntry entry;
QString servicePath( url.path( KUrl::AddTrailingSlash ) );
servicePath.remove(0, 1); // remove starting '/'
KServiceGroup::Ptr grp = KServiceGroup::group(servicePath);
if (grp && grp->isValid()) {
createDirEntry(entry, ((m_runMode==ApplicationsMode) ? i18n("Applications") : i18n("Programs")),
url.url(), "inode/directory",grp->icon() );
} else {
KService::Ptr service = KService::serviceByDesktopName( url.fileName() );
if (service && service->isValid()) {
createFileEntry(entry, service, url );
} else {
error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown application folder"));
return;
}
}
statEntry(entry);
finished();
}
示例14: data
QVariant RecentAppsModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() >= m_recentApps.count()) {
return QVariant();
}
const QString storageId = m_recentApps.at(index.row());
KService::Ptr service = KService::serviceByStorageId(storageId);
if (!service) {
return QVariant();
}
if (role == Qt::DisplayRole) {
return service->name();
} else if (role == Qt::DecorationRole) {
return QIcon::fromTheme(service->icon(), QIcon::fromTheme("unknown"));
} else if (role == Kicker::FavoriteIdRole) {
return QVariant("app:" + storageId);
} else if (role == Kicker::HasActionListRole) {
return true;
} else if (role == Kicker::ActionListRole) {
QVariantList actionList;
const QVariantMap &forgetAction = Kicker::createActionItem(i18n("Forget Application"), "forget");
actionList.append(forgetAction);
const QVariantMap &forgetAllAction = Kicker::createActionItem(i18n("Forget All Applications"), "forgetAll");
actionList.append(forgetAllAction);
return actionList;
}
return QVariant();
}
示例15: addRecentApplication
void addRecentApplication(KService::Ptr service, bool append) {
// remove existing item if any
if (removeExistingItem(service->entryPath())) {
--recentApplicationCount;
}
QStandardItem *appItem = StandardItemFactory::createItemForService(service, displayOrder);
appItem->setData(applicationTitle, Kickoff::GroupNameRole);
itemsByPath.insert(service->entryPath(), appItem);
if (append) {
q->insertRow(recentApplicationCount, appItem);
} else {
q->insertRow(0, appItem);
}
++recentApplicationCount;
while (recentApplicationCount > maxRecentApps) {
--recentApplicationCount;
QList<QStandardItem*> row = q->takeRow(recentApplicationCount);
//don't leave pending stuff in itemsByPath
if (!row.isEmpty()) {
itemsByPath.remove(row.first()->data(UrlRole).toString());
qDeleteAll(row.begin(), row.end());
}
}
}