Merge pull request #6472 from cquike/xdg
Support for XDG_CONFIG_HOME and XDG_CACHE_HOME
This commit is contained in:
commit
672b90659b
@ -345,8 +345,9 @@ QString GetConfigPath(ConfigPath config) {
|
|||||||
return mac::GetApplicationSupportPath() + "/" +
|
return mac::GetApplicationSupportPath() + "/" +
|
||||||
QCoreApplication::organizationName();
|
QCoreApplication::organizationName();
|
||||||
#else
|
#else
|
||||||
return QString("%1/.config/%2")
|
return QString("%1/%2").arg(
|
||||||
.arg(QDir::homePath(), QCoreApplication::organizationName());
|
QStandardPaths::writableLocation(QStandardPaths::ConfigLocation),
|
||||||
|
QCoreApplication::organizationName());
|
||||||
#endif
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -355,13 +356,9 @@ QString GetConfigPath(ConfigPath config) {
|
|||||||
return GetConfigPath(Path_Root) + "/cache";
|
return GetConfigPath(Path_Root) + "/cache";
|
||||||
}
|
}
|
||||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
|
#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
|
||||||
char* xdg = getenv("XDG_CACHE_HOME");
|
return QString("%1/%2").arg(QStandardPaths::writableLocation(
|
||||||
if (!xdg || !*xdg) {
|
QStandardPaths::GenericCacheLocation),
|
||||||
return QString("%1/.cache/%2")
|
QCoreApplication::organizationName());
|
||||||
.arg(QDir::homePath(), QCoreApplication::organizationName());
|
|
||||||
} else {
|
|
||||||
return QString("%1/%2").arg(xdg, QCoreApplication::organizationName());
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
return GetConfigPath(Path_Root);
|
return GetConfigPath(Path_Root);
|
||||||
#endif
|
#endif
|
||||||
@ -379,6 +376,9 @@ QString GetConfigPath(ConfigPath config) {
|
|||||||
case Path_MoodbarCache:
|
case Path_MoodbarCache:
|
||||||
return GetConfigPath(Path_CacheRoot) + "/moodbarcache";
|
return GetConfigPath(Path_CacheRoot) + "/moodbarcache";
|
||||||
|
|
||||||
|
case Path_PixmapCache:
|
||||||
|
return GetConfigPath(Path_CacheRoot) + "/pixmapcache";
|
||||||
|
|
||||||
case Path_GstreamerRegistry:
|
case Path_GstreamerRegistry:
|
||||||
return GetConfigPath(Path_Root) +
|
return GetConfigPath(Path_Root) +
|
||||||
QString("/gst-registry-%1-bin")
|
QString("/gst-registry-%1-bin")
|
||||||
|
@ -132,6 +132,7 @@ enum ConfigPath {
|
|||||||
Path_DefaultMusicLibrary,
|
Path_DefaultMusicLibrary,
|
||||||
Path_LocalSpotifyBlob,
|
Path_LocalSpotifyBlob,
|
||||||
Path_MoodbarCache,
|
Path_MoodbarCache,
|
||||||
|
Path_PixmapCache,
|
||||||
Path_CacheRoot,
|
Path_CacheRoot,
|
||||||
};
|
};
|
||||||
QString GetConfigPath(ConfigPath config);
|
QString GetConfigPath(ConfigPath config);
|
||||||
|
@ -105,7 +105,7 @@ LibraryModel::LibraryModel(LibraryBackend* backend, Application* app,
|
|||||||
SLOT(AlbumArtLoaded(quint64, QImage)));
|
SLOT(AlbumArtLoaded(quint64, QImage)));
|
||||||
|
|
||||||
icon_cache_->setCacheDirectory(
|
icon_cache_->setCacheDirectory(
|
||||||
Utilities::GetConfigPath(Utilities::Path_CacheRoot) + "/pixmapcache");
|
Utilities::GetConfigPath(Utilities::Path_PixmapCache));
|
||||||
icon_cache_->setMaximumCacheSize(LibraryModel::kIconCacheSize);
|
icon_cache_->setMaximumCacheSize(LibraryModel::kIconCacheSize);
|
||||||
|
|
||||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||||
|
@ -302,14 +302,6 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
|
||||||
// Must happen after QCoreApplication::setOrganizationName().
|
|
||||||
setenv(
|
|
||||||
"XDG_CONFIG_HOME",
|
|
||||||
Utilities::GetConfigPath(Utilities::Path_Root).toLocal8Bit().constData(),
|
|
||||||
1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Output the version, so when people attach log output to bug reports they
|
// Output the version, so when people attach log output to bug reports they
|
||||||
// don't have to tell us which version they're using.
|
// don't have to tell us which version they're using.
|
||||||
qLog(Info) << "Clementine-qt5" << CLEMENTINE_VERSION_DISPLAY;
|
qLog(Info) << "Clementine-qt5" << CLEMENTINE_VERSION_DISPLAY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user