Hopefully this finishes the path part of playlist preferences.
This commit is contained in:
parent
e8d3aa9254
commit
0efb23994d
@ -20,11 +20,12 @@
|
||||
#include "library/librarybackend.h"
|
||||
#include "library/libraryquery.h"
|
||||
#include "library/sqlrow.h"
|
||||
#include "playlist/playlist.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
ParserBase::ParserBase(LibraryBackendInterface* library, QObject* parent)
|
||||
: QObject(parent), library_(library) {}
|
||||
ParserBase::ParserBase(LibraryBackendInterface* library, QSettings *settings, QObject* parent)
|
||||
: QObject(parent), settings_(settings), library_(library) {}
|
||||
|
||||
void ParserBase::LoadSong(const QString& filename_or_url, qint64 beginning,
|
||||
const QDir& dir, Song* song) const {
|
||||
@ -90,10 +91,13 @@ QString ParserBase::URLOrRelativeFilename(const QUrl& url,
|
||||
if (url.scheme() != "file") return url.toString();
|
||||
|
||||
const QString filename = url.toLocalFile();
|
||||
if (QDir::isAbsolutePath(filename)) {
|
||||
const Playlist::Path path = settings->value("path_type", Playlist::Path_Automatic);
|
||||
|
||||
if (path != Playlist::Path_Absolute && QDir::isAbsolutePath(filename)) {
|
||||
const QString relative = dir.relativeFilePath(filename);
|
||||
|
||||
if (!relative.startsWith("../")) return relative;
|
||||
if (!relative.startsWith("../") || path == Playlist::Path_Relative)
|
||||
return relative;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QDir>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "playlist/playlist.h"
|
||||
|
||||
class LibraryBackendInterface;
|
||||
|
||||
@ -29,7 +30,7 @@ class ParserBase : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ParserBase(LibraryBackendInterface* library, QObject* parent = nullptr);
|
||||
ParserBase(LibraryBackendInterface* library, QSettings* settings, QObject* parent = nullptr);
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QStringList file_extensions() const = 0;
|
||||
@ -72,6 +73,7 @@ class ParserBase : public QObject {
|
||||
|
||||
private:
|
||||
LibraryBackendInterface* library_;
|
||||
QSettings* settings_;
|
||||
};
|
||||
|
||||
#endif // PARSERBASE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user