KService
kservice.cpp
51 // We are opening a "" service, this means whatever warning we might get is going to be misleading
95 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "instead of \"Application\" or \"Service\"";
110 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "but no Exec line";
125 if ((m_strType == QLatin1String("Application")) && (locationType != QStandardPaths::ApplicationsLocation) && !absPath) {
126 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "but is located under \""
132 if ((m_strType == QLatin1String("Service")) && (locationType != QStandardPaths::GenericDataLocation) && !absPath) {
133 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "but is located under \""
188 if (m_strType == QLatin1String("Application") && !lstServiceTypes.contains(QLatin1String("Application")))
238 // Exec lines from the KCMs always have the pattern "<program> m_strDesktopEntryName", see https://phabricator.kde.org/T13729
239 const static bool hasSystemsettings = !QStandardPaths::findExecutable(QStringLiteral("systemsettings5")).isEmpty();
244 if (!desktopGroup.readEntry("X-KDE-System-Settings-Parent-Category").isEmpty() && hasSystemsettings) {
270 // do not store other translations like Name[fr]; kbuildsycoca will rerun if we change languages anyway
300 qCWarning(SERVICES) << "The action" << group << "in the desktop file" << q->entryPath() << "has no Name or no Exec key";
308 if (it->first == QLatin1String("Name") || it->first == QLatin1String("Icon") || it->first == QLatin1String("Exec")
316 KServiceAction action(group, cg.readEntry("Name"), cg.readEntry("Icon"), cg.readEntry("Exec"), cg.readEntry("NoDisplay", false), serviceClone);
321 qCWarning(SERVICES) << "The desktop file" << q->entryPath() << "references the action" << group << "but doesn't define it";
376 s << m_strType << m_strName << m_strExec << m_strIcon << term << m_strTerminalOptions << m_strWorkingDirectory << m_strComment << def << m_mapProps
377 << m_strLibrary << dst << m_strDesktopEntryName << initpref << m_lstKeywords << m_strGenName << categories << menuId << m_actions << m_serviceTypes
449 return KSycocaPrivate::self()->serviceFactory()->hasOffer(ptr->offset(), ptr->serviceOffersOffset(), serviceOffset);
492 return KSycocaPrivate::self()->serviceFactory()->hasOffer(mimeOffset, serviceOffersOffset, serviceOffset);
502 // But this should matter only in a very rare case, since most code gets KServices from ksycoca.
608 return KConfigGroup::convertToQVariant(_name.toUtf8().constData(), it.value().toString().toUtf8(), QVariant(static_cast<QVariant::Type>(t)));
610 return KConfigGroup::convertToQVariant(_name.toUtf8().constData(), it.value().toString().toUtf8(), QVariant(QMetaType(t)));
699 QVector<QStringView> currentDesktops = QStringView(envVar).split(QLatin1Char(':'), Qt::SkipEmptyParts);
722 return std::any_of(currentDesktops.cbegin(), currentDesktops.cend(), [&aList](const auto desktop) {
733 return std::none_of(currentDesktops.cbegin(), currentDesktops.cend(), [&aList](const auto desktop) {
815 QMap<QString, QVariant>::ConstIterator it = d->m_mapProps.find(QStringLiteral("X-KDE-PluginKeyword"));
846 // Can we pass multiple files on the command line or do we have to start the application for every single file ?
887 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/applications/") + d->menuId;
890 QString KService::newServicePath(bool showInMenu, const QString &suggestedName, QString *menuId, const QStringList *reservedMenuIds)
913 if (!QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("applications/") + result).isEmpty()) {
923 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/applications/") + result;
936 qCWarning(SERVICES) << "The desktop entry file" << entryPath() << "has Type=" << d->m_strType << "but has no Exec field.";
1027 std::transform(m_serviceTypes.cbegin(), m_serviceTypes.cend(), std::back_inserter(ret), [](const KService::ServiceTypeAndPreference &typePref) {
1124 return KPluginName::fromErrorString(i18n("The service '%1' provides no library or the Library key is missing", entryPath()));
1134 return KServiceUtilPrivate::completeBaseName(property(QStringLiteral("X-KDE-AliasFor"), QMetaType::QString).toString());
static KSycoca * self()
Get or create the only instance of KSycoca (read-only)
Definition: ksycoca.cpp:379
void append(const T &value)
bool isNull() const const
QMap::const_iterator constBegin() const const
QString readEntry(const char *key, const char *aDefault=nullptr) const
QString desktopEntryName() const
Returns the filename of the service desktop entry without any extension.
Definition: kservice.cpp:976
bool isEmpty() const const
bool isValid() const const
bool contains(const Key &key) const const
QMap::const_key_value_iterator constKeyValueBegin() const const
QString comment() const
Returns the descriptive comment for the service, if there is one.
Definition: kservice.cpp:1004
QVariant fromValue(const T &value)
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition: ksycocaentry.cpp:61
QString parentApp() const
Name of the application this service belongs to.
Definition: kservice.cpp:796
QVector::const_iterator cend() const const
QStringList serviceTypes() const
Returns the service types that this service supports.
Definition: kservice.cpp:1035
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
T value() const const
QString storageId() const
Returns a normalized ID suitable for storing in configuration files.
Definition: kservice.cpp:871
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void clear()
void append(const T &value)
bool hasServiceType(const QString &serviceTypePtr) const
Checks whether the service supports this service type.
Definition: kservice.cpp:432
QString readEntryUntranslated(const char *key, const QString &aDefault=QString()) const
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
QString genericName() const
Returns the generic name for the service, if there is one (e.g.
Definition: kservice.cpp:1010
QString untranslatedGenericName() const
Returns the untranslated (US English) generic name for the service, if there is one (e....
Definition: kservice.cpp:789
QString writableLocation(QStandardPaths::StandardLocation type)
KService(const QString &name, const QString &exec, const QString &icon)
Construct a temporary service with a given name, exec-line and icon.
Definition: kservice.cpp:383
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
QStringList mimeTypes() const
Returns the list of MIME types that this service supports.
Definition: kservice.cpp:1041
QMap< QString, QString > entryMap() const
QVariant property(const QString &_name, QVariant::Type t) const
Returns the requested property.
Definition: kservice.cpp:527
UnknownType
bool hasMimeType(const QString &mimeType) const
Checks whether the service supports this MIME type.
Definition: kservice.cpp:475
int initialPreference() const
What preference to associate with this service initially (before the user has had any chance to defin...
Definition: kservice.cpp:1065
QString findExecutable(const QString &executableName, const QStringList &paths)
void reserve(int alloc)
int remove(const Key &key)
QMap::iterator insert(const Key &key, const T &value)
static Ptr serviceByMenuId(const QString &_menuId)
Find a service by its menu-id.
Definition: kservice.cpp:659
int size() const const
QMap::iterator end()
void setWorkingDirectory(const QString &workingDir)
Overrides the "Path=" line of the service.
Definition: kservice.cpp:1093
DBusStartupType dbusStartupType() const
Returns the DBUSStartupType supported by this service.
Definition: kservice.cpp:983
QString i18n(const char *text, const TYPE &arg...)
QStringList readXdgListEntry(const char *key, const QStringList &aDefault=QStringList()) const
QMap::iterator find(const Key &key)
static QString newServicePath(bool showInMenu, const QString &suggestedName, QString *menuId=nullptr, const QStringList *reservedMenuIds=nullptr)
Returns a path that can be used to create a new KService based on suggestedName.
Definition: kservice.cpp:890
QString fromLocal8Bit(const char *str, int size)
static KPluginName fromErrorString(const QString &errorString)
QString terminalOptions() const
Returns any options associated with the terminal the service runs in, if it requires a terminal.
Definition: kservice.cpp:953
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
QMap::const_iterator constEnd() const const
bool isApplication() const
Services are either applications (executables) or dlopened libraries (plugins).
Definition: kservice.cpp:926
QVector::const_iterator cbegin() const const
bool isEmpty() const const
SkipEmptyParts
bool isEmpty() const const
bool allowAsDefault() const
Set to true if it is allowed to use this service as the default (main) action for the files it suppor...
Definition: kservice.cpp:1058
QVector< QStringRef > splitRef(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QByteArray toUtf8() const const
QMap::iterator erase(QMap::iterator pos)
QCoreApplication * instance()
static Ptr serviceByDesktopPath(const QString &_path)
Find a service based on its path as returned by entryPath().
Definition: kservice.cpp:647
KCOREADDONS_EXPORT QString tildeExpand(const QString &path)
int toInt(bool *ok, int base) const const
QStringList keywords() const
Returns a list of descriptive keywords the service, if there are any.
Definition: kservice.cpp:1016
void setTerminalOptions(const QString &options)
Definition: kservice.cpp:1077
bool isEmpty() const const
name
KCONFIGCORE_EXPORT bool authorizeControlModule(const QString &menuId)
void setExec(const QString &exec)
Overrides the "Exec=" line of the service.
Definition: kservice.cpp:1083
bool isValid() const const
bool hasKey(const char *key) const
KSharedConfigPtr config()
QString aliasFor() const
A desktop file name that this service is an alias for.
Definition: kservice.cpp:1132
static Ptr serviceType(const QString &_name)
Returns a pointer to the servicetype '_name' or nullptr if the service type is unknown.
Definition: kservicetype.cpp:166
bool toBool() const const
Definition: kservice.h:50
QList< KServiceAction > actions() const
Returns the actions defined in this desktop file.
Definition: kservice.cpp:1109
QString toLower() const const
StandardLocation
bool showOnCurrentPlatform() const
Whether the service should be shown on the current platform (e.g.
Definition: kservice.cpp:742
bool allowMultipleFiles() const
Checks whether this service can handle several files as startup arguments.
Definition: kservice.cpp:843
const char * constData() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
static Ptr serviceByStorageId(const QString &_storageId)
Find a service by its storage-id or desktop-file path.
Definition: kservice.cpp:665
QString & insert(int position, QChar ch)
QString fromLatin1(const char *str, int size)
bool substituteUid() const
Checks whether the service runs with a different user id.
Definition: kservice.cpp:671
bool runOnDiscreteGpu() const
Returns true if the service inidicates that it's preferred to run the application on a discrete graph...
Definition: kservice.cpp:965
QString locateLocal() const
Returns a path that can be used for saving changes to this service.
Definition: kservice.cpp:878
bool terminal() const
Checks whether the service should be run in a terminal.
Definition: kservice.cpp:959
bool isRelativePath(const QString &path)
Definition: kserviceaction.h:29
QString username() const
Returns the user name, if the service runs with a different user id.
Definition: kservice.cpp:677
QString displayName(QStandardPaths::StandardLocation type)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QDataStream & operator>>(QDataStream &in, KDateTime &dateTime)
static Ptr serviceByDesktopName(const QString &_name)
Find a service by the name of its desktop file, not depending on its actual location (as long as it's...
Definition: kservice.cpp:653
Type
bool showInCurrentDesktop() const
Whether the service should be shown in the current desktop (including in context menus).
Definition: kservice.cpp:692
static QString locateLocal(const QString &path)
QString pluginKeyword() const
The keyword to be used when constructing the plugin using KPluginFactory.
Definition: kservice.cpp:812
Q_D(Todo)
bool noDisplay() const
Whether the entry should be suppressed in the K menu.
Definition: kservice.cpp:768
QString toString() const const
QVariant property(const char *name) const const
QMap::const_key_value_iterator constKeyValueEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.