From b8d4dc0dc42d91b9d620fced9909d5edb19b67c8 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 5 May 2024 02:04:03 +0300 Subject: [PATCH] generic: call static KStandardDirs methods as such Signed-off-by: Ivailo Monev --- kdecore/config/kdesktopfile.cpp | 2 +- kdecore/tests/kstandarddirstest.cpp | 14 +++++++------- kded/vfolder_menu.cpp | 8 ++++---- kdeui/icons/kiconloader.cpp | 2 +- kdeui/icons/kicontheme.cpp | 8 ++++---- kdeui/tests/kiconloader_unittest.cpp | 4 ++-- plasma/theme.cpp | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/kdecore/config/kdesktopfile.cpp b/kdecore/config/kdesktopfile.cpp index 35b7eb81..b951cda8 100644 --- a/kdecore/config/kdesktopfile.cpp +++ b/kdecore/config/kdesktopfile.cpp @@ -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) { diff --git a/kdecore/tests/kstandarddirstest.cpp b/kdecore/tests/kstandarddirstest.cpp index fa1e44ee..41e12488 100644 --- a/kdecore/tests/kstandarddirstest.cpp +++ b/kdecore/tests/kstandarddirstest.cpp @@ -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 diff --git a/kded/vfolder_menu.cpp b/kded/vfolder_menu.cpp index 0118f5a2..5b953c9f 100644 --- a/kded/vfolder_menu.cpp +++ b/kded/vfolder_menu.cpp @@ -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; } diff --git a/kdeui/icons/kiconloader.cpp b/kdeui/icons/kiconloader.cpp index 9c997e41..db2609d7 100644 --- a/kdeui/icons/kiconloader.cpp +++ b/kdeui/icons/kiconloader.cpp @@ -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 ) diff --git a/kdeui/icons/kicontheme.cpp b/kdeui/icons/kicontheme.cpp index cfe2620f..09f62043 100644 --- a/kdeui/icons/kicontheme.cpp +++ b/kdeui/icons/kicontheme.cpp @@ -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); diff --git a/kdeui/tests/kiconloader_unittest.cpp b/kdeui/tests/kiconloader_unittest.cpp index 7c10bdba..72a25c6c 100644 --- a/kdeui/tests/kiconloader_unittest.cpp +++ b/kdeui/tests/kiconloader_unittest.cpp @@ -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... diff --git a/plasma/theme.cpp b/plasma/theme.cpp index 9ec93993..1487c0ce 100644 --- a/plasma/theme.cpp +++ b/plasma/theme.cpp @@ -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