diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index ecabd8f1b..80838d554 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -114,7 +114,7 @@ CollectionModel::CollectionModel(const SharedPtr backend, con pixmap_no_cover_ = nocover.pixmap(nocover_sizes.last()).scaled(kPrettyCoverSize, kPrettyCoverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); } - icon_disk_cache_->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + u'/' + QLatin1String(kPixmapDiskCacheDir) + u'-' + Song::TextForSource(backend_->source())); + icon_disk_cache_->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + u'/' + QLatin1String(kPixmapDiskCacheDir) + u'-' + Song::TextForSource(backend_->source())); QObject::connect(&*backend_, &CollectionBackend::SongsAdded, this, &CollectionModel::AddReAddOrUpdate); QObject::connect(&*backend_, &CollectionBackend::SongsChanged, this, &CollectionModel::AddReAddOrUpdate); diff --git a/src/core/database.cpp b/src/core/database.cpp index ed1ff69eb..fde6e8002 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -78,7 +78,7 @@ Database::Database(SharedPtr task_manager, QObject *parent, const Q connection_id_ = sNextConnectionId++; } - directory_ = QDir::toNativeSeparators(StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation)).replace(u"Strawberry"_s, u"strawberry"_s); + directory_ = QDir::toNativeSeparators(StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation)).replace(u"Strawberry"_s, u"strawberry"_s); QMutexLocker l(&mutex_); Connect(); diff --git a/src/core/iconloader.cpp b/src/core/iconloader.cpp index 8d9f58b7e..587204ea1 100644 --- a/src/core/iconloader.cpp +++ b/src/core/iconloader.cpp @@ -51,7 +51,7 @@ void IconLoader::Init() { #endif QDir dir; - if (dir.exists(StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/icons"_s)) { + if (dir.exists(StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/icons"_s)) { custom_icons_ = true; } @@ -125,7 +125,7 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi } if (custom_icons_) { - QString custom_icon_path = StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/icons/%1x%2/%3.png"_s; + QString custom_icon_path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/icons/%1x%2/%3.png"_s; for (int s : std::as_const(sizes)) { QString filename(custom_icon_path.arg(s).arg(s).arg(name)); if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s)); diff --git a/src/core/song.cpp b/src/core/song.cpp index 16f717b75..f7bb52782 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -1335,24 +1335,24 @@ QString Song::ImageCacheDir(const Source source) { switch (source) { case Source::Collection: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/collectionalbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/collectionalbumcovers"_s; case Source::Subsonic: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/subsonicalbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/subsonicalbumcovers"_s; case Source::Tidal: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/tidalalbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/tidalalbumcovers"_s; case Source::Spotify: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/spotifyalbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/spotifyalbumcovers"_s; case Source::Qobuz: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/qobuzalbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/qobuzalbumcovers"_s; case Source::Device: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/devicealbumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/devicealbumcovers"_s; case Source::LocalFile: case Source::CDDA: case Source::Stream: case Source::SomaFM: case Source::RadioParadise: case Source::Unknown: - return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/albumcovers"_s; + return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/albumcovers"_s; } return QString(); diff --git a/src/core/standardpaths.h b/src/core/standardpaths.h index 0982bc117..83702703d 100644 --- a/src/core/standardpaths.h +++ b/src/core/standardpaths.h @@ -22,12 +22,12 @@ #include -class StandardPaths : public QStandardPaths { +class StandardPaths { Q_GADGET public: + using StandardLocation = QStandardPaths::StandardLocation; static QString WritableLocation(const StandardLocation type); - static QString writableLocation(const StandardLocation type) = delete; private: static void AppendOrganizationAndApplication(QString &path); diff --git a/src/core/threadsafenetworkdiskcache.cpp b/src/core/threadsafenetworkdiskcache.cpp index 17dac5ba7..2610c077c 100644 --- a/src/core/threadsafenetworkdiskcache.cpp +++ b/src/core/threadsafenetworkdiskcache.cpp @@ -48,9 +48,9 @@ ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent) : QAbstr if (!sCache) { sCache = new QNetworkDiskCache; #ifdef Q_OS_WIN32 - sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::TempLocation) + u"/strawberry/networkcache"_s); + sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation) + u"/strawberry/networkcache"_s); #else - sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + u"/networkcache"_s); + sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + u"/networkcache"_s); #endif } diff --git a/src/covermanager/currentalbumcoverloader.cpp b/src/covermanager/currentalbumcoverloader.cpp index 6599a5462..df5a4cb8a 100644 --- a/src/covermanager/currentalbumcoverloader.cpp +++ b/src/covermanager/currentalbumcoverloader.cpp @@ -42,7 +42,7 @@ using namespace Qt::Literals::StringLiterals; CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(const SharedPtr albumcover_loader, QObject *parent) : QObject(parent), albumcover_loader_(albumcover_loader), - temp_file_pattern_(StandardPaths::WritableLocation(StandardPaths::TempLocation) + u"/strawberry-cover-XXXXXX.jpg"_s), + temp_file_pattern_(StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation) + u"/strawberry-cover-XXXXXX.jpg"_s), id_(0) { setObjectName(QLatin1String(metaObject()->className())); diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index 0b99387c7..4787a37f7 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -211,9 +211,9 @@ bool GPodDevice::CopyToStorage(const CopyJob &job, QString &error_text) { bool result = false; if (!job.cover_image_.isNull()) { #ifdef Q_OS_LINUX - QString temp_path = StandardPaths::WritableLocation(StandardPaths::CacheLocation) + u"/organize"_s; + QString temp_path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + u"/organize"_s; #else - QString temp_path = StandardPaths::WritableLocation(StandardPaths::TempLocation); + QString temp_path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation); #endif if (!QDir(temp_path).exists()) QDir().mkpath(temp_path); SharedPtr cover_file = make_shared(temp_path + u"/track-albumcover-XXXXXX.jpg"_s); diff --git a/src/engine/gststartup.cpp b/src/engine/gststartup.cpp index dd9afbf19..b7a8b9576 100644 --- a/src/engine/gststartup.cpp +++ b/src/engine/gststartup.cpp @@ -145,7 +145,7 @@ void SetEnvironment() { #endif // USE_BUNDLE #if defined(Q_OS_WIN32) || defined(Q_OS_MACOS) - QString gst_registry_filename = StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + QStringLiteral("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); + QString gst_registry_filename = StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + QStringLiteral("/gst-registry-%1-bin").arg(QCoreApplication::applicationVersion()); qLog(Debug) << "Setting GStreamer registry file to" << gst_registry_filename; Utilities::SetEnv("GST_REGISTRY", gst_registry_filename); #endif diff --git a/src/main.cpp b/src/main.cpp index e890e6cb1..9611c7244 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) { #ifdef Q_OS_MACOS // Must happen after QCoreApplication::setOrganizationName(). - Utilities::SetEnv("XDG_CONFIG_HOME", StandardPaths::WritableLocation(StandardPaths::AppConfigLocation)); + Utilities::SetEnv("XDG_CONFIG_HOME", StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppConfigLocation)); #endif // Output the version, so when people attach log output to bug reports they don't have to tell us which version they're using. diff --git a/src/moodbar/moodbarloader.cpp b/src/moodbar/moodbarloader.cpp index cb2f414d2..0a7d16d3e 100644 --- a/src/moodbar/moodbarloader.cpp +++ b/src/moodbar/moodbarloader.cpp @@ -67,7 +67,7 @@ MoodbarLoader::MoodbarLoader(QObject *parent) setObjectName(QLatin1String(metaObject()->className())); thread_->setObjectName(objectName()); - cache_->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + u"/moodbar"_s); + cache_->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + u"/moodbar"_s); cache_->setMaximumCacheSize(60LL * 1024LL * 1024LL); // 60MB - enough for 20,000 moodbars ReloadSettings(); diff --git a/src/scrobbler/scrobblercache.cpp b/src/scrobbler/scrobblercache.cpp index fcdefb75d..4b2993a46 100644 --- a/src/scrobbler/scrobblercache.cpp +++ b/src/scrobbler/scrobblercache.cpp @@ -49,7 +49,7 @@ using std::make_shared; ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent) : QObject(parent), timer_flush_(new QTimer(this)), - filename_(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + QLatin1Char('/') + filename), + filename_(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + QLatin1Char('/') + filename), loaded_(false) { ReadCache(); diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp index 84984a181..729e0e5f9 100644 --- a/src/settings/collectionsettingspage.cpp +++ b/src/settings/collectionsettingspage.cpp @@ -246,7 +246,7 @@ void CollectionSettingsPage::AddDirectory() { Settings s; s.beginGroup(kSettingsGroup); - QString path = s.value(kLastPath, StandardPaths::WritableLocation(StandardPaths::MusicLocation)).toString(); + QString path = s.value(kLastPath, StandardPaths::WritableLocation(StandardPaths::StandardLocation::MusicLocation)).toString(); path = QDir::cleanPath(QFileDialog::getExistingDirectory(this, tr("Add directory..."), path)); if (!path.isEmpty()) { diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 883f42a5a..537e755fd 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -283,7 +283,7 @@ QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset if (!fileinfo_output.isFile() || fileinfo_output.filePath().isEmpty() || fileinfo_output.path().isEmpty() || fileinfo_output.fileName().isEmpty() || fileinfo_output.suffix().isEmpty()) { QFileInfo fileinfo_input(input); - QString temp_dir = StandardPaths::WritableLocation(StandardPaths::CacheLocation) + "/transcoder"_L1; + QString temp_dir = StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + "/transcoder"_L1; if (!QDir(temp_dir).exists()) QDir().mkpath(temp_dir); QString filename = fileinfo_input.completeBaseName() + QLatin1Char('.') + preset.extension_; fileinfo_output.setFile(temp_dir + QLatin1Char('/') + filename); diff --git a/src/utilities/coverutils.cpp b/src/utilities/coverutils.cpp index 87032a900..4b3deaf4e 100644 --- a/src/utilities/coverutils.cpp +++ b/src/utilities/coverutils.cpp @@ -85,7 +85,7 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc QDir dir; if (!QFileInfo::exists(path) && !dir.mkpath(path)) { qLog(Error) << "Unable to create directory" << path; - path = StandardPaths::WritableLocation(StandardPaths::TempLocation); + path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation); } QString filename;