Fix initial loading of autostart program names

When the auto start entry is first loaded, the module only take into account
the "Name" entry in the desktop file. However, after editing or when adding
a new one, `KService::name` is used which uses the file name as a fallback.
This causes the name to "mysteriously" appear and disappear when
checking the setting or reopenning the setting page.

This change fixes the issue by using the same function `KService::name`
in all cases. This is less efficient but easier to maintain than
duplicating the logic from `KService`.

Also use the newly available `KService` instance to replace some of
the manual reading of the desktop file.
The handling of `NotShowIn` and `OnlyShowIn` are left in place since
`KService::showInCurrentDesktop()` takes into account the current running
environment rather than only `KDE`.
Changing that behavior should be a separate issue.

Test Plan: Tested on 5.18.3. Unable to test on master (5.18.80)

Reviewers: apol, davidedmundson

Reviewed By: apol, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision:
parent 90ac7c21
......@@ -190,8 +190,9 @@ void Autostart::load()
bool desktopFile = filename.endsWith(QLatin1String(".desktop"));
if ( desktopFile ) {
KDesktopFile config(fi.absoluteFilePath());
//kDebug() << fi.absoluteFilePath() << "trying" << config.desktopGroup().readEntry("Exec");
QStringList commandLine = KShell::splitArgs(config.desktopGroup().readEntry("Exec"));
KService service(&config);
//kDebug() << fi.absoluteFilePath() << "trying" << service.exec();
QStringList commandLine = KShell::splitArgs(service.exec());
if (commandLine.isEmpty()) {
......@@ -204,7 +205,7 @@ void Autostart::load()
DesktopStartItem *item = new DesktopStartItem( fi.absoluteFilePath(), m_programItem, this );
const KConfigGroup grp = config.desktopGroup();
const bool hidden = grp.readEntry("Hidden", false);
const bool hidden = service.isDeleted();
const QStringList notShowList = grp.readXdgListEntry("NotShowIn");
const QStringList onlyShowList = grp.readXdgListEntry("OnlyShowIn");
......@@ -215,7 +216,7 @@ void Autostart::load()
int indexPath = m_paths.indexOf((item->fileName().adjusted(QUrl::RemoveFilename).toString() ) );
if ( indexPath > 2 )
indexPath = 0; //.kde/share/autostart and .config/autostart load desktop at startup
addItem(item, config.readName(), m_pathName.value(indexPath), grp.readEntry("Exec"), disabled );
addItem(item,, m_pathName.value(indexPath), service.exec(), disabled );
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment