diff --git a/src/services/kautostart.h b/src/services/kautostart.h --- a/src/services/kautostart.h +++ b/src/services/kautostart.h @@ -71,6 +71,9 @@ * @param entryName the name used to identify the service. If none is * provided then it uses the name registered with KAboutData. * @param parent QObject + * + * @since 5.61 we are allowed to specify an absolute path to the service + * description and it will still work. */ explicit KAutostart(const QString &entryName = QString(), QObject *parent = nullptr); diff --git a/src/services/kautostart.cpp b/src/services/kautostart.cpp --- a/src/services/kautostart.cpp +++ b/src/services/kautostart.cpp @@ -23,6 +23,7 @@ #include "kconfiggroup.h" #include +#include #include #include @@ -72,17 +73,22 @@ : QObject(parent), d(new KAutostartPrivate) { - if (entryName.isEmpty()) { - d->name = QCoreApplication::applicationName(); + const bool isAbsolute = QDir::isAbsolutePath(entryName); + if (isAbsolute) { + d->name = entryName.mid(entryName.lastIndexOf(QLatin1Char('/')) + 1); } else { - d->name = entryName; - } + if (entryName.isEmpty()) { + d->name = QCoreApplication::applicationName(); + } else { + d->name = entryName; + } - if (!d->name.endsWith(QLatin1String(".desktop"))) { - d->name.append(QStringLiteral(".desktop")); + if (!d->name.endsWith(QLatin1String(".desktop"))) { + d->name.append(QStringLiteral(".desktop")); + } } - const QString path = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("autostart/") + d->name); + const QString path = isAbsolute ? entryName : QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("autostart/") + d->name); if (path.isEmpty()) { // just a new KDesktopFile, since we have nothing to use d->df = new KDesktopFile(QStandardPaths::GenericConfigLocation, QStringLiteral("autostart/") + d->name);