KStandardDirs::locate/locateLocal ported, by script, this time.

(kdesdk/scripts/kf5/convert-kstandarddirs.pl coming up)
This commit is contained in:
David Faure 2012-05-30 20:25:25 +02:00
parent 745b39d905
commit 0fd5c690c8
8 changed files with 26 additions and 26 deletions

View File

@ -384,7 +384,7 @@ void AbstractRunnerPrivate::init(const KService::Ptr service)
if (runnerDescription.isValid()) {
const QString api = runnerDescription.property("X-Plasma-API").toString();
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data", "plasma/runners/" + runnerDescription.pluginName() + '/');
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/runners/" + runnerDescription.pluginName() + '/');
prepScripting(path, api);
if (!script) {
#ifndef NDEBUG

View File

@ -462,14 +462,14 @@ void Package::setPath(const QString &path)
if (!d->defaultPackageRoot.isEmpty()) {
dir.setPath(d->defaultPackageRoot);
if (dir.isRelative()) {
location = KStandardDirs::locate("data", d->defaultPackageRoot + path);
location = QStandardPaths::locate(QStandardPaths::GenericDataLocation, d->defaultPackageRoot + path);
} else {
location = d->defaultPackageRoot + path;
}
}
if (location.isEmpty()) {
location = KStandardDirs::locate("data", path);
location = QStandardPaths::locate(QStandardPaths::GenericDataLocation, path);
if (location.isEmpty()) {
d->path.clear();
@ -859,7 +859,7 @@ bool PackagePrivate::installPackage(const QString &package, const QString &packa
const QString serviceName = servicePrefix + meta.pluginName() + ".desktop";
QString service = KStandardDirs::locateLocal("services", serviceName);
QString service = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kde5/services/") + serviceName;
#ifndef PLASMA_NO_KIO
KIO::FileCopyJob *job = KIO::file_copy(QUrl::fromLocalFile(metaPath), QUrl::fromLocalFile(service), -1, KIO::HideProgressInfo);
const bool ok = job->exec();
@ -909,7 +909,7 @@ bool PackagePrivate::uninstallPackage(const QString &packageName, const QString
const QString serviceName = servicePrefix + packageName + ".desktop";
QString service = KStandardDirs::locateLocal("services", serviceName);
QString service = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kde5/services/") + serviceName;
#ifndef NDEBUG
kDebug() << "Removing service file " << service;
#endif

View File

@ -146,9 +146,9 @@ void AppletPrivate::init(const QString &packagePath)
QString path = packagePath;
if (path.isEmpty()) {
const QString subPath = package->defaultPackageRoot() + appletDescription.pluginName() + '/';
path = KStandardDirs::locate("data", subPath + "metadata.desktop");
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath + "metadata.desktop");
if (path.isEmpty()) {
path = KStandardDirs::locate("data", subPath);
path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, subPath);
} else {
path.remove(QString("metadata.desktop"));
}

View File

@ -129,7 +129,7 @@ void ServiceProvider::sendOperations(Jolie::Message message)
Jolie::Message response(message.resourcePath(), message.operationName(), message.id());
//FIXME: this is duplicated from Plasma::Service
QString path = KStandardDirs::locate("data", "plasma/services/" + m_service->name() +
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/services/" + m_service->name() +
".operations");
if (path.isEmpty()) {

View File

@ -67,7 +67,7 @@ void StorageThread::initializeDb(StorageJob *caller)
{
if (!m_db.open()) {
m_db = QSqlDatabase::addDatabase("QSQLITE", QString("plasma-storage-%1").arg((quintptr)this));
m_db.setDatabaseName(KStandardDirs::locateLocal("appdata", "plasma-storage2.db"));
m_db.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + "plasma-storage2.db");
}
if (!m_db.open()) {

View File

@ -402,7 +402,7 @@ void Service::registerOperationsScheme()
return;
}
const QString path = KStandardDirs::locate("data", "plasma/services/" + d->name + ".operations");
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "plasma/services/" + d->name + ".operations");
if (path.isEmpty()) {
#ifndef NDEBUG

View File

@ -225,7 +225,7 @@ bool ThemePrivate::useCache()
// FIXME: when using the system colors, if they change while the application is not running
// the cache should be dropped; we need a way to detect system color change when the
// application is not running.
QFile f(KStandardDirs::locate("data", "desktoptheme/" + themeName + "/metadata.desktop"));
QFile f(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "desktoptheme/" + themeName + "/metadata.desktop"));
QFileInfo info(f);
if (info.lastModified().toTime_t() > uint(pixmapCache->lastModifiedTime())) {
pixmapCache->clear();
@ -254,19 +254,19 @@ QString ThemePrivate::findInTheme(const QString &image, const QString &theme, bo
if (locolor) {
search = QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/locolor/") % image;
search = KStandardDirs::locate("data", search);
search = QStandardPaths::locate(QStandardPaths::GenericDataLocation, search);
} else if (!compositingActive) {
search = QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/opaque/") % image;
search = KStandardDirs::locate("data", search);
search = QStandardPaths::locate(QStandardPaths::GenericDataLocation, search);
} else if (KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind)) {
search = QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/translucent/") % image;
search = KStandardDirs::locate("data", search);
search = QStandardPaths::locate(QStandardPaths::GenericDataLocation, search);
}
//not found or compositing enabled
if (search.isEmpty()) {
search = QLatin1Literal("desktoptheme/") % theme % QLatin1Char('/') % image;
search = KStandardDirs::locate("data", search);
search = QStandardPaths::locate(QStandardPaths::GenericDataLocation, search);
}
if (cache && !search.isEmpty()) {
@ -313,7 +313,7 @@ void ThemePrivate::discardCache(CacheTypes caches)
f.remove();
}
const QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
const QString svgElementsFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + "plasma-svgelements-" + themeName;
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
}
}
@ -451,7 +451,7 @@ public:
self.d->isDefault = true;
//FIXME: if/when kconfig gets change notification, this will be unnecessary
KDirWatch::self()->addFile(KStandardDirs::locateLocal("config", ThemePrivate::themeRcFile));
KDirWatch::self()->addFile(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QLatin1Char('/') + ThemePrivate::themeRcFile);
QObject::connect(KDirWatch::self(), SIGNAL(created(QString)), &self, SLOT(settingsFileChanged(QString)));
QObject::connect(KDirWatch::self(), SIGNAL(dirty(QString)), &self, SLOT(settingsFileChanged(QString)));
}
@ -575,9 +575,9 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
// the system colors.
bool realTheme = theme != systemColorsTheme;
if (realTheme) {
QString themePath = KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Char('/'));
QString themePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Char('/'));
if (themePath.isEmpty() && themeName.isEmpty()) {
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
themePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "desktoptheme/default", QStandardPaths::LocateDirectory);
if (themePath.isEmpty()) {
return;
@ -595,14 +595,14 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
themeName = theme;
// load the color scheme config
const QString colorsFile = realTheme ? KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/colors"))
const QString colorsFile = realTheme ? QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/colors"))
: QString();
//kDebug() << "we're going for..." << colorsFile << "*******************";
// load the wallpaper settings, if any
if (realTheme) {
const QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
const QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
KConfig metadata(metadataPath);
processWallpaperSettings(&metadata);
@ -615,7 +615,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
while (!fallback.isEmpty() && !fallbackThemes.contains(fallback)) {
fallbackThemes.append(fallback);
QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
KConfig metadata(metadataPath);
KConfigGroup cg(&metadata, "Settings");
fallback = cg.readEntry("FallbackTheme", QString());
@ -630,7 +630,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
}
foreach (const QString &theme, fallbackThemes) {
QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
KConfig metadata(metadataPath);
processWallpaperSettings(&metadata);
}
@ -649,7 +649,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 = KStandardDirs::exists(KStandardDirs::locateLocal("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/wallpapers/")));
hasWallpapers = KStandardDirs::exists(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/wallpapers/"));
if (realTheme && isDefault && writeSettings) {
// we're the default theme, let's save our state
@ -1053,7 +1053,7 @@ void Theme::setCacheLimit(int kbytes)
QUrl Theme::homepage() const
{
const QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % d->themeName % QLatin1Literal("/metadata.desktop")));
const QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal("desktoptheme/") % d->themeName % QLatin1Literal("/metadata.desktop")));
KConfig metadata(metadataPath);
KConfigGroup brandConfig(&metadata, "Branding");
return brandConfig.readEntry("homepage", QUrl("http://www.kde.org"));

View File

@ -516,7 +516,7 @@ QString WallpaperPrivate::cacheKey(const QString &sourceImagePath, const QSize &
QString WallpaperPrivate::cachePath(const QString &key) const
{
return KGlobal::dirs()->locateLocal("cache", "plasma-wallpapers/" + key + ".png");
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1Char('/') + "plasma-wallpapers/" + key + ".png";
}
void WallpaperPrivate::newRenderCompleted(const WallpaperRenderRequest &request, const QImage &image)