KService
kservice.cpp
37 // We are opening a "" service, this means whatever warning we might get is going to be misleading
72 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "does not have a \"Type=Application\" set.";
75 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "instead of \"Application\" or \"Service\"";
95 if ((m_strType == QLatin1String("Application")) && (locationType != QStandardPaths::ApplicationsLocation) && !absPath) {
96 qCWarning(SERVICES) << "The desktop entry file" << entryPath << "has Type=" << m_strType << "but is located under \""
118 m_lstFormFactors = entryMap.take(QStringLiteral("X-KDE-FormFactors")).split(QLatin1Char(' '), Qt::SkipEmptyParts);
123 m_lstKeywords += entryMap.take(QStringLiteral("X-KDE-Keywords")).split(QLatin1Char(' '), Qt::SkipEmptyParts);
151 // do not store other translations like Name[fr]; kbuildsycoca will rerun if we change languages anyway
187 qCWarning(SERVICES) << "The action" << group << "in the desktop file" << q->entryPath() << "has no Name or no Exec key";
195 if (it->first == QLatin1String("Name") || it->first == QLatin1String("Icon") || it->first == QLatin1String("Exec")
203 KServiceAction action(group, cg.readEntry("Name"), cg.readEntry("Icon"), cg.readEntry("Exec"), cg.readEntry("NoDisplay", false), serviceClone);
208 qCWarning(SERVICES) << "The desktop file" << q->entryPath() << "references the action" << group << "but doesn't define it";
255 s << m_strType << m_strName << m_strExec << m_strIcon << term << m_strTerminalOptions << m_strWorkingDirectory << m_strComment << def << m_mapProps
256 << m_strLibrary << dst << m_strDesktopEntryName << m_lstKeywords << m_strGenName << categories << menuId << m_actions << m_lstFormFactors
405 return KConfigGroup::convertToQVariant(_name.toUtf8().constData(), it.value().toString().toUtf8(), QVariant(QMetaType(t)));
463 QList<QStringView> currentDesktops = QStringView(envVar).split(QLatin1Char(':'), Qt::SkipEmptyParts);
479 return std::any_of(currentDesktops.cbegin(), currentDesktops.cend(), [&aList](const auto desktop) {
616 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/applications/") + d->menuId;
619QString KService::newServicePath(bool showInMenu, const QString &suggestedName, QString *menuId, const QStringList *reservedMenuIds)
642 if (!QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("applications/") + result).isEmpty()) {
652 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/applications/") + result;
814 return KServiceUtilPrivate::completeBaseName(property<QString>(QStringLiteral("X-KDE-AliasFor")));
QString readEntryUntranslated(const char *key, const QString &aDefault=QString()) const
bool hasKey(const char *key) const
QStringList readXdgListEntry(const char *key, const QStringList &aDefault=QStringList()) const
QString readEntry(const char *key, const char *aDefault=nullptr) const
QMap< QString, QString > entryMap() const
QStandardPaths::StandardLocation locationType() const
KConfigGroup actionGroup(const QString &group)
QString readName() const
bool tryExec() const
KConfigGroup desktopGroup() const
static QString locateLocal(const QString &path)
bool hasActionGroup(const QString &group) const
QStringList readActions() const
Represents an action in a .desktop file Actions are defined with the config key Actions in the [Deskt...
Definition kserviceaction.h:31
QStringList mimeTypes() const
Returns the list of MIME types that this application supports.
Definition kservice.cpp:726
static Ptr serviceByStorageId(const QString &_storageId)
Find a application by its storage-id or desktop-file path.
Definition kservice.cpp:433
void setExec(const QString &exec)
Overrides the "Exec=" line of the service.
Definition kservice.cpp:786
void setWorkingDirectory(const QString &workingDir)
Overrides the "Path=" line of the application.
Definition kservice.cpp:796
QString storageId() const
Returns a normalized ID suitable for storing in configuration files.
Definition kservice.cpp:600
QString desktopEntryName() const
Returns the filename of the desktop entry without any extension, e.g.
Definition kservice.cpp:696
QStringList keywords() const
Returns a list of descriptive keywords for the application, if there are any.
Definition kservice.cpp:720
void setTerminalOptions(const QString &options)
Definition kservice.cpp:780
QList< KServiceAction > actions() const
Returns the actions defined in this desktop file.
Definition kservice.cpp:806
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:619
bool allowMultipleFiles() const
Checks whether this application can handle several files as startup arguments.
Definition kservice.cpp:572
QStringList supportedProtocols() const
Returns the list of protocols this application supports.
Definition kservice.cpp:756
QString genericName() const
Returns the generic name for the application, if there is one (e.g.
Definition kservice.cpp:714
bool substituteUid() const
Checks whether the application needs to run under a different UID.
Definition kservice.cpp:439
bool terminal() const
Checks whether the application should be run in a terminal.
Definition kservice.cpp:679
QString terminalOptions() const
Returns any options associated with the terminal the application runs in, if it requires a terminal.
Definition kservice.cpp:673
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:262
QString username() const
Returns the user name if the application runs with a different user id.
Definition kservice.cpp:444
QString aliasFor() const
A desktop file name that this application is an alias for.
Definition kservice.cpp:812
QString locateLocal() const
Returns a path that can be used for saving changes to this application.
Definition kservice.cpp:607
static Ptr serviceByDesktopName(const QString &_name)
Find an application by the name of its desktop file, not depending on its actual location (as long as...
Definition kservice.cpp:421
QString menuId() const
Returns the menu ID of the application desktop entry.
Definition kservice.cpp:588
bool showOnCurrentPlatform() const
Whether the application should be shown on the current platform (e.g.
Definition kservice.cpp:499
QString comment() const
Returns the descriptive comment for the application, if there is one.
Definition kservice.cpp:708
QString untranslatedGenericName() const
Returns the untranslated (US English) generic name for the application, if there is one (e....
Definition kservice.cpp:541
QStringList schemeHandlers() const
Returns the list of scheme handlers this application supports.
Definition kservice.cpp:740
QString docPath() const
The path to the documentation for this application.
Definition kservice.cpp:553
std::optional< bool > startupNotify() const
Returns the value of StartupNotify for this service.
Definition kservice.cpp:823
static Ptr serviceByMenuId(const QString &_menuId)
Find a application by its menu-id.
Definition kservice.cpp:427
bool showInCurrentDesktop() const
Whether the application should be shown in the current desktop (including in context menus).
Definition kservice.cpp:457
static Ptr serviceByDesktopPath(const QString &_path)
Find a application based on its path as returned by entryPath().
Definition kservice.cpp:415
bool hasMimeType(const QString &mimeType) const
Checks whether the application supports this MIME type.
Definition kservice.cpp:310
bool runOnDiscreteGpu() const
Returns true if the application indicates that it's preferred to run on a discrete graphics card,...
Definition kservice.cpp:685
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition ksycocaentry.cpp:60
static KSycoca * self()
Get or create the only instance of KSycoca (read-only)
Definition ksycoca.cpp:357
KCOREADDONS_EXPORT QString tildeExpand(const QString &path)
const char * constData() const const
QCoreApplication * instance()
bool isRelativePath(const QString &path)
void append(QList< T > &&value)
const_iterator cbegin() const const
const_iterator cend() const const
bool isEmpty() const const
const_iterator constBegin() const const
const_iterator constEnd() const const
const_key_value_iterator constKeyValueBegin() const const
const_key_value_iterator constKeyValueEnd() const const
bool contains(const Key &key) const const
size_type remove(const Key &key)
T take(const Key &key)
Type
QMimeType mimeTypeForName(const QString &nameOrAlias) const const
name
bool isValid() const const
QVariant property(const char *name) const const
StandardLocation
QString displayName(StandardLocation type)
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QString writableLocation(StandardLocation type)
QString arg(Args &&... args) const const
void clear()
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString fromLatin1(QByteArrayView str)
QString fromLocal8Bit(QByteArrayView str)
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QByteArray toUtf8() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
SkipEmptyParts
QVariant fromValue(T &&value)
bool isValid() const const
bool toBool() const const
QString toString() const const
T value() const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:00:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:00:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.