diff -ur kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp kdelibs-4.0.83-kstandarddirs/kdecore/kernel/kstandarddirs.cpp --- kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp 2008-06-18 14:42:26.000000000 +0200 +++ kdelibs-4.0.83-kstandarddirs/kdecore/kernel/kstandarddirs.cpp 2008-06-27 03:54:18.000000000 +0200 @@ -75,9 +75,12 @@ bool checkRestrictions : 1; QMap restrictions; QStringList xdgdata_prefixes; + QString localXdgdatahome; QStringList xdgconf_prefixes; + QString localXdgconfhome; QStringList prefixes; + QString localKdehome; // Directory dictionaries QMap absolutes; @@ -952,12 +955,63 @@ restrictionActive = true; d->dataRestrictionActive = false; // Reset } + const QStringList *prefixList = 0; + QString home; + if (strncmp(type, "xdgdata-", 8) == 0) + { + prefixList = &(d->xdgdata_prefixes); + home=d->localXdgdatahome; + } + else if (strncmp(type, "xdgconf-", 8) == 0) + { + prefixList = &(d->xdgconf_prefixes); + home=d->localXdgconfhome; + } + else + { + prefixList = &d->prefixes; + home=d->localKdehome; + } QStringList dirs; dirs = d->relatives.value(type); QString installdir = installPath( type ); QString installprefix = installPath("kdedir"); + if(!home.isNull()) + { + for (QStringList::ConstIterator it = dirs.begin(); + it != dirs.end(); ++it) + { + if ( (*it).startsWith('%')) + continue; + QString path = realPath( home + *it ); + testdir.setPath(path); + if (restrictionActive) + continue; + if (!candidates.contains(path)) + candidates.append(path); + } + + } + + // make sure we find the path where it's installed + // for non-config, non-exe files, we want the installed path _first_, so /usr/share/kde4 takes precedence over /usr/share + if (strcmp("config", type) && strcmp("exe", type)) { + if (!installdir.isEmpty()) { + bool ok = true; + foreach (const QString &s, candidates) { + if (installdir.startsWith(s)) { + ok = false; + break; + } + } + if (ok) { + candidates.append(installdir); + } + } + } + if (!dirs.isEmpty()) { bool local = true; @@ -983,55 +1037,47 @@ } } - const QStringList *prefixList = 0; - if (strncmp(type, "xdgdata-", 8) == 0) - prefixList = &(d->xdgdata_prefixes); - else if (strncmp(type, "xdgconf-", 8) == 0) - prefixList = &(d->xdgconf_prefixes); - else - prefixList = &d->prefixes; for (QStringList::ConstIterator pit = prefixList->begin(); pit != prefixList->end(); ++pit) { - if((*pit)!=installprefix||installdir.isEmpty()) - { - for (QStringList::ConstIterator it = dirs.begin(); - it != dirs.end(); ++it) - { - if ( (*it).startsWith('%')) - continue; - QString path = realPath( *pit + *it ); - testdir.setPath(path); - if (local && restrictionActive) - continue; - if ((local || testdir.exists()) && !candidates.contains(path)) - candidates.append(path); - } - local = false; + for (QStringList::ConstIterator it = dirs.begin(); + it != dirs.end(); ++it) + { + if ( (*it).startsWith('%')) + continue; + QString path = realPath( *pit + *it ); + testdir.setPath(path); + if (local && restrictionActive) + continue; + if ((local || testdir.exists()) && !candidates.contains(path)) + candidates.append(path); } - else - { - // we have a custom install path, so use this instead of / - testdir.setPath(installdir); - if(testdir.exists() && ! candidates.contains(installdir)) - candidates.append(installdir); - } + // UGLY HACK - forward porting Chris Cheney's HACK - Rex Dieter + if ( local && (!strcmp("config", type))) + candidates.append("/etc/kde/"); + // + local = false; } } - // make sure we find the path where it's installed - if (!installdir.isEmpty()) { - bool ok = true; - foreach (const QString &s, candidates) { - if (installdir.startsWith(s)) { - ok = false; - break; + // for config files, we want the installed path _last_, so profiles take precedence + // for exe files too, so /usr/libexec/kde4 takes precedence over /usr/bin + if (!strcmp("config", type) || !strcmp("exe", type)) { + QString installdir = installPath( type ); + if (!installdir.isEmpty()) { + bool ok = true; + foreach (const QString &s, candidates) { + if (installdir.startsWith(s)) { + ok = false; + break; + } + } + if (ok) { + candidates.append(installdir); } } - if (ok) - candidates.append(installdir); } dirs = d->absolutes.value(type); @@ -1500,6 +1546,7 @@ { localKdeDir = KShell::tildeExpand(localKdeDir); addPrefix(localKdeDir); + d->localKdehome=localKdeDir; } #ifdef Q_WS_MACX @@ -1558,6 +1605,7 @@ localXdgDir = KShell::tildeExpand(localXdgDir); addXdgConfigPrefix(localXdgDir); + d->localXdgconfhome=localXdgDir; for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); ++it) @@ -1606,6 +1654,7 @@ localXdgDir = KShell::tildeExpand(localXdgDir); addXdgDataPrefix(localXdgDir); + d->localXdgdatahome=localXdgDir; for (QStringList::ConstIterator it = xdgdirList.begin(); it != xdgdirList.end(); ++it)