StandardPaths: Remove inheritance
This commit is contained in:
@@ -114,7 +114,7 @@ CollectionModel::CollectionModel(const SharedPtr<CollectionBackend> backend, con
|
|||||||
pixmap_no_cover_ = nocover.pixmap(nocover_sizes.last()).scaled(kPrettyCoverSize, kPrettyCoverSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
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::SongsAdded, this, &CollectionModel::AddReAddOrUpdate);
|
||||||
QObject::connect(&*backend_, &CollectionBackend::SongsChanged, this, &CollectionModel::AddReAddOrUpdate);
|
QObject::connect(&*backend_, &CollectionBackend::SongsChanged, this, &CollectionModel::AddReAddOrUpdate);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ Database::Database(SharedPtr<TaskManager> task_manager, QObject *parent, const Q
|
|||||||
connection_id_ = sNextConnectionId++;
|
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_);
|
QMutexLocker l(&mutex_);
|
||||||
Connect();
|
Connect();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void IconLoader::Init() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
QDir dir;
|
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;
|
custom_icons_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (custom_icons_) {
|
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)) {
|
for (int s : std::as_const(sizes)) {
|
||||||
QString filename(custom_icon_path.arg(s).arg(s).arg(name));
|
QString filename(custom_icon_path.arg(s).arg(s).arg(name));
|
||||||
if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s));
|
if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s));
|
||||||
|
|||||||
@@ -1335,24 +1335,24 @@ QString Song::ImageCacheDir(const Source source) {
|
|||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
case Source::Collection:
|
case Source::Collection:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/collectionalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/collectionalbumcovers"_s;
|
||||||
case Source::Subsonic:
|
case Source::Subsonic:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/subsonicalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/subsonicalbumcovers"_s;
|
||||||
case Source::Tidal:
|
case Source::Tidal:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/tidalalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/tidalalbumcovers"_s;
|
||||||
case Source::Spotify:
|
case Source::Spotify:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/spotifyalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/spotifyalbumcovers"_s;
|
||||||
case Source::Qobuz:
|
case Source::Qobuz:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/qobuzalbumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/qobuzalbumcovers"_s;
|
||||||
case Source::Device:
|
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::LocalFile:
|
||||||
case Source::CDDA:
|
case Source::CDDA:
|
||||||
case Source::Stream:
|
case Source::Stream:
|
||||||
case Source::SomaFM:
|
case Source::SomaFM:
|
||||||
case Source::RadioParadise:
|
case Source::RadioParadise:
|
||||||
case Source::Unknown:
|
case Source::Unknown:
|
||||||
return StandardPaths::WritableLocation(StandardPaths::AppLocalDataLocation) + u"/albumcovers"_s;
|
return StandardPaths::WritableLocation(StandardPaths::StandardLocation::AppLocalDataLocation) + u"/albumcovers"_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
|
|||||||
@@ -22,12 +22,12 @@
|
|||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
class StandardPaths : public QStandardPaths {
|
class StandardPaths {
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using StandardLocation = QStandardPaths::StandardLocation;
|
||||||
static QString WritableLocation(const StandardLocation type);
|
static QString WritableLocation(const StandardLocation type);
|
||||||
static QString writableLocation(const StandardLocation type) = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void AppendOrganizationAndApplication(QString &path);
|
static void AppendOrganizationAndApplication(QString &path);
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent) : QAbstr
|
|||||||
if (!sCache) {
|
if (!sCache) {
|
||||||
sCache = new QNetworkDiskCache;
|
sCache = new QNetworkDiskCache;
|
||||||
#ifdef Q_OS_WIN32
|
#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
|
#else
|
||||||
sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + u"/networkcache"_s);
|
sCache->setCacheDirectory(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + u"/networkcache"_s);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ using namespace Qt::Literals::StringLiterals;
|
|||||||
CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(const SharedPtr<AlbumCoverLoader> albumcover_loader, QObject *parent)
|
CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(const SharedPtr<AlbumCoverLoader> albumcover_loader, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
albumcover_loader_(albumcover_loader),
|
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) {
|
id_(0) {
|
||||||
|
|
||||||
setObjectName(QLatin1String(metaObject()->className()));
|
setObjectName(QLatin1String(metaObject()->className()));
|
||||||
|
|||||||
@@ -211,9 +211,9 @@ bool GPodDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
if (!job.cover_image_.isNull()) {
|
if (!job.cover_image_.isNull()) {
|
||||||
#ifdef Q_OS_LINUX
|
#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
|
#else
|
||||||
QString temp_path = StandardPaths::WritableLocation(StandardPaths::TempLocation);
|
QString temp_path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation);
|
||||||
#endif
|
#endif
|
||||||
if (!QDir(temp_path).exists()) QDir().mkpath(temp_path);
|
if (!QDir(temp_path).exists()) QDir().mkpath(temp_path);
|
||||||
SharedPtr<TemporaryFile> cover_file = make_shared<TemporaryFile>(temp_path + u"/track-albumcover-XXXXXX.jpg"_s);
|
SharedPtr<TemporaryFile> cover_file = make_shared<TemporaryFile>(temp_path + u"/track-albumcover-XXXXXX.jpg"_s);
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ void SetEnvironment() {
|
|||||||
#endif // USE_BUNDLE
|
#endif // USE_BUNDLE
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MACOS)
|
#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;
|
qLog(Debug) << "Setting GStreamer registry file to" << gst_registry_filename;
|
||||||
Utilities::SetEnv("GST_REGISTRY", gst_registry_filename);
|
Utilities::SetEnv("GST_REGISTRY", gst_registry_filename);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
// Must happen after QCoreApplication::setOrganizationName().
|
// 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
|
#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.
|
// Output the version, so when people attach log output to bug reports they don't have to tell us which version they're using.
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ MoodbarLoader::MoodbarLoader(QObject *parent)
|
|||||||
setObjectName(QLatin1String(metaObject()->className()));
|
setObjectName(QLatin1String(metaObject()->className()));
|
||||||
thread_->setObjectName(objectName());
|
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
|
cache_->setMaximumCacheSize(60LL * 1024LL * 1024LL); // 60MB - enough for 20,000 moodbars
|
||||||
|
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ using std::make_shared;
|
|||||||
ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent)
|
ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
timer_flush_(new QTimer(this)),
|
timer_flush_(new QTimer(this)),
|
||||||
filename_(StandardPaths::WritableLocation(StandardPaths::CacheLocation) + QLatin1Char('/') + filename),
|
filename_(StandardPaths::WritableLocation(StandardPaths::StandardLocation::CacheLocation) + QLatin1Char('/') + filename),
|
||||||
loaded_(false) {
|
loaded_(false) {
|
||||||
|
|
||||||
ReadCache();
|
ReadCache();
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ void CollectionSettingsPage::AddDirectory() {
|
|||||||
Settings s;
|
Settings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
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));
|
path = QDir::cleanPath(QFileDialog::getExistingDirectory(this, tr("Add directory..."), path));
|
||||||
|
|
||||||
if (!path.isEmpty()) {
|
if (!path.isEmpty()) {
|
||||||
|
|||||||
@@ -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()) {
|
if (!fileinfo_output.isFile() || fileinfo_output.filePath().isEmpty() || fileinfo_output.path().isEmpty() || fileinfo_output.fileName().isEmpty() || fileinfo_output.suffix().isEmpty()) {
|
||||||
QFileInfo fileinfo_input(input);
|
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);
|
if (!QDir(temp_dir).exists()) QDir().mkpath(temp_dir);
|
||||||
QString filename = fileinfo_input.completeBaseName() + QLatin1Char('.') + preset.extension_;
|
QString filename = fileinfo_input.completeBaseName() + QLatin1Char('.') + preset.extension_;
|
||||||
fileinfo_output.setFile(temp_dir + QLatin1Char('/') + filename);
|
fileinfo_output.setFile(temp_dir + QLatin1Char('/') + filename);
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc
|
|||||||
QDir dir;
|
QDir dir;
|
||||||
if (!QFileInfo::exists(path) && !dir.mkpath(path)) {
|
if (!QFileInfo::exists(path) && !dir.mkpath(path)) {
|
||||||
qLog(Error) << "Unable to create directory" << path;
|
qLog(Error) << "Unable to create directory" << path;
|
||||||
path = StandardPaths::WritableLocation(StandardPaths::TempLocation);
|
path = StandardPaths::WritableLocation(StandardPaths::StandardLocation::TempLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
|
|||||||
Reference in New Issue
Block a user