KDesktopFile Class
Header: | #include <KDesktopFile> |
Inherits: | KConfig |
Public Functions
KDesktopFile(const QString &fileName) | |
KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName) | |
virtual | ~KDesktopFile() override |
KConfigGroup | actionGroup(const QString &group) |
KConfigGroup | actionGroup(const QString &group) const |
(since 6.0) QList<KDesktopFileAction> | actions() const |
KDesktopFile * | copyTo(const QString &file) const |
KConfigGroup | desktopGroup() const |
QString | fileName() const |
bool | hasActionGroup(const QString &group) const |
bool | hasApplicationType() const |
bool | hasDeviceType() const |
bool | hasLinkType() const |
(since 4.1) bool | noDisplay() const |
QStringList | readActions() const |
QString | readComment() const |
QString | readDocPath() const |
QString | readGenericName() const |
QString | readIcon() const |
(since 5.15) QStringList | readMimeTypes() const |
QString | readName() const |
QString | readPath() const |
QString | readType() const |
QString | readUrl() const |
bool | tryExec() const |
Static Public Members
bool | isAuthorizedDesktopFile(const QString &path) |
bool | isDesktopFile(const QString &path) |
QString | locateLocal(const QString &path) |
Detailed Description
This class implements KDE's support for the freedesktop.org Desktop Entry Spec.
See also KConfigBase and KConfig.
Member Function Documentation
[explicit]
KDesktopFile::KDesktopFile(const QString &fileName)
Constructs a KDesktopFile object.
See QStandardPaths for more information on resources.
fileName The name or path of the desktop file. If it is not absolute, it will be located using the resource type ApplicationsLocation
[explicit]
KDesktopFile::KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
Constructs a KDesktopFile object.
See QStandardPaths for more information on resources.
resourceType Allows you to change what sort of resource to search for if fileName is not absolute. For instance, you might want to specify GenericConfigLocation.
fileName The name or path of the desktop file. If it is not absolute, it will be located using the resource type resourceType.
[override virtual noexcept]
KDesktopFile::~KDesktopFile()
Destructs the KDesktopFile object.
Writes back any changed configuration entries.
KConfigGroup KDesktopFile::actionGroup(const QString &group)
Sets the desktop action group.
group the new action group
KConfigGroup KDesktopFile::actionGroup(const QString &group) const
Sets the desktop action group.
group the new action group
[since 6.0]
QList<KDesktopFileAction> KDesktopFile::actions() const
Returns the desktop file's actions
This function was introduced in 6.0.
KDesktopFile *KDesktopFile::copyTo(const QString &file) const
Copies all entries from this config object to a new KDesktopFile object that will save itself to file.
Actual saving to file happens when the returned object is destructed or when sync() is called upon it.
file the new KDesktopFile object it will save itself to.
KConfigGroup KDesktopFile::desktopGroup() const
Returns the main config group (named "Desktop Entry") in a .desktop file.
QString KDesktopFile::fileName() const
Returns the name of the .desktop file that was used to construct this KDesktopFile.
bool KDesktopFile::hasActionGroup(const QString &group) const
Returns true
if the action group exists, false
otherwise
group the action group to test
bool KDesktopFile::hasApplicationType() const
Checks whether there is an entry "Type=Application".
bool KDesktopFile::hasDeviceType() const
Checks whether there is an entry "Type=FSDevice".
bool KDesktopFile::hasLinkType() const
Checks whether there is a "Type=Link" entry.
The link points to the "URL=" entry.
[static]
bool KDesktopFile::isAuthorizedDesktopFile(const QString &path)
Checks whether the user is authorized to run this desktop file. By default users are authorized to run all desktop files but the KIOSK framework can be used to activate certain restrictions. See README.kiosk for more information.
Note that desktop files that are not in a standard location (as specified by XDG_DATA_DIRS) must have their executable bit set to be authorized, regardless of KIOSK settings, to prevent users from inadvertently running trojan desktop files.
path the file to check
Returns true
if the user is authorized to run the file
[static]
bool KDesktopFile::isDesktopFile(const QString &path)
Checks whether this is really a desktop file.
The check is performed looking at the file extension (the file is not opened). Currently, the only valid extension is ".desktop".
path the path of the file to check
Returns true
if the file appears to be a desktop file.
[static]
QString KDesktopFile::locateLocal(const QString &path)
Returns the location where changes for the .desktop file path should be written to.
[since 4.1]
bool KDesktopFile::noDisplay() const
Whether the entry should be suppressed in menus.
This handles the NoDisplay key
This function was introduced in 4.1.
QStringList KDesktopFile::readActions() const
Returns a list of the "Actions=" entries
QString KDesktopFile::readComment() const
Returns the value of the "Comment=" entry, or QString() if not specified
QString KDesktopFile::readDocPath() const
Returns the value of the "X-DocPath=" Or "DocPath=" entry.
QString KDesktopFile::readGenericName() const
Returns the value of the "GenericName=" entry, or QString() if not specified
QString KDesktopFile::readIcon() const
Returns the value of the "Icon=" entry, or QString() if not specified
[since 5.15]
QStringList KDesktopFile::readMimeTypes() const
Returns a list of the "MimeType=" entries
This function was introduced in 5.15.
QString KDesktopFile::readName() const
Returns the value of the "Name=" entry, or QString() if not specified
QString KDesktopFile::readPath() const
Returns the value of the "Path=" entry, or QString() if not specified
QString KDesktopFile::readType() const
Returns the value of the "Type=" entry, or QString() if not specified
QString KDesktopFile::readUrl() const
Returns the value of the "URL=" entry, or QString() if not specified
bool KDesktopFile::tryExec() const
Checks whether the TryExec field contains a binary which is found on the local system.