KConfig 5.109.0
kdesktopfile.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1999 Pietro Iglio <iglio@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#ifndef KDESKTOPFILE_H
8#define KDESKTOPFILE_H
9
10#include <kconfig.h>
11
12class KConfigGroup;
13class KDesktopFilePrivate;
14
26class KCONFIGCORE_EXPORT KDesktopFile : public KConfig
27{
28public:
41 explicit KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName);
42
52 explicit KDesktopFile(const QString &fileName);
53
59 ~KDesktopFile() override;
60
70 static bool isDesktopFile(const QString &path);
71
86 static bool isAuthorizedDesktopFile(const QString &path);
87
92 static QString locateLocal(const QString &path);
93
98
103 QString readType() const;
104
109 QString readIcon() const;
110
115 QString readName() const;
116
121 QString readComment() const;
122
127 QString readGenericName() const;
128
133 QString readPath() const;
134
135#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 82)
142 KCONFIGCORE_DEPRECATED_VERSION(5, 82, "For lack of usage.")
143 QString readDevice() const;
144#endif
145
150 QString readUrl() const;
151
156 QStringList readActions() const;
157
163 QStringList readMimeTypes() const;
164
169 KConfigGroup actionGroup(const QString &group);
170
171 // TODO KF6, don't return by const value
172 const KConfigGroup actionGroup(const QString &group) const;
173
179 bool hasActionGroup(const QString &group) const;
180
187 bool hasLinkType() const;
188
193 bool hasApplicationType() const;
194
199 bool hasDeviceType() const;
200
206 bool tryExec() const;
207
212 QString readDocPath() const;
213
214#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 42)
222 KCONFIGCORE_DEPRECATED_VERSION(5, 42, "Not recommended, Desktop Menu Specification defines another mechanism")
223 QStringList sortOrder() const;
224#endif
225
232 bool noDisplay() const;
233
243 KDesktopFile *copyTo(const QString &file) const;
244
248 QString fileName() const;
249
250#if KCONFIGCORE_ENABLE_DEPRECATED_SINCE(5, 89)
254 KCONFIGCORE_DEPRECATED_VERSION(5, 89, "Use locationType() instead.")
255 QStandardPaths::StandardLocation resource() const;
256#endif
257
258private:
259 Q_DISABLE_COPY(KDesktopFile)
260
261 Q_DECLARE_PRIVATE(KDesktopFile)
262};
263
264#endif
A class for one specific group in a KConfig object.
Definition kconfiggroup.h:39
The central class of the KDE configuration data system.
Definition kconfig.h:57
KDE Desktop File Management.
Definition kdesktopfile.h:27
bool hasApplicationType() const
Checks whether there is an entry "Type=Application".
QString readPath() const
Returns the value of the "Path=" entry.
QString fileName() const
Returns the name of the .desktop file that was used to construct this KDesktopFile.
KConfigGroup actionGroup(const QString &group)
Sets the desktop action group.
QString readGenericName() const
Returns the value of the "GenericName=" entry.
QStringList readMimeTypes() const
Returns a list of the "MimeType=" entries.
bool hasDeviceType() const
Checks whether there is an entry "Type=FSDevice".
QString readName() const
Returns the value of the "Name=" entry.
KDesktopFile * copyTo(const QString &file) const
Copies all entries from this config object to a new KDesktopFile object that will save itself to file...
static bool isDesktopFile(const QString &path)
Checks whether this is really a desktop file.
bool noDisplay() const
Whether the entry should be suppressed in menus.
QString readComment() const
Returns the value of the "Comment=" entry.
KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
Constructs a KDesktopFile object.
~KDesktopFile() override
Destructs the KDesktopFile object.
static QString locateLocal(const QString &path)
Returns the location where changes for the .desktop file path should be written to.
bool hasLinkType() const
Checks whether there is a "Type=Link" entry.
bool tryExec() const
Checks whether the TryExec field contains a binary which is found on the local system.
KConfigGroup desktopGroup() const
Returns the main config group (named "Desktop Entry") in a .desktop file.
QString readDocPath() const
Returns the value of the "X-DocPath=" Or "DocPath=" entry.
QString readUrl() const
Returns the value of the "URL=" entry.
QString readIcon() const
Returns the value of the "Icon=" entry.
bool hasActionGroup(const QString &group) const
Returns true if the action group exists, false otherwise.
QString readType() const
Returns the value of the "Type=" entry.
QStringList readActions() const
Returns a list of the "Actions=" entries.
static bool isAuthorizedDesktopFile(const QString &path)
Checks whether the user is authorized to run this desktop file.
KDesktopFile(const QString &fileName)
Constructs a KDesktopFile object.