mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: call static KStandardDirs methods as such
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
8b9fc25d48
commit
b8d4dc0dc4
7 changed files with 20 additions and 20 deletions
|
@ -118,7 +118,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString& path)
|
||||||
kdePrefixes += dirs->resourceDirs("xdgdata-apps");
|
kdePrefixes += dirs->resourceDirs("xdgdata-apps");
|
||||||
kdePrefixes += dirs->resourceDirs("autostart");
|
kdePrefixes += dirs->resourceDirs("autostart");
|
||||||
|
|
||||||
const QString realPath = KGlobal::dirs()->realPath(path);
|
const QString realPath = KStandardDirs::realPath(path);
|
||||||
|
|
||||||
// Check if the .desktop file is installed as part of KDE or XDG.
|
// Check if the .desktop file is installed as part of KDE or XDG.
|
||||||
foreach (const QString &prefix, kdePrefixes) {
|
foreach (const QString &prefix, kdePrefixes) {
|
||||||
|
|
|
@ -70,7 +70,7 @@ void KStandarddirsTest::testChangeSaveLocation()
|
||||||
const QString newSaveLoc = m_kdehome + "/newconfigdir/";
|
const QString newSaveLoc = m_kdehome + "/newconfigdir/";
|
||||||
//cData.dirs()->addResourceDir("config", newSaveLoc); // can't be done, absolute paths have less priority than relative paths
|
//cData.dirs()->addResourceDir("config", newSaveLoc); // can't be done, absolute paths have less priority than relative paths
|
||||||
cData.dirs()->addResourceType("config", 0, "newconfigdir");
|
cData.dirs()->addResourceType("config", 0, "newconfigdir");
|
||||||
QCOMPARE_PATHS(KGlobal::dirs()->realPath(cData.dirs()->saveLocation("config")), newSaveLoc);
|
QCOMPARE_PATHS(KStandardDirs::realPath(cData.dirs()->saveLocation("config")), newSaveLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isKdelibsInstalled()
|
static bool isKdelibsInstalled()
|
||||||
|
@ -301,14 +301,14 @@ void KStandarddirsTest::testAddResourceDir()
|
||||||
|
|
||||||
KGlobal::dirs()->addResourceDir("here", dir);
|
KGlobal::dirs()->addResourceDir("here", dir);
|
||||||
ret = KStandardDirs::locate( "here", file );
|
ret = KStandardDirs::locate( "here", file );
|
||||||
QCOMPARE_PATHS(ret, KGlobal::dirs()->realPath(dir) + "kstandarddirstest.cpp");
|
QCOMPARE_PATHS(ret, KStandardDirs::realPath(dir) + "kstandarddirstest.cpp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void KStandarddirsTest::testSetXdgDataDirs()
|
void KStandarddirsTest::testSetXdgDataDirs()
|
||||||
{
|
{
|
||||||
// By default we should have KDEDIR/share/applications in `kde4-config --path xdgdata-apps`
|
// By default we should have KDEDIR/share/applications in `kde4-config --path xdgdata-apps`
|
||||||
const QStringList dirs = KGlobal::dirs()->resourceDirs("xdgdata-apps");
|
const QStringList dirs = KGlobal::dirs()->resourceDirs("xdgdata-apps");
|
||||||
const QString kdeDataApps = KGlobal::dirs()->realPath(KDEDIR "/share/applications/");
|
const QString kdeDataApps = KStandardDirs::realPath(KDEDIR "/share/applications/");
|
||||||
if (!dirs.contains(kdeDataApps)) {
|
if (!dirs.contains(kdeDataApps)) {
|
||||||
kDebug() << "ERROR:" << kdeDataApps << "not in" << dirs;
|
kDebug() << "ERROR:" << kdeDataApps << "not in" << dirs;
|
||||||
kDebug() << "XDG_DATA_DIRS=" << qgetenv("XDG_DATA_DIRS");
|
kDebug() << "XDG_DATA_DIRS=" << qgetenv("XDG_DATA_DIRS");
|
||||||
|
@ -350,7 +350,7 @@ void KStandarddirsTest::testSymlinkResolution()
|
||||||
// The issue at this point is that saveLoc does not actually exist yet.
|
// The issue at this point is that saveLoc does not actually exist yet.
|
||||||
QVERIFY(QDir(saveLoc).canonicalPath().isEmpty()); // this is why we can't use canonicalPath
|
QVERIFY(QDir(saveLoc).canonicalPath().isEmpty()); // this is why we can't use canonicalPath
|
||||||
QVERIFY(!QFile::exists(saveLoc));
|
QVERIFY(!QFile::exists(saveLoc));
|
||||||
QCOMPARE(saveLoc, KGlobal::dirs()->realPath(saveLoc)); // must be resolved
|
QCOMPARE(saveLoc, KStandardDirs::realPath(saveLoc)); // must be resolved
|
||||||
QCOMPARE(saveLoc, expected);
|
QCOMPARE(saveLoc, expected);
|
||||||
QVERIFY(QDir(m_kdehome).mkpath("real/test")); // KConfig calls mkdir on its own, we simulate that here
|
QVERIFY(QDir(m_kdehome).mkpath("real/test")); // KConfig calls mkdir on its own, we simulate that here
|
||||||
const QString sameSaveLoc = KGlobal::dirs()->resourceDirs("david").first();
|
const QString sameSaveLoc = KGlobal::dirs()->resourceDirs("david").first();
|
||||||
|
@ -358,10 +358,10 @@ void KStandarddirsTest::testSymlinkResolution()
|
||||||
QCOMPARE(sameSaveLoc, KGlobal::dirs()->saveLocation("david"));
|
QCOMPARE(sameSaveLoc, KGlobal::dirs()->saveLocation("david"));
|
||||||
|
|
||||||
// While we're here...
|
// While we're here...
|
||||||
QCOMPARE(KGlobal::dirs()->realPath(QString()), QString());
|
QCOMPARE(KStandardDirs::realPath(QString()), QString());
|
||||||
QCOMPARE(KGlobal::dirs()->realPath(QString("/")), QString("/"));
|
QCOMPARE(KStandardDirs::realPath(QString("/")), QString("/"));
|
||||||
|
|
||||||
QCOMPARE(KGlobal::dirs()->realPath(QString("/does_not_exist/")), QString("/does_not_exist/"));
|
QCOMPARE(KStandardDirs::realPath(QString("/does_not_exist/")), QString("/does_not_exist/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// To find multithreading bugs: valgrind --tool=helgrind ./kstandarddirstest testThreads
|
// To find multithreading bugs: valgrind --tool=helgrind ./kstandarddirstest testThreads
|
||||||
|
|
|
@ -429,7 +429,7 @@ VFolderMenu::absoluteDir(const QString &_dir, const QString &baseDir, bool keepR
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!relative)
|
if (!relative)
|
||||||
dir = KGlobal::dirs()->realPath(dir);
|
dir = KStandardDirs::realPath(dir);
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +745,7 @@ VFolderMenu::locateMenuFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
if (!QDir::isRelativePath(fileName))
|
if (!QDir::isRelativePath(fileName))
|
||||||
{
|
{
|
||||||
if (KGlobal::dirs()->exists(fileName))
|
if (KStandardDirs::exists(fileName))
|
||||||
return fileName;
|
return fileName;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,7 @@ VFolderMenu::locateDirectoryFile(const QString &fileName)
|
||||||
|
|
||||||
if (!QDir::isRelativePath(fileName))
|
if (!QDir::isRelativePath(fileName))
|
||||||
{
|
{
|
||||||
if (KGlobal::dirs()->exists(fileName))
|
if (KStandardDirs::exists(fileName))
|
||||||
return fileName;
|
return fileName;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ VFolderMenu::locateDirectoryFile(const QString &fileName)
|
||||||
foreach(const QString &it, m_directoryDirs)
|
foreach(const QString &it, m_directoryDirs)
|
||||||
{
|
{
|
||||||
const QString tmp = it+fileName;
|
const QString tmp = it+fileName;
|
||||||
if (KGlobal::dirs()->exists(tmp))
|
if (KStandardDirs::exists(tmp))
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -632,7 +632,7 @@ void KIconLoader::addExtraDesktopThemes()
|
||||||
QStringList::ConstIterator it2;
|
QStringList::ConstIterator it2;
|
||||||
for (it2=lst.begin(); it2!=lst.end(); ++it2)
|
for (it2=lst.begin(); it2!=lst.end(); ++it2)
|
||||||
{
|
{
|
||||||
if (!KGlobal::dirs()->exists(*it + *it2 + "/index.theme"))
|
if (!KStandardDirs::exists(*it + *it2 + "/index.theme"))
|
||||||
continue;
|
continue;
|
||||||
r=readlink( QFile::encodeName(*it + *it2) , buf, sizeof(buf)-1);
|
r=readlink( QFile::encodeName(*it + *it2) , buf, sizeof(buf)-1);
|
||||||
if ( r>0 )
|
if ( r>0 )
|
||||||
|
|
|
@ -137,10 +137,10 @@ KIconTheme::KIconTheme(const QString &name, const QString &appName)
|
||||||
|
|
||||||
for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
|
for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
|
||||||
const QString cDir = *it + name + '/';
|
const QString cDir = *it + name + '/';
|
||||||
if (KGlobal::dirs()->exists(cDir)) {
|
if (KStandardDirs::exists(cDir)) {
|
||||||
themeDirs += cDir;
|
themeDirs += cDir;
|
||||||
if (d->mDir.isEmpty()) {
|
if (d->mDir.isEmpty()) {
|
||||||
if (KGlobal::dirs()->exists(cDir + "index.theme")) {
|
if (KStandardDirs::exists(cDir + "index.theme")) {
|
||||||
d->mDir = cDir;
|
d->mDir = cDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ KIconTheme::KIconTheme(const QString &name, const QString &appName)
|
||||||
KConfigGroup cg(sharedConfig, *it);
|
KConfigGroup cg(sharedConfig, *it);
|
||||||
for (itDir=themeDirs.constBegin(); itDir!=themeDirs.constEnd(); ++itDir) {
|
for (itDir=themeDirs.constBegin(); itDir!=themeDirs.constEnd(); ++itDir) {
|
||||||
const QString currentDir(*itDir + *it + '/');
|
const QString currentDir(*itDir + *it + '/');
|
||||||
if (!addedDirs.contains(currentDir) && KGlobal::dirs()->exists(currentDir)) {
|
if (!addedDirs.contains(currentDir) && KStandardDirs::exists(currentDir)) {
|
||||||
addedDirs.insert(currentDir);
|
addedDirs.insert(currentDir);
|
||||||
KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg);
|
KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg);
|
||||||
if (!dir->isValid()) {
|
if (!dir->isValid()) {
|
||||||
|
@ -483,7 +483,7 @@ QStringList KIconTheme::list()
|
||||||
if ((*it2).startsWith(QLatin1String("default.")) ) {
|
if ((*it2).startsWith(QLatin1String("default.")) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!KGlobal::dirs()->exists(*it + *it2 + "/index.theme")) {
|
if (!KStandardDirs::exists(*it + *it2 + "/index.theme")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
KIconTheme oink(*it2);
|
KIconTheme oink(*it2);
|
||||||
|
|
|
@ -149,7 +149,7 @@ private Q_SLOTS:
|
||||||
// as the "data" resource. But if the file is installed, then it will be
|
// as the "data" resource. But if the file is installed, then it will be
|
||||||
// preferred (because KStandardDirs::resourceDirs() looks at relative paths first)
|
// preferred (because KStandardDirs::resourceDirs() looks at relative paths first)
|
||||||
// So we have to expect that one -or- the other will be found.
|
// So we have to expect that one -or- the other will be found.
|
||||||
const QString dataDir = KGlobal::dirs()->realPath(KDESRCDIR "/../../");
|
const QString dataDir = KStandardDirs::realPath(KDESRCDIR "/../../");
|
||||||
KGlobal::dirs()->addResourceDir("data", dataDir);
|
KGlobal::dirs()->addResourceDir("data", dataDir);
|
||||||
|
|
||||||
const QString appName = "kdewidgets";
|
const QString appName = "kdewidgets";
|
||||||
|
@ -173,7 +173,7 @@ private Q_SLOTS:
|
||||||
|
|
||||||
void testAppPicsDir_KIcon()
|
void testAppPicsDir_KIcon()
|
||||||
{
|
{
|
||||||
const QString dataDir = KGlobal::dirs()->realPath(KDESRCDIR "/../../");
|
const QString dataDir = KStandardDirs::realPath(KDESRCDIR "/../../");
|
||||||
KGlobal::dirs()->addResourceDir("data", dataDir);
|
KGlobal::dirs()->addResourceDir("data", dataDir);
|
||||||
// #### This test is broken; it passes even if appName is set to foobar, because
|
// #### This test is broken; it passes even if appName is set to foobar, because
|
||||||
// KIcon::pixmap returns an unknown icon if it can't find the real icon...
|
// KIcon::pixmap returns an unknown icon if it can't find the real icon...
|
||||||
|
|
|
@ -538,7 +538,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
||||||
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
||||||
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
||||||
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
||||||
hasWallpapers = KGlobal::dirs()->exists(KStandardDirs::locateLocal("data", QLatin1String("desktoptheme/") + theme + QLatin1String("/wallpapers/")));
|
hasWallpapers = KStandardDirs::exists(KStandardDirs::locateLocal("data", QLatin1String("desktoptheme/") + theme + QLatin1String("/wallpapers/")));
|
||||||
|
|
||||||
if (realTheme && isDefault && writeSettings) {
|
if (realTheme && isDefault && writeSettings) {
|
||||||
// we're the default theme, let's save our state
|
// we're the default theme, let's save our state
|
||||||
|
|
Loading…
Add table
Reference in a new issue