Make sure the plasma desktop scripts are sorted in the correct order

Instead of sorting the scripts according to their absolute paths,
which would cause scripts installed by packages to always end at
the top, scripts should be sorted by their relative path i.e.
plasma scripts from each directory that occurs in the path
should be sorted and then merged together to form a super list

REVIEWED BY: Marco Martin
This commit is contained in:
Rohan Garg 2012-08-31 15:21:11 +05:30 committed by Marco Martin
parent 7c6d8e8377
commit 6095abcdbf

View File

@ -676,8 +676,24 @@ QStringList ScriptEngine::pendingUpdateScripts()
QStringList ScriptEngine::defaultLayoutScripts()
{
const QString appName = KGlobal::activeComponent().aboutData()->appName();
QStringList scripts = KGlobal::dirs()->findAllResources("data", appName + "/init/*.js");
scripts.sort();
QStringList appNameDirs = KGlobal::dirs()->findDirs("data", appName);
QStringList scripts;
QDir appDir;
QFileInfoList scriptList;
foreach (const QString &appNameDir, appNameDirs) {
appDir.setPath(appNameDir + QLatin1String("init/"));
if (appDir.exists()) {
scriptList = appDir.entryInfoList(QStringList("*.js"),
QDir::NoFilter,
QDir::Name);
foreach (const QFileInfo &script, scriptList) {
if (script.exists()) {
scripts.append(script.absoluteFilePath());
}
}
}
}
QStringList scriptPaths;