diff --git a/context/contextwidget.cpp b/context/contextwidget.cpp index 5e2edc77c..6b9b3d42b 100644 --- a/context/contextwidget.cpp +++ b/context/contextwidget.cpp @@ -586,8 +586,9 @@ void ContextWidget::updateBackdrop() } if (!currentSong.isStream() && MPDConnection::self()->getDetails().dirReadable) { - QString dirName=MPDConnection::self()->getDetails().dir; - if (!dirName.isEmpty() && !dirName.startsWith(QLatin1String("http:/"))) { + bool localNonMpd=currentSong.file.startsWith(Utils::constDirSep); + QString dirName=localNonMpd ? QString() : MPDConnection::self()->getDetails().dir; + if (localNonMpd || (!dirName.isEmpty() && !dirName.startsWith(QLatin1String("http:/")))) { dirName+=Utils::getDir(currentSong.file); QString encoded=Covers::encodeName(currentArtist); QStringList names=QStringList() << encoded+"-"+constBackdropName+".jpg" << encoded+"-"+constBackdropName+".png" @@ -895,8 +896,8 @@ void ContextWidget::downloadResponse() updateImage(img); bool saved=false; - if (Settings::self()->storeBackdropsInMpdDir() && !currentSong.isVariousArtists() && !currentSong.isStream() && - !currentSong.isCdda() && MPDConnection::self()->getDetails().dirReadable) { + if (Settings::self()->storeBackdropsInMpdDir() && !currentSong.isVariousArtists() && + !currentSong.isNonMPD() && MPDConnection::self()->getDetails().dirReadable) { QString mpdDir=MPDConnection::self()->getDetails().dir; QString songDir=Utils::getDir(currentSong.file); if (!mpdDir.isEmpty() && 2==songDir.split(Utils::constDirSep, QString::SkipEmptyParts).count()) { @@ -916,8 +917,8 @@ void ContextWidget::downloadResponse() } } else { DBUG << "Not saving to mpd folder - set to save in mpd?" << Settings::self()->storeBackdropsInMpdDir() - << "isVa:" << currentSong.isVariousArtists() << "isStream:" << currentSong.isStream() - << "isCdda:" << currentSong.isCdda() << "mpd readable:" << MPDConnection::self()->getDetails().dirReadable; + << "isVa:" << currentSong.isVariousArtists() << "isNonMPD:" << currentSong.isNonMPD() + << "mpd readable:" << MPDConnection::self()->getDetails().dirReadable; } if (!saved) { diff --git a/context/songview.cpp b/context/songview.cpp index efc9a6fc2..192fca625 100644 --- a/context/songview.cpp +++ b/context/songview.cpp @@ -265,7 +265,7 @@ void SongView::abort() text->setText(QString()); // Set lyrics file anyway - so that editing is enabled! - lyricsFile=Settings::self()->storeLyricsInMpdDir() + lyricsFile=Settings::self()->storeLyricsInMpdDir() && !currentSong.isNonMPD() ? mpdFilePath(currentSong) : cacheFile(currentSong.artist, currentSong.title); setMode(Mode_Display); @@ -315,7 +315,7 @@ void SongView::update(const Song &s, bool force) currentProvider=-1; } - if (!MPDConnection::self()->getDetails().dir.isEmpty() && !song.file.isEmpty() && !song.isStream()) { + if (!MPDConnection::self()->getDetails().dir.isEmpty() && !song.file.isEmpty() && !song.isNonMPD()) { QString songFile=song.file; if (song.isCantataStream()) { @@ -421,7 +421,7 @@ void SongView::lyricsReady(int id, QString lyrics) } else { text->setText(fixNewLines(plain)); lyricsFile=QString(); - if (! ( Settings::self()->storeLyricsInMpdDir() && + if (! ( Settings::self()->storeLyricsInMpdDir() && !currentSong.isNonMPD() && saveFile(mpdFilePath(currentSong))) ) { saveFile(cacheFile(currentSong.artist, currentSong.title, true)); } @@ -446,7 +446,7 @@ bool SongView::saveFile(const QString &fileName) QString SongView::mpdFileName() const { - return currentSong.file.isEmpty() || MPDConnection::self()->getDetails().dir.isEmpty() || currentSong.isStream() + return currentSong.file.isEmpty() || MPDConnection::self()->getDetails().dir.isEmpty() || currentSong.isNonMPD() ? QString() : mpdFilePath(currentSong); } @@ -466,7 +466,7 @@ void SongView::getLyrics() text->setText(QString()); currentProvider=-1; // Set lyrics file anyway - so that editing is enabled! - lyricsFile=Settings::self()->storeLyricsInMpdDir() + lyricsFile=Settings::self()->storeLyricsInMpdDir() && !currentSong.isNonMPD() ? mpdFilePath(currentSong) : cacheFile(currentSong.artist, currentSong.title); setMode(Mode_Display); diff --git a/dbus/mpris.cpp b/dbus/mpris.cpp index 143ca1bf0..67785447c 100644 --- a/dbus/mpris.cpp +++ b/dbus/mpris.cpp @@ -154,7 +154,7 @@ QVariantMap Mpris::Metadata() const { metadataMap.insert("xesam:contentCreated", QString("%04d").arg(currentSong.year)); } if (!currentSong.file.isEmpty()) { - if (currentSong.isStream()) { + if (currentSong.isNonMPD()) { metadataMap.insert("xesam:url", currentSong.file); } else if (MPDConnection::self()->getDetails().dirReadable) { QString mpdDir=MPDConnection::self()->getDetails().dir; diff --git a/gui/covers.cpp b/gui/covers.cpp index 58adf9fbe..9dcda7153 100644 --- a/gui/covers.cpp +++ b/gui/covers.cpp @@ -732,7 +732,7 @@ QString CoverDownloader::saveImg(const Job &job, const QImage &img, const QByteA } if (job.isArtist) { - if (saveInMpdDir && canSaveTo(job.dir)) { + if (saveInMpdDir && !job.song.isNonMPD() && canSaveTo(job.dir)) { QString mpdDir=MPDConnection::self()->getDetails().dir; if (!mpdDir.isEmpty() && job.dir.startsWith(mpdDir) && 2==job.dir.mid(mpdDir.length()).split(Utils::constDirSep, QString::SkipEmptyParts).count()) { QDir d(job.dir); @@ -755,7 +755,7 @@ QString CoverDownloader::saveImg(const Job &job, const QImage &img, const QByteA } } else { // Try to save as cover.jpg in album dir... - if (saveInMpdDir && canSaveTo(job.dir)) { + if (saveInMpdDir && !job.song.isNonMPD() && canSaveTo(job.dir)) { QString coverName=Covers::albumFileName(job.song); savedName=save(mimeType, extension, job.dir+coverName, img, raw); if (!savedName.isEmpty()) { diff --git a/mpd/song.h b/mpd/song.h index 5046db3b9..df94a2478 100644 --- a/mpd/song.h +++ b/mpd/song.h @@ -32,6 +32,7 @@ #include #include #include "config.h" +#include "utils.h" struct Song { @@ -112,6 +113,7 @@ struct Song static QString capitalize(const QString &s); bool capitalise(); bool isStream() const { return Stream==type || CantataStream==type; } + bool isNonMPD() const { return isStream() || OnlineSvrTrack==type || Cdda==type || (!file.isEmpty() && file.startsWith(Utils::constDirSep)); } bool isCantataStream() const { return CantataStream==type; } bool isCdda() const { return Cdda==type; } QString albumKey() const { return albumArtist()+QLatin1Char(':')+album; }