generic: call static KStandardDirs methods as such

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-05 02:04:03 +03:00
parent 8b9fc25d48
commit b8d4dc0dc4
7 changed files with 20 additions and 20 deletions

View file

@ -118,7 +118,7 @@ bool KDesktopFile::isAuthorizedDesktopFile(const QString& path)
kdePrefixes += dirs->resourceDirs("xdgdata-apps");
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.
foreach (const QString &prefix, kdePrefixes) {

View file

@ -70,7 +70,7 @@ void KStandarddirsTest::testChangeSaveLocation()
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()->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()
@ -301,14 +301,14 @@ void KStandarddirsTest::testAddResourceDir()
KGlobal::dirs()->addResourceDir("here", dir);
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()
{
// By default we should have KDEDIR/share/applications in `kde4-config --path 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)) {
kDebug() << "ERROR:" << kdeDataApps << "not in" << 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.
QVERIFY(QDir(saveLoc).canonicalPath().isEmpty()); // this is why we can't use canonicalPath
QVERIFY(!QFile::exists(saveLoc));
QCOMPARE(saveLoc, KGlobal::dirs()->realPath(saveLoc)); // must be resolved
QCOMPARE(saveLoc, KStandardDirs::realPath(saveLoc)); // must be resolved
QCOMPARE(saveLoc, expected);
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();
@ -358,10 +358,10 @@ void KStandarddirsTest::testSymlinkResolution()
QCOMPARE(sameSaveLoc, KGlobal::dirs()->saveLocation("david"));
// While we're here...
QCOMPARE(KGlobal::dirs()->realPath(QString()), QString());
QCOMPARE(KGlobal::dirs()->realPath(QString("/")), QString("/"));
QCOMPARE(KStandardDirs::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

View file

@ -429,7 +429,7 @@ VFolderMenu::absoluteDir(const QString &_dir, const QString &baseDir, bool keepR
}
if (!relative)
dir = KGlobal::dirs()->realPath(dir);
dir = KStandardDirs::realPath(dir);
return dir;
}
@ -745,7 +745,7 @@ VFolderMenu::locateMenuFile(const QString &fileName)
{
if (!QDir::isRelativePath(fileName))
{
if (KGlobal::dirs()->exists(fileName))
if (KStandardDirs::exists(fileName))
return fileName;
return QString();
}
@ -762,7 +762,7 @@ VFolderMenu::locateDirectoryFile(const QString &fileName)
if (!QDir::isRelativePath(fileName))
{
if (KGlobal::dirs()->exists(fileName))
if (KStandardDirs::exists(fileName))
return fileName;
return QString();
}
@ -771,7 +771,7 @@ VFolderMenu::locateDirectoryFile(const QString &fileName)
foreach(const QString &it, m_directoryDirs)
{
const QString tmp = it+fileName;
if (KGlobal::dirs()->exists(tmp))
if (KStandardDirs::exists(tmp))
return tmp;
}

View file

@ -632,7 +632,7 @@ void KIconLoader::addExtraDesktopThemes()
QStringList::ConstIterator 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;
r=readlink( QFile::encodeName(*it + *it2) , buf, sizeof(buf)-1);
if ( r>0 )

View file

@ -137,10 +137,10 @@ KIconTheme::KIconTheme(const QString &name, const QString &appName)
for (it=icnlibs.constBegin(); it!=icnlibs.constEnd(); ++it) {
const QString cDir = *it + name + '/';
if (KGlobal::dirs()->exists(cDir)) {
if (KStandardDirs::exists(cDir)) {
themeDirs += cDir;
if (d->mDir.isEmpty()) {
if (KGlobal::dirs()->exists(cDir + "index.theme")) {
if (KStandardDirs::exists(cDir + "index.theme")) {
d->mDir = cDir;
}
}
@ -176,7 +176,7 @@ KIconTheme::KIconTheme(const QString &name, const QString &appName)
KConfigGroup cg(sharedConfig, *it);
for (itDir=themeDirs.constBegin(); itDir!=themeDirs.constEnd(); ++itDir) {
const QString currentDir(*itDir + *it + '/');
if (!addedDirs.contains(currentDir) && KGlobal::dirs()->exists(currentDir)) {
if (!addedDirs.contains(currentDir) && KStandardDirs::exists(currentDir)) {
addedDirs.insert(currentDir);
KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg);
if (!dir->isValid()) {
@ -483,7 +483,7 @@ QStringList KIconTheme::list()
if ((*it2).startsWith(QLatin1String("default.")) ) {
continue;
}
if (!KGlobal::dirs()->exists(*it + *it2 + "/index.theme")) {
if (!KStandardDirs::exists(*it + *it2 + "/index.theme")) {
continue;
}
KIconTheme oink(*it2);

View file

@ -149,7 +149,7 @@ private Q_SLOTS:
// as the "data" resource. But if the file is installed, then it will be
// preferred (because KStandardDirs::resourceDirs() looks at relative paths first)
// 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);
const QString appName = "kdewidgets";
@ -173,7 +173,7 @@ private Q_SLOTS:
void testAppPicsDir_KIcon()
{
const QString dataDir = KGlobal::dirs()->realPath(KDESRCDIR "/../../");
const QString dataDir = KStandardDirs::realPath(KDESRCDIR "/../../");
KGlobal::dirs()->addResourceDir("data", dataDir);
// #### 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...

View file

@ -538,7 +538,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, 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) {
// we're the default theme, let's save our state