Read tumbnails from itdb tracks
This commit is contained in:
@@ -26,6 +26,15 @@
|
|||||||
#include <taglib/fileref.h>
|
#include <taglib/fileref.h>
|
||||||
#include <taglib/id3v1genres.h>
|
#include <taglib/id3v1genres.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBGPOD
|
||||||
|
# include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
# include <gpod/itdb.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBMTP
|
||||||
|
# include <libmtp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -46,14 +55,6 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPOD
|
|
||||||
#include <gpod/itdb.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBMTP
|
|
||||||
#include <libmtp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/messagehandler.h"
|
#include "core/messagehandler.h"
|
||||||
#include "core/iconloader.h"
|
#include "core/iconloader.h"
|
||||||
@@ -1061,7 +1062,7 @@ void Song::InitArtManual() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPOD
|
#ifdef HAVE_LIBGPOD
|
||||||
void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) {
|
void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||||
|
|
||||||
d->valid_ = true;
|
d->valid_ = true;
|
||||||
|
|
||||||
@@ -1104,6 +1105,22 @@ void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) {
|
|||||||
d->skipcount_ = track->skipcount;
|
d->skipcount_ = track->skipcount;
|
||||||
d->lastplayed_ = track->time_played;
|
d->lastplayed_ = track->time_played;
|
||||||
|
|
||||||
|
if (itdb_track_has_thumbnails(track)) {
|
||||||
|
GdkPixbuf *pixbuf = static_cast<GdkPixbuf*>(itdb_track_get_thumbnail(track, -1, -1));
|
||||||
|
if (pixbuf) {
|
||||||
|
gchar *buffer = nullptr;
|
||||||
|
gsize buffer_size = 0;
|
||||||
|
GError *error = nullptr;
|
||||||
|
gdk_pixbuf_save_to_buffer(pixbuf, &buffer, &buffer_size, "jpeg", &error, nullptr);
|
||||||
|
if (buffer) {
|
||||||
|
const QByteArray data = QByteArray::fromRawData(buffer, buffer_size);
|
||||||
|
d->image_.loadFromData(data, "JPEG");
|
||||||
|
g_free(buffer);
|
||||||
|
}
|
||||||
|
g_object_unref(pixbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Song::ToItdb(Itdb_Track *track) const {
|
void Song::ToItdb(Itdb_Track *track) const {
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class Song {
|
|||||||
bool MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle);
|
bool MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle);
|
||||||
|
|
||||||
#ifdef HAVE_LIBGPOD
|
#ifdef HAVE_LIBGPOD
|
||||||
void InitFromItdb(const _Itdb_Track *track, const QString &prefix);
|
void InitFromItdb(_Itdb_Track *track, const QString &prefix);
|
||||||
void ToItdb(_Itdb_Track *track) const;
|
void ToItdb(_Itdb_Track *track) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user