Use QUrl::isLocalFile()
This commit is contained in:
parent
f4b1ef4d04
commit
7fa1461d5e
|
@ -328,9 +328,9 @@ int Song::lastplayed() const { return d->lastplayed_; }
|
|||
const QUrl &Song::art_automatic() const { return d->art_automatic_; }
|
||||
const QUrl &Song::art_manual() const { return d->art_manual_; }
|
||||
bool Song::has_manually_unset_cover() const { return d->art_manual_.path() == kManuallyUnsetCover; }
|
||||
void Song::manually_unset_cover() { d->art_manual_.clear(); d->art_manual_.setPath(kManuallyUnsetCover); }
|
||||
void Song::manually_unset_cover() { d->art_manual_ = QUrl::fromLocalFile(kManuallyUnsetCover); }
|
||||
bool Song::has_embedded_cover() const { return d->art_automatic_.path() == kEmbeddedCover; }
|
||||
void Song::set_embedded_cover() { d->art_automatic_.clear(); d->art_automatic_.setPath(kEmbeddedCover); }
|
||||
void Song::set_embedded_cover() { d->art_automatic_ = QUrl::fromLocalFile(kEmbeddedCover); }
|
||||
const QImage &Song::image() const { return d->image_; }
|
||||
|
||||
const QString &Song::cue_path() const { return d->cue_path_; }
|
||||
|
@ -447,7 +447,7 @@ QString Song::JoinSpec(const QString &table) {
|
|||
|
||||
Song::Source Song::SourceFromURL(const QUrl &url) {
|
||||
|
||||
if (url.scheme() == "file") return Source_LocalFile;
|
||||
if (url.isLocalFile()) return Source_LocalFile;
|
||||
else if (url.scheme() == "cdda") return Source_CDDA;
|
||||
else if (url.scheme() == "tidal") return Source_Tidal;
|
||||
else if (url.scheme() == "subsonic") return Source_Subsonic;
|
||||
|
@ -697,7 +697,7 @@ void Song::InitFromProtobuf(const pb::tagreader::SongMetadata &pb) {
|
|||
}
|
||||
|
||||
if (pb.has_art_automatic()) {
|
||||
set_art_automatic(QUrl::fromEncoded(QByteArray(pb.art_automatic().data(), pb.art_automatic().size())));
|
||||
set_art_automatic(QUrl::fromLocalFile(QByteArray(pb.art_automatic().data(), pb.art_automatic().size())));
|
||||
}
|
||||
|
||||
InitArtManual();
|
||||
|
@ -1407,4 +1407,3 @@ void Song::MergeUserSetData(const Song &other) {
|
|||
set_art_manual(other.art_manual());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ SongLoader::Result SongLoader::Load(const QUrl &url) {
|
|||
|
||||
url_ = url;
|
||||
|
||||
if (url_.scheme() == "file") {
|
||||
if (url_.isLocalFile()) {
|
||||
return LoadLocal(url_.toLocalFile());
|
||||
}
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ void OpenInFileBrowser(const QList<QUrl> &urls) {
|
|||
QSet<QString> dirs;
|
||||
|
||||
for (const QUrl &url : urls) {
|
||||
if (url.scheme() != "file") {
|
||||
if (!url.isLocalFile()) {
|
||||
continue;
|
||||
}
|
||||
QString path = url.toLocalFile();
|
||||
|
@ -662,7 +662,7 @@ bool IsLaptop() {
|
|||
|
||||
bool UrlOnSameDriveAsStrawberry(const QUrl &url) {
|
||||
|
||||
if (!url.isValid() || url.scheme() != "file" || url.toLocalFile().isEmpty()) return false;
|
||||
if (!url.isValid() || !url.isLocalFile() || url.toLocalFile().isEmpty()) return false;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QUrl appUrl = QUrl::fromLocalFile(QCoreApplication::applicationDirPath());
|
||||
|
|
|
@ -252,17 +252,18 @@ QUrl AlbumCoverChoiceController::UnsetCover(Song *song) {
|
|||
void AlbumCoverChoiceController::ShowCover(const Song &song) {
|
||||
|
||||
QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url());
|
||||
if (pixmap.isNull()) return;
|
||||
ShowCover(song, pixmap);
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage &image) {
|
||||
|
||||
if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image));
|
||||
else if (!song.art_manual().isEmpty() || !song.art_automatic().isEmpty()) {
|
||||
if (song.art_manual().isLocalFile() || song.art_automatic().isLocalFile()) {
|
||||
QPixmap pixmap = AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url());
|
||||
if (!pixmap.isNull()) ShowCover(song, pixmap);
|
||||
}
|
||||
else if (!image.isNull()) ShowCover(song, QPixmap::fromImage(image));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task)
|
|||
return TryLoadResult(false, false, cover_url, task.options.default_output_image_);
|
||||
}
|
||||
else {
|
||||
if (cover_url.scheme() == "file") {
|
||||
if (cover_url.isLocalFile()) {
|
||||
QImage image(cover_url.toLocalFile());
|
||||
return TryLoadResult(false, !image.isNull(), cover_url, image.isNull() ? task.options.default_output_image_ : image);
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ void EditTagDialog::UpdateSummaryTab(const Song &song) {
|
|||
|
||||
ui_->filetype->setText(song.TextForFiletype());
|
||||
|
||||
if (song.url().scheme() == "file")
|
||||
if (song.url().isLocalFile())
|
||||
ui_->filename->setText(QDir::toNativeSeparators(song.url().toLocalFile()));
|
||||
else
|
||||
ui_->filename->setText(song.url().toString());
|
||||
|
|
|
@ -502,7 +502,7 @@ uint XineEngine::length() const {
|
|||
|
||||
// Xine often delivers nonsense values for VBR files and such, so we only use the length for remote files
|
||||
|
||||
if (media_url_.scheme().toLower() == "file") return 0;
|
||||
if (media_url_.isLocalFile()) return 0;
|
||||
else {
|
||||
int pos = 0, time = 0, length = 0;
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ void Organise::ProcessSomeFiles() {
|
|||
job.remove_original_ = !copy_;
|
||||
|
||||
if (task.song_info_.song_.art_manual_is_valid() && task.song_info_.song_.art_manual().path() != Song::kManuallyUnsetCover) {
|
||||
if (task.song_info_.song_.art_manual().scheme() == "file" && QFile::exists(task.song_info_.song_.art_manual().toLocalFile())) {
|
||||
if (task.song_info_.song_.art_manual().isLocalFile() && QFile::exists(task.song_info_.song_.art_manual().toLocalFile())) {
|
||||
job.cover_source_ = task.song_info_.song_.art_manual().toLocalFile();
|
||||
}
|
||||
else if (task.song_info_.song_.art_manual().scheme().isEmpty() && QFile::exists(task.song_info_.song_.art_manual().path())) {
|
||||
|
@ -210,7 +210,7 @@ void Organise::ProcessSomeFiles() {
|
|||
}
|
||||
}
|
||||
else if (task.song_info_.song_.art_automatic_is_valid() && task.song_info_.song_.art_automatic().path() != Song::kEmbeddedCover) {
|
||||
if (task.song_info_.song_.art_automatic().scheme() == "file" && QFile::exists(task.song_info_.song_.art_automatic().toLocalFile())) {
|
||||
if (task.song_info_.song_.art_automatic().isLocalFile() && QFile::exists(task.song_info_.song_.art_automatic().toLocalFile())) {
|
||||
job.cover_source_ = task.song_info_.song_.art_automatic().toLocalFile();
|
||||
}
|
||||
else if (task.song_info_.song_.art_automatic().scheme().isEmpty() && QFile::exists(task.song_info_.song_.art_automatic().path())) {
|
||||
|
|
|
@ -157,7 +157,7 @@ bool OrganiseDialog::SetSongs(const SongList &songs) {
|
|||
songs_.clear();
|
||||
|
||||
for (const Song &song : songs) {
|
||||
if (song.url().scheme() != "file") {
|
||||
if (!song.url().isLocalFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1826,7 +1826,7 @@ void Playlist::InvalidateDeletedSongs() {
|
|||
PlaylistItemPtr item = items_[row];
|
||||
Song song = item->Metadata();
|
||||
|
||||
if (song.url().scheme() == "file") {
|
||||
if (song.url().isLocalFile()) {
|
||||
bool exists = QFile::exists(song.url().toLocalFile());
|
||||
|
||||
if (!exists && !item->HasForegroundColor(kInvalidSongPriority)) {
|
||||
|
|
|
@ -426,7 +426,7 @@ QString NativeSeparatorsDelegate::displayText(const QVariant &value, const QLoca
|
|||
return QDir::toNativeSeparators(string_value);
|
||||
}
|
||||
|
||||
if (url.scheme() == "file") {
|
||||
if (url.isLocalFile()) {
|
||||
return QDir::toNativeSeparators(url.toLocalFile());
|
||||
}
|
||||
return string_value;
|
||||
|
|
|
@ -40,7 +40,7 @@ bool SongPlaylistItem::InitFromQuery(const SqlRow &query) {
|
|||
QUrl SongPlaylistItem::Url() const { return song_.url(); }
|
||||
|
||||
void SongPlaylistItem::Reload() {
|
||||
if (song_.url().scheme() != "file") return;
|
||||
if (!song_.url().isLocalFile()) return;
|
||||
TagReaderClient::Instance()->ReadFileBlocking(song_.url().toLocalFile(), &song_);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ Song ParserBase::LoadSong(const QString &filename_or_url, qint64 beginning, cons
|
|||
|
||||
QString ParserBase::URLOrFilename(const QUrl &url, const QDir &dir, Playlist::Path path_type) const {
|
||||
|
||||
if (url.scheme() != "file") return url.toString();
|
||||
if (!url.isLocalFile()) return url.toString();
|
||||
|
||||
const QString filename = url.toLocalFile();
|
||||
|
||||
|
|
Loading…
Reference in New Issue