本文整理汇总了C++中kservice::Ptr::desktopEntryName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::desktopEntryName方法的具体用法?C++ Ptr::desktopEntryName怎么用?C++ Ptr::desktopEntryName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kservice::Ptr
的用法示例。
在下文中一共展示了Ptr::desktopEntryName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: DesktopBehaviorPreviewItem
DesktopBehaviorPreviewItem(DesktopBehavior *rootOpts, QListView *parent,
const KService::Ptr &plugin, bool on)
: QCheckListItem(parent, plugin->name(), CheckBox),
m_rootOpts(rootOpts)
{
m_pluginName = plugin->desktopEntryName();
setOn(on);
}
示例3: isMimeTypeAssociatedWithSelf
static bool isMimeTypeAssociatedWithSelf(const KService::Ptr &offer)
{
if (!offer)
return false;
kDebug(800) << offer->desktopEntryName();
const QString& appName = QCoreApplication::applicationName();
if (appName == offer->desktopEntryName() || offer->exec().trimmed().startsWith(appName))
return true;
// konqueror exception since it uses kfmclient to open html content...
if (appName == QL1S("konqueror") && offer->exec().trimmed().startsWith(QL1S("kfmclient")))
return true;
return false;
}
示例4:
SearchProvider::SearchProvider(const KService::Ptr service)
: m_dirty(false)
{
m_desktopEntryName = service->desktopEntryName();
m_name = service->name();
m_query = service->property("Query").toString();
m_keys = service->property("Keys").toStringList();
m_charset = service->property("Charset").toString();
}
示例5: setDesktopEntryName
SearchProvider::SearchProvider(const KService::Ptr service)
: m_dirty(false)
{
setDesktopEntryName(service->desktopEntryName());
setName(service->name());
setKeys(service->property(QStringLiteral("Keys")).toStringList());
m_query = service->property(QStringLiteral("Query")).toString();
m_charset = service->property(QStringLiteral("Charset")).toString();
}
示例6: createFileEntry
static void createFileEntry(KIO::UDSEntry& entry, const KService::Ptr& service, const KUrl& parentUrl)
{
entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, KIO::encodeFileName(service->name()));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
const QString fileUrl = parentUrl.url(KUrl::AddTrailingSlash) + service->desktopEntryName();
entry.insert(KIO::UDSEntry::UDS_URL, fileUrl);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, "application/x-desktop");
entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
entry.insert(KIO::UDSEntry::UDS_LOCAL_PATH, KStandardDirs::locate("apps", service->entryPath()));
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(0));
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, service->icon());
}
示例7: loadPlugins
void PluginManager::loadPlugins()
{
DEBUG_FUNC_NAME
KConfigGroup group = KGlobal::config()->group( "Plugins" );
KService::List offers = KServiceTypeTrader::self()->query(
QString::fromLatin1( "GluonCreator/Plugin" ),
QString( "[X-KDE-GluonCreatorPluginVersion] == %1" ).arg( GLUONCREATOR_PLUGIN_VERSION ) );
KService::List::const_iterator iter;
for( iter = offers.begin(); iter < offers.end(); ++iter )
{
QString error;
KService::Ptr service = *iter;
QString serviceName = service->desktopEntryName();
bool loadPlugin = group.readEntry<bool>( QString( "%1Enabled" ).arg( serviceName ), true );
if( !d->loadedPlugins.contains( serviceName ) && loadPlugin )
{
KPluginFactory* factory = KPluginLoader( service->library() ).factory();
if( !factory )
{
DEBUG_TEXT( QString( "KPluginFactory could not load the plugin: %1" ).arg( service->library() ) );
continue;
}
Plugin* plugin = factory->create<Plugin>( this );
if( plugin )
{
DEBUG_TEXT( QString( "Load plugin: %1" ).arg( service->name() ) );
plugin->load( d->mainWindow );
d->loadedPlugins.insert( serviceName, plugin );
}
else
{
DEBUG_TEXT( error );
}
}
else if( !loadPlugin && d->loadedPlugins.contains( serviceName ) )
{
Plugin* plugin = d->loadedPlugins.value( serviceName );
plugin->unload( d->mainWindow );
delete plugin;
d->loadedPlugins.remove( serviceName );
}
}
}
示例8: appstreamActions
QVariantList appstreamActions(const KService::Ptr &service)
{
if (!appstreamPool.exists()) {
appstreamPool->load();
}
QVariantList ret;
const auto components = appstreamPool->componentsById(service->desktopEntryName()+QLatin1String(".desktop"));
for(const auto &component: components) {
const QString componentId = component.id();
QVariantMap appstreamAction = Kicker::createActionItem(i18nc("@action opens a software center with the application", "Manage '%1'...", component.name()), "manageApplication", QVariant(QStringLiteral("appstream://") + componentId));
appstreamAction[QStringLiteral("icon")] = QStringLiteral("applications-other");
ret << appstreamAction;
}
return ret;
}
示例9: searchExtParts
void KDiffTextEdit::searchExtParts()
{
// only execute once
static bool init = false;
if ( init )
return;
init = true;
// search all parts that can handle text/x-diff
KTrader::OfferList offers = KTrader::self()->query("text/x-diff", "('KParts/ReadOnlyPart' in ServiceTypes) and ('text/x-diff' in ServiceTypes) and (DesktopEntryName != 'katepart')");
KTrader::OfferList::const_iterator it;
for ( it = offers.begin(); it != offers.end(); ++it ) {
KService::Ptr ptr = (*it);
extPartsTranslated << ptr->name();
extParts << ptr->desktopEntryName();
}
return;
}
示例10: _config
KCMInit::KCMInit( KCmdLineArgs* args )
{
QDBusConnection::sessionBus().registerObject("/kcminit", this,
QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals);
QString arg;
if (args->count() == 1) {
arg = args->arg(0);
}
if (args->isSet("list"))
{
list = KServiceTypeTrader::self()->query( "KCModuleInit" );
for(KService::List::Iterator it = list.begin();
it != list.end();
++it)
{
KService::Ptr service = (*it);
if (service->library().isEmpty())
continue; // Skip
printf("%s\n", QFile::encodeName(service->desktopEntryName()).data());
}
return;
}
if (!arg.isEmpty()) {
QString module = arg;
if (!module.endsWith(".desktop"))
module += ".desktop";
KService::Ptr serv = KService::serviceByStorageId( module );
if ( !serv || serv->library().isEmpty() ) {
kError(1208) << i18n("Module %1 not found", module) << endl;
return;
} else
list.append(serv);
} else {
// locate the desktop files
list = KServiceTypeTrader::self()->query( "KCModuleInit" );
}
// This key has no GUI apparently
KConfig _config( "kcmdisplayrc" );
KConfigGroup config(&_config, "X11");
#ifdef Q_WS_X11
bool multihead = !config.readEntry( "disableMultihead", false) &&
(ScreenCount(QX11Info::display()) > 1);
#else
bool multihead = false;
#endif
// Pass env. var to kdeinit.
QString name = "KDE_MULTIHEAD";
QString value = multihead ? "true" : "false";
KToolInvocation::klauncher()->setLaunchEnv(name, value);
setenv( name.toLatin1().constData(), value.toLatin1().constData(), 1 ); // apply effect also to itself
if( startup )
{
runModules( 0 );
XEvent e;
e.xclient.type = ClientMessage;
e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False );
e.xclient.display = QX11Info::display();
e.xclient.window = QX11Info::appRootWindow();
e.xclient.format = 8;
strcpy( e.xclient.data.b, "kcminit" );
XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e );
sendReady();
QTimer::singleShot( 300 * 1000, qApp, SLOT(quit())); // just in case
qApp->exec(); // wait for runPhase1() and runPhase2()
}
else
runModules( -1 ); // all phases
}
示例11: createView
KonqViewFactory KonqFactory::createView( const QString &serviceType,
const QString &serviceName,
KService::Ptr *serviceImpl,
KService::List *partServiceOffers,
KService::List *appServiceOffers,
bool forceAutoEmbed )
{
kDebug() << "Trying to create view for" << serviceType << serviceName;
// We need to get those in any case
KService::List offers, appOffers;
// Query the trader
getOffers( serviceType, &offers, &appOffers );
if ( partServiceOffers )
(*partServiceOffers) = offers;
if ( appServiceOffers )
(*appServiceOffers) = appOffers;
// We ask ourselves whether to do it or not only if no service was specified.
// If it was (from the View menu or from RMB + Embedding service), just do it.
forceAutoEmbed = forceAutoEmbed || !serviceName.isEmpty();
// Or if we have no associated app anyway, then embed.
forceAutoEmbed = forceAutoEmbed || ( appOffers.isEmpty() && !offers.isEmpty() );
// Or if the associated app is konqueror itself, then embed.
if ( !appOffers.isEmpty() )
forceAutoEmbed = forceAutoEmbed || KonqMainWindow::isMimeTypeAssociatedWithSelf( serviceType, appOffers.first() );
if ( ! forceAutoEmbed )
{
if ( ! KonqFMSettings::settings()->shouldEmbed( serviceType ) )
{
kDebug() << "KonqFMSettings says: don't embed this servicetype";
return KonqViewFactory();
}
}
KService::Ptr service;
// Look for this service
if (!serviceName.isEmpty()) {
KService::List::const_iterator it = offers.constBegin();
for ( ; it != offers.constEnd() && !service ; ++it ) {
if ( (*it)->desktopEntryName() == serviceName ) {
kDebug() << "Found requested service" << serviceName;
service = *it;
}
}
}
KonqViewFactory viewFactory;
if (service) {
kDebug() << "Trying to open lib for requested service " << service->desktopEntryName();
viewFactory = tryLoadingService(service);
// If this fails, then return an error.
// When looking for konq_sidebartng or konq_aboutpage, we don't want to end up
// with khtml or another Browser/View part in case of an error...
} else {
KService::List::Iterator it = offers.begin();
for ( ; viewFactory.isNull() /* exit as soon as we get one */ && it != offers.end() ; ++it ) {
service = (*it);
// Allowed as default ?
QVariant prop = service->property( "X-KDE-BrowserView-AllowAsDefault" );
kDebug() << service->desktopEntryName() << " : X-KDE-BrowserView-AllowAsDefault is valid : " << prop.isValid();
if ( !prop.isValid() || prop.toBool() ) { // defaults to true
//kDebug() << "Trying to open lib for service " << service->name();
viewFactory = tryLoadingService(service);
// If this works, we exit the loop.
} else {
kDebug() << "Not allowed as default " << service->desktopEntryName();
}
}
}
if (serviceImpl)
(*serviceImpl) = service;
if (viewFactory.isNull()) {
if (offers.isEmpty())
kWarning() << "no part was associated with" << serviceType;
else
kWarning() << "no part could be loaded"; // full error was shown to user already
return viewFactory;
}
QVariantList args;
const QVariant prop = service->property( "X-KDE-BrowserView-Args" );
if (prop.isValid()) {
Q_FOREACH(const QString& str, prop.toString().split(' '))
args << QVariant(str);
}
示例12: foundMimeType
void KonqRun::foundMimeType(const QString & _type)
{
//kDebug() << "KonqRun::foundMimeType " << _type << " m_req=" << m_req.debug();
QString mimeType = _type; // this ref comes from the job, we lose it when using KIO again
m_bFoundMimeType = true;
if (m_pView)
m_pView->setLoading(false); // first phase finished, don't confuse KonqView
// Check if the main window wasn't deleted meanwhile
if (!m_pMainWindow) {
setError(true);
setFinished(true);
return;
}
// Grab the args back from BrowserRun
m_req.args = arguments();
m_req.browserArgs = browserArguments();
bool tryEmbed = true;
// One case where we shouldn't try to embed, is when the server asks us to save
if (serverSuggestsSave())
tryEmbed = false;
const bool associatedAppIsKonqueror = KonqMainWindow::isMimeTypeAssociatedWithSelf(mimeType);
if (tryEmbed && tryOpenView(mimeType, associatedAppIsKonqueror)) {
return;
}
// If we were following another view, do nothing if opening didn't work.
if (m_req.followMode) {
setFinished(true);
}
if (!hasFinished()) {
// If we couldn't embed the mimetype, call BrowserRun::handleNonEmbeddable()
KService::Ptr selectedService;
KParts::BrowserRun::NonEmbeddableResult res = handleNonEmbeddable(mimeType, &selectedService);
if (res == KParts::BrowserRun::Delayed)
return;
setFinished(res == KParts::BrowserRun::Handled);
if (hasFinished()) {
// save or cancel -> nothing else will happen in m_pView, so clear statusbar (#163628)
m_pView->frame()->statusbar()->slotClear();
} else {
if (!tryEmbed) {
// "Open" selected for a serverSuggestsSave() file - let's open. #171869
if (tryOpenView(mimeType, associatedAppIsKonqueror))
return;
}
// "Open" selected, possible with a specific application
if (selectedService)
KRun::setPreferredService(selectedService->desktopEntryName());
else {
KRun::displayOpenWithDialog(url(), m_pMainWindow, false /*tempfile*/, suggestedFileName());
setFinished(true);
}
}
}
// make Konqueror think there was an error, in order to stop the spinning wheel
// (we saved, canceled, or we're starting another app... in any case the current view should stop loading).
setError(true);
if (!hasFinished()) { // only if we're going to open
if (associatedAppIsKonqueror && m_pMainWindow->refuseExecutingKonqueror(mimeType)) {
setFinished(true);
}
}
if (!hasFinished()) {
kDebug() << "Nothing special to do in KonqRun, falling back to KRun";
KRun::foundMimeType(mimeType);
}
}