KConfig
kdesktopfile.cpp
42KDesktopFile::KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
68 const QStringList genericConfig = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
70 auto it = std::find_if(genericConfig.crbegin(), genericConfig.crend(), [&path](const QString &dir) {
74 return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + slash + QStringView(path).mid(it->size() + 1);
79 const QStringList lstGenericDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
86 // What now? The desktop file doesn't come from XDG_DATA_DIRS. Use filename only and hope for the best.
89 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + slash + relativePath;
119 const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
122 return info.exists() && info.isDir() && realPath.startsWith(info.canonicalFilePath(), sensitivity);
129 const QStringList lstConfigPath = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
130 auto configIt = std::find_if(lstConfigPath.cbegin(), lstConfigPath.cend(), [&realPath, &autostartDir](const QString &xdgDataPrefix) {
144 qCWarning(KCONFIG_CORE_LOG) << "Access to" << path << "denied because of 'run_desktop_files' restriction.";
155 qCInfo(KCONFIG_CORE_LOG) << "Access to" << path << "denied, not owned by root and executable flag not set.";
318 desktopFileActions << KDesktopFileAction(actionKey, grp.readEntry("Name"), grp.readEntry("Icon"), grp.readEntry("Exec"), fileName());
static Q_INVOKABLE bool authorize(const QString &action)
Returns whether the user is permitted to perform a certain action.
Definition kauthorized.cpp:215
bool hasGroup(const QString &group) const
Returns true if the specified group is known about.
Definition kconfigbase.cpp:16
KConfigGroup group(const QString &group)
Returns an object for the named subgroup.
Definition kconfigbase.cpp:21
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition kconfiggroup.h:216
void reparseConfiguration()
Updates the state of this object to match the persistent storage.
Definition kconfig.cpp:652
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.
Definition kconfig.cpp:546
Class for representing an Action of a desktop file.
Definition kdesktopfileaction.h:21
bool hasApplicationType() const
Checks whether there is an entry "Type=Application".
Definition kdesktopfile.cpp:247
QString fileName() const
Returns the name of the .desktop file that was used to construct this KDesktopFile.
Definition kdesktopfile.cpp:301
KConfigGroup actionGroup(const QString &group)
Sets the desktop action group.
Definition kdesktopfile.cpp:227
QString readGenericName() const
Returns the value of the "GenericName=" entry.
Definition kdesktopfile.cpp:183
QStringList readMimeTypes() const
Returns a list of the "MimeType=" entries.
Definition kdesktopfile.cpp:221
bool hasDeviceType() const
Checks whether there is an entry "Type=FSDevice".
Definition kdesktopfile.cpp:252
KDesktopFile * copyTo(const QString &file) const
Copies all entries from this config object to a new KDesktopFile object that will save itself to file...
Definition kdesktopfile.cpp:294
bool noDisplay() const
Whether the entry should be suppressed in menus.
Definition kdesktopfile.cpp:306
QString readComment() const
Returns the value of the "Comment=" entry.
Definition kdesktopfile.cpp:177
KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
Constructs a KDesktopFile object.
Definition kdesktopfile.cpp:42
static bool isDesktopFile(const QString &path)
Checks whether this is really a desktop file.
Definition kdesktopfile.cpp:92
bool tryExec() const
Checks whether the TryExec field contains a binary which is found on the local system.
Definition kdesktopfile.cpp:257
KConfigGroup desktopGroup() const
Returns the main config group (named "Desktop Entry") in a .desktop file.
Definition kdesktopfile.cpp:57
static QString locateLocal(const QString &path)
Returns the location where changes for the .desktop file path should be written to.
Definition kdesktopfile.cpp:63
QString readDocPath() const
Returns the value of the "X-DocPath=" Or "DocPath=" entry.
Definition kdesktopfile.cpp:288
static bool isAuthorizedDesktopFile(const QString &path)
Checks whether the user is authorized to run this desktop file.
Definition kdesktopfile.cpp:97
bool hasActionGroup(const QString &group) const
Returns true if the action group exists, false otherwise.
Definition kdesktopfile.cpp:237
QStringList readActions() const
Returns a list of the "Actions=" entries.
Definition kdesktopfile.cpp:215
QString path(const QString &relativePath)
bool isRelativePath(const QString &path)
QString canonicalFilePath() const const
const_iterator cbegin() const const
const_iterator cend() const const
const_reverse_iterator crbegin() const const
const_reverse_iterator crend() const const
StandardLocation
QString findExecutable(const QString &executableName, const QStringList &paths)
QStringList standardLocations(StandardLocation type)
QString writableLocation(StandardLocation type)
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
qsizetype lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QStringView mid(qsizetype start, qsizetype length) const const
CaseSensitivity
QUrl fromLocalFile(const QString &localFile)
QString toString(FormattingOptions options) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.