KConfig 5.109.0
|
KDE Desktop File Management. More...
#include <KDesktopFile>
Public Member Functions | |
KDesktopFile (const QString &fileName) | |
Constructs a KDesktopFile object. | |
KDesktopFile (QStandardPaths::StandardLocation resourceType, const QString &fileName) | |
Constructs a KDesktopFile object. | |
~KDesktopFile () override | |
Destructs the KDesktopFile object. | |
KConfigGroup | actionGroup (const QString &group) |
Sets the desktop action group. | |
const KConfigGroup | actionGroup (const QString &group) const |
KDesktopFile * | copyTo (const QString &file) const |
Copies all entries from this config object to a new KDesktopFile object that will save itself to file . | |
KConfigGroup | desktopGroup () const |
Returns the main config group (named "Desktop Entry") in a .desktop file. | |
QString | fileName () const |
Returns the name of the .desktop file that was used to construct this KDesktopFile. | |
bool | hasActionGroup (const QString &group) const |
Returns true if the action group exists, false otherwise. | |
bool | hasApplicationType () const |
Checks whether there is an entry "Type=Application". | |
bool | hasDeviceType () const |
Checks whether there is an entry "Type=FSDevice". | |
bool | hasLinkType () const |
Checks whether there is a "Type=Link" entry. | |
bool | noDisplay () const |
Whether the entry should be suppressed in menus. | |
QStringList | readActions () const |
Returns a list of the "Actions=" entries. | |
QString | readComment () const |
Returns the value of the "Comment=" entry. | |
QString | readDocPath () const |
Returns the value of the "X-DocPath=" Or "DocPath=" entry. | |
QString | readGenericName () const |
Returns the value of the "GenericName=" entry. | |
QString | readIcon () const |
Returns the value of the "Icon=" entry. | |
QStringList | readMimeTypes () const |
Returns a list of the "MimeType=" entries. | |
QString | readName () const |
Returns the value of the "Name=" entry. | |
QString | readPath () const |
Returns the value of the "Path=" entry. | |
QString | readType () const |
Returns the value of the "Type=" entry. | |
QString | readUrl () const |
Returns the value of the "URL=" entry. | |
bool | tryExec () const |
Checks whether the TryExec field contains a binary which is found on the local system. | |
![]() | |
KConfig (const QString &file, const QString &backend, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation) | |
KConfig (const QString &file=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation) | |
Creates a KConfig object to manipulate a configuration file for the current application. | |
void | checkUpdate (const QString &id, const QString &updateFile) |
Ensures that the configuration file contains a certain update. | |
KConfig * | copyTo (const QString &file, KConfig *config=nullptr) const |
Copies all entries from this config object to a new config object that will save itself to file . | |
QMap< QString, QString > | entryMap (const QString &aGroup=QString()) const |
Returns a map (tree) of entries in a particular group. | |
QStringList | groupList () const override |
bool | isDirty () const |
Returns true if sync has any changes to write out. | |
QStandardPaths::StandardLocation | locationType () const |
Returns the standard location enum passed to the constructor. | |
void | markAsClean () override |
QString | name () const |
Returns the filename used to store the configuration. | |
OpenFlags | openFlags () const |
void | reparseConfiguration () |
Updates the state of this object to match the persistent storage. | |
bool | sync () override |
AccessMode | accessMode () const override |
bool | isConfigWritable (bool warnUser) |
Whether the configuration can be written to. | |
void | addConfigSources (const QStringList &sources) |
extra config files | |
QStringList | additionalConfigSources () const |
Returns a list of the additional configuration sources used in this object. | |
QString | locale () const |
locales | |
bool | setLocale (const QString &aLocale) |
Sets the locale to aLocale . | |
void | setReadDefaults (bool b) |
defaults | |
bool | readDefaults () const |
bool | isImmutable () const override |
void | setForceGlobal (bool force) |
global | |
bool | forceGlobal () const |
Returns whether all entries are being written to kdeglobals . | |
![]() | |
virtual | ~KConfigBase () |
Destructs the KConfigBase object. | |
virtual AccessMode | accessMode () const =0 |
Returns the access mode of the app-config object. | |
void | deleteGroup (const char *group, WriteConfigFlags flags=Normal) |
Overload for deleteGroup(const QString&, WriteConfigFlags) | |
void | deleteGroup (const QByteArray &group, WriteConfigFlags flags=Normal) |
Overload for deleteGroup(const QString&, WriteConfigFlags) | |
void | deleteGroup (const QString &group, WriteConfigFlags flags=Normal) |
Delete group . | |
KConfigGroup | group (const char *group) |
Overload for group(const QString&) | |
const KConfigGroup | group (const char *group) const |
Const overload for group(const QString&) | |
KConfigGroup | group (const QByteArray &group) |
Overload for group(const QString&) | |
const KConfigGroup | group (const QByteArray &group) const |
Const overload for group(const QString&) | |
KConfigGroup | group (const QString &group) |
Returns an object for the named subgroup. | |
const KConfigGroup | group (const QString &group) const |
Const overload for group(const QString&) | |
virtual QStringList | groupList () const =0 |
Returns a list of groups that are known about. | |
bool | hasGroup (const char *group) const |
Overload for hasGroup(const QString&) const. | |
bool | hasGroup (const QByteArray &group) const |
Overload for hasGroup(const QString&) const. | |
bool | hasGroup (const QString &group) const |
Returns true if the specified group is known about. | |
bool | isGroupImmutable (const char *group) const |
Overload for isGroupImmutable(const QString&) const. | |
bool | isGroupImmutable (const QByteArray &group) const |
Overload for isGroupImmutable(const QString&) const. | |
bool | isGroupImmutable (const QString &group) const |
Can changes be made to the entries in group ? | |
virtual bool | isImmutable () const =0 |
Checks whether this configuration object can be modified. | |
virtual void | markAsClean ()=0 |
Reset the dirty flags of all entries in the entry map, so the values will not be written to disk on a later call to sync(). | |
virtual bool | sync ()=0 |
Syncs the configuration object that this group belongs to. | |
Static Public Member Functions | |
static bool | isAuthorizedDesktopFile (const QString &path) |
Checks whether the user is authorized to run this desktop file. | |
static bool | isDesktopFile (const QString &path) |
Checks whether this is really a desktop file. | |
static QString | locateLocal (const QString &path) |
Returns the location where changes for the .desktop file path should be written to. | |
![]() | |
static QString | mainConfigName () |
Get the name of application config file. | |
static void | setMainConfigName (const QString &str) |
Sets the name of the application config file. | |
Additional Inherited Members | |
![]() | |
enum | OpenFlag { IncludeGlobals = 0x01 , CascadeConfig = 0x02 , SimpleConfig = 0x00 , NoCascade = IncludeGlobals , NoGlobals = CascadeConfig , FullConfig = IncludeGlobals | CascadeConfig } |
Determines how the system-wide and user's global settings will affect the reading of the configuration. More... | |
typedef QFlags< OpenFlag > | OpenFlags |
Stores a combination of #OpenFlag values. | |
![]() | |
enum | AccessMode { NoAccess , ReadOnly , ReadWrite } |
Possible return values for accessMode(). More... | |
enum | WriteConfigFlag { Persistent = 0x01 , Global = 0x02 , Localized = 0x04 , Notify = 0x08 | Persistent , Normal = Persistent } |
Flags to control write entry. More... | |
typedef QFlags< WriteConfigFlag > | WriteConfigFlags |
Stores a combination of #WriteConfigFlag values. | |
![]() | |
__attribute__ ((visibility("hidden"))) explicit KConfig(KConfigPrivate &d) | |
void | deleteGroupImpl (const QByteArray &group, WriteConfigFlags flags=Normal) override |
const KConfigGroup | groupImpl (const QByteArray &b) const override |
KConfigGroup | groupImpl (const QByteArray &b) override |
bool | hasGroupImpl (const QByteArray &group) const override |
bool | isGroupImmutableImpl (const QByteArray &aGroup) const override |
void | virtual_hook (int id, void *data) override |
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. | |
virtual void | deleteGroupImpl (const QByteArray &group, WriteConfigFlags flags=Normal)=0 |
virtual const KConfigGroup | groupImpl (const QByteArray &group) const =0 |
virtual KConfigGroup | groupImpl (const QByteArray &group)=0 |
virtual bool | hasGroupImpl (const QByteArray &group) const =0 |
virtual bool | isGroupImmutableImpl (const QByteArray &group) const =0 |
virtual void | virtual_hook (int id, void *data) |
Virtual hook, used to add new "virtual" functions while maintaining binary compatibility. | |
![]() | |
KConfigPrivate *const | d_ptr |
KDE Desktop File Management.
This class implements KDE's support for the freedesktop.org Desktop Entry Spec.
|
explicit |
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 resType . |
|
explicit |
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 |
|
override |
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 |
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 |
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 |
|
static |
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 |
|
static |
Returns the location where changes for the .desktop file path
should be written to.
bool KDesktopFile::noDisplay | ( | ) | const |
Whether the entry should be suppressed in menus.
This handles the NoDisplay key, but also OnlyShowIn / NotShowIn.
QStringList KDesktopFile::readActions | ( | ) | const |
Returns a list of the "Actions=" entries.
QString KDesktopFile::readComment | ( | ) | const |
Returns the value of the "Comment=" entry.
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.
QString KDesktopFile::readIcon | ( | ) | const |
Returns the value of the "Icon=" entry.
QStringList KDesktopFile::readMimeTypes | ( | ) | const |
Returns a list of the "MimeType=" entries.
QString KDesktopFile::readName | ( | ) | const |
Returns the value of the "Name=" entry.
QString KDesktopFile::readPath | ( | ) | const |
Returns the value of the "Path=" entry.
QString KDesktopFile::readType | ( | ) | const |
Returns the value of the "Type=" entry.
QString KDesktopFile::readUrl | ( | ) | const |
Returns the value of the "URL=" entry.
bool KDesktopFile::tryExec | ( | ) | const |
Checks whether the TryExec field contains a binary which is found on the local system.