diff --git a/src/core/musicstorage.h b/src/core/musicstorage.h index 97b824995..c2d7b4456 100644 --- a/src/core/musicstorage.h +++ b/src/core/musicstorage.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "song.h" @@ -67,6 +68,7 @@ class MusicStorage { bool albumcover_; QString cover_source_; QString cover_dest_; + QImage cover_image_; ProgressFunction progress_; QString playlist_; }; diff --git a/src/core/song.cpp b/src/core/song.cpp index 8a1e745d3..1d155af58 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -224,7 +223,6 @@ struct Song::Private : public QSharedData { float rating_; // Database rating, initial rating read from tag. QUrl stream_url_; // Temporary stream url set by url handler. - QImage image_; // Album Cover image set by album cover loader. bool init_from_file_; // Whether this song was loaded from a file using taglib. bool suspicious_tags_; // Whether our encoding guesser thinks these tags might be incorrectly encoded. @@ -365,7 +363,6 @@ bool Song::save_embedded_cover_supported(const FileType filetype) { const QUrl &Song::stream_url() const { return d->stream_url_; } const QUrl &Song::effective_stream_url() const { return !d->stream_url_.isEmpty() && d->stream_url_.isValid() ? d->stream_url_ : d->url_; } -const QImage &Song::image() const { return d->image_; } bool Song::init_from_file() const { return d->init_from_file_; } const QString &Song::cue_path() const { return d->cue_path_; } @@ -479,7 +476,6 @@ void Song::set_cue_path(const QString &v) { d->cue_path_ = v; } void Song::set_rating(const float v) { d->rating_ = v; } void Song::set_stream_url(const QUrl &v) { d->stream_url_ = v; } -void Song::set_image(const QImage &i) { d->image_ = i; } QString Song::JoinSpec(const QString &table) { return Utilities::Prepend(table + ".", kColumns).join(", "); diff --git a/src/core/song.h b/src/core/song.h index 752d280a1..03ba5220c 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -37,7 +37,6 @@ #include #include #include -#include #include class SqlQuery; @@ -301,7 +300,6 @@ class Song { const QUrl &stream_url() const; const QUrl &effective_stream_url() const; - const QImage &image() const; bool init_from_file() const; // Pretty accessors @@ -380,7 +378,6 @@ class Song { void set_rating(const float v); void set_stream_url(const QUrl &v); - void set_image(const QImage &i); // Comparison functions bool IsMetadataEqual(const Song &other) const; diff --git a/src/device/gpoddevice.cpp b/src/device/gpoddevice.cpp index 1c22c88d3..d7d0160d8 100644 --- a/src/device/gpoddevice.cpp +++ b/src/device/gpoddevice.cpp @@ -190,7 +190,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) { if (job.albumcover_) { bool result = false; - if (!job.metadata_.image().isNull()) { + if (!job.cover_image_.isNull()) { #ifdef Q_OS_LINUX QString temp_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/organize"; #else @@ -201,7 +201,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) { cover_file->setAutoRemove(true); if (cover_file->open()) { cover_file->close(); - QImage image = job.metadata_.image(); + const QImage &image = job.cover_image_; if (image.save(cover_file->fileName(), "JPG")) { const QByteArray filename = QFile::encodeName(cover_file->fileName()); result = itdb_track_set_thumbnails(track, filename.constData()); diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index d11bd1c2a..8b959103c 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -174,10 +174,6 @@ void Organize::ProcessSomeFiles() { Song song = task.song_info_.song_; if (!song.is_valid()) continue; - // Get embedded album cover - QImage cover = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(task.song_info_.song_.url().toLocalFile()); - if (!cover.isNull()) song.set_image(cover); - #ifdef HAVE_GSTREAMER // Maybe this file is one that's been transcoded already? if (!task.transcoded_filename_.isEmpty()) { @@ -242,6 +238,10 @@ void Organize::ProcessSomeFiles() { job.cover_source_ = task.song_info_.song_.art_automatic().path(); } } + else if (destination_->source() == Song::Source_Device) { + job.cover_image_ = TagReaderClient::Instance()->LoadEmbeddedArtAsImageBlocking(task.song_info_.song_.url().toLocalFile()); + } + if (!job.cover_source_.isEmpty()) { job.cover_dest_ = QFileInfo(job.destination_).path() + "/" + QFileInfo(job.cover_source_).fileName(); }