kdelibs/kdelibs-4.0.83-kstandarddir...

161 lines
5.7 KiB
Diff

diff -up kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp.kstandarddirs kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp
--- kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp.kstandarddirs 2008-06-19 14:23:20.000000000 +0200
+++ kdelibs-4.0.83/kdecore/kernel/kstandarddirs.cpp 2008-06-19 15:44:23.000000000 +0200
@@ -75,9 +75,12 @@ public:
bool checkRestrictions : 1;
QMap<QByteArray, bool> restrictions;
QStringList xdgdata_prefixes;
+ QString localXdgdatahome;
QStringList xdgconf_prefixes;
+ QString localXdgconfhome;
QStringList prefixes;
+ QString localKdehome;
// Directory dictionaries
QMap<QByteArray, QStringList> absolutes;
@@ -952,12 +955,63 @@ QStringList KStandardDirs::resourceDirs(
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 files, we want the installed path _first_, so /usr/share/kde4 takes precedence over /usr/share
+ if (strcmp("config", 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,13 +1037,6 @@ QStringList KStandardDirs::resourceDirs(
}
}
- 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();
@@ -1009,6 +1056,10 @@ QStringList KStandardDirs::resourceDirs(
if ((local || testdir.exists()) && !candidates.contains(path))
candidates.append(path);
}
+ // UGLY HACK - forward porting Chris CHeney's HACK - Rex Dieter
+ if ( local && (!strcmp("config", type)))
+ candidates.append("/etc/kde/");
+ //
local = false;
}
else
@@ -1021,17 +1072,21 @@ QStringList KStandardDirs::resourceDirs(
}
}
- // 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
+ if (!strcmp("config", 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 +1555,7 @@ void KStandardDirs::addKDEDefaults()
{
localKdeDir = KShell::tildeExpand(localKdeDir);
addPrefix(localKdeDir);
+ d->localKdehome=localKdeDir;
}
#ifdef Q_WS_MACX
@@ -1558,6 +1614,7 @@ void KStandardDirs::addKDEDefaults()
localXdgDir = KShell::tildeExpand(localXdgDir);
addXdgConfigPrefix(localXdgDir);
+ d->localXdgconfhome=localXdgDir;
for (QStringList::ConstIterator it = xdgdirList.begin();
it != xdgdirList.end(); ++it)
@@ -1606,6 +1663,7 @@ void KStandardDirs::addKDEDefaults()
localXdgDir = KShell::tildeExpand(localXdgDir);
addXdgDataPrefix(localXdgDir);
+ d->localXdgdatahome=localXdgDir;
for (QStringList::ConstIterator it = xdgdirList.begin();
it != xdgdirList.end(); ++it)