Make the "show full size" menu item in the now playing widget and edit tag dialog work with embedded covers

This commit is contained in:
David Sansome 2010-12-28 22:20:54 +00:00
parent d2fda6875f
commit d1d0236385
4 changed files with 15 additions and 8 deletions

View File

@ -150,7 +150,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
return TryLoadResult(false, !image.isNull(), image.isNull() ? default_ : image);
}
QImage AlbumCoverLoader::LoadFromTaglib(const QString& filename) const {
QImage AlbumCoverLoader::LoadFromTaglib(const QString& filename) {
QImage ret;
if (filename.isEmpty())
return ret;
@ -237,14 +237,20 @@ QImage AlbumCoverLoader::ScaleAndPad(const QImage &image) const {
return padded_image;
}
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual) {
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString& automatic,
const QString& manual,
const QString& filename) {
QPixmap ret;
if (manual == kManuallyUnsetCover)
return ret;
if (!manual.isEmpty())
ret.load(manual);
if (!automatic.isEmpty() && ret.isNull())
ret.load(automatic);
if (ret.isNull()) {
if (automatic == kEmbeddedCover && !filename.isNull())
ret = QPixmap::fromImage(LoadFromTaglib(filename));
else if (!automatic.isEmpty())
ret.load(automatic);
}
return ret;
}

View File

@ -54,7 +54,8 @@ class AlbumCoverLoader : public QObject {
void Clear();
static QPixmap TryLoadPixmap(const QString& automatic, const QString& manual);
static QPixmap TryLoadPixmap(const QString& automatic, const QString& manual,
const QString& filename = QString());
static const char* kManuallyUnsetCover;
static const char* kEmbeddedCover;
@ -96,7 +97,7 @@ class AlbumCoverLoader : public QObject {
void NextState(Task* task);
TryLoadResult TryLoadImage(const Task& task);
QImage ScaleAndPad(const QImage& image) const;
QImage LoadFromTaglib(const QString& filename) const;
static QImage LoadFromTaglib(const QString& filename);
bool stop_requested_;

View File

@ -539,7 +539,7 @@ void EditTagDialog::ZoomCover() {
QLabel* label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
song.art_automatic(), song.art_manual()));
song.art_automatic(), song.art_manual(), song.filename()));
dialog->resize(label->pixmap()->size());
dialog->show();

View File

@ -475,7 +475,7 @@ void NowPlayingWidget::ZoomCover() {
QLabel* label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
metadata_.art_automatic(), metadata_.art_manual()));
metadata_.art_automatic(), metadata_.art_manual(), metadata_.filename()));
dialog->resize(label->pixmap()->size());
dialog->show();