KConfig
kdesktopfile.cpp
40KDesktopFile::KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
66 const QStringList genericConfig = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
68 auto it = std::find_if(genericConfig.crbegin(), genericConfig.crend(), [&path](const QString &dir) {
72 return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + slash + QStringView(path).mid(it->size() + 1);
77 const QStringList lstGenericDataLocation = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
84 // What now? The desktop file doesn't come from XDG_DATA_DIRS. Use filename only and hope for the best.
87 return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + slash + relativePath;
117 const QStringList appsDirs = QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation);
118 auto it = std::find_if(appsDirs.cbegin(), appsDirs.cend(), [&realPath, &path](const QString &prefix) {
120 return info.exists() && info.isDir() && (realPath.startsWith(info.canonicalFilePath(), sensitivity) || path.startsWith(info.canonicalFilePath()));
127 const QStringList lstConfigPath = QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
128 auto configIt = std::find_if(lstConfigPath.cbegin(), lstConfigPath.cend(), [&realPath, &autostartDir](const QString &xdgDataPrefix) {
142 qCWarning(KCONFIG_CORE_LOG) << "Access to" << path << "denied because of 'run_desktop_files' restriction.";
153 qCInfo(KCONFIG_CORE_LOG) << "Access to" << path << "denied, not owned by root and executable flag not set.";
316 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:223
void reparseConfiguration()
Updates the state of this object to match the persistent storage.
Definition kconfig.cpp:647
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:542
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:245
QString fileName() const
Returns the name of the .desktop file that was used to construct this KDesktopFile.
Definition kdesktopfile.cpp:299
KConfigGroup actionGroup(const QString &group)
Sets the desktop action group.
Definition kdesktopfile.cpp:225
QString readGenericName() const
Returns the value of the "GenericName=" entry.
Definition kdesktopfile.cpp:181
QStringList readMimeTypes() const
Returns a list of the "MimeType=" entries.
Definition kdesktopfile.cpp:219
bool hasDeviceType() const
Checks whether there is an entry "Type=FSDevice".
Definition kdesktopfile.cpp:250
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:292
bool noDisplay() const
Whether the entry should be suppressed in menus.
Definition kdesktopfile.cpp:304
QString readComment() const
Returns the value of the "Comment=" entry.
Definition kdesktopfile.cpp:175
KDesktopFile(QStandardPaths::StandardLocation resourceType, const QString &fileName)
Constructs a KDesktopFile object.
Definition kdesktopfile.cpp:40
static bool isDesktopFile(const QString &path)
Checks whether this is really a desktop file.
Definition kdesktopfile.cpp:90
bool tryExec() const
Checks whether the TryExec field contains a binary which is found on the local system.
Definition kdesktopfile.cpp:255
KConfigGroup desktopGroup() const
Returns the main config group (named "Desktop Entry") in a .desktop file.
Definition kdesktopfile.cpp:55
static QString locateLocal(const QString &path)
Returns the location where changes for the .desktop file path should be written to.
Definition kdesktopfile.cpp:61
QString readDocPath() const
Returns the value of the "X-DocPath=" Or "DocPath=" entry.
Definition kdesktopfile.cpp:286
static bool isAuthorizedDesktopFile(const QString &path)
Checks whether the user is authorized to run this desktop file.
Definition kdesktopfile.cpp:95
bool hasActionGroup(const QString &group) const
Returns true if the action group exists, false otherwise.
Definition kdesktopfile.cpp:235
QStringList readActions() const
Returns a list of the "Actions=" entries.
Definition kdesktopfile.cpp:213
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 Mon Nov 18 2024 12:18:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.