From b188241ec7226d146b8f7ef9494b4d03e9b45c2b Mon Sep 17 00:00:00 2001 From: John Maguire Date: Thu, 7 Jul 2011 14:20:34 +0000 Subject: [PATCH] Support drag and drop of images to the cover in the edit tag dialog. Fixes issue #1406 --- src/ui/albumcoverchoicecontroller.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ui/albumcoverchoicecontroller.cpp b/src/ui/albumcoverchoicecontroller.cpp index 5eda40f62..24bebc998 100644 --- a/src/ui/albumcoverchoicecontroller.cpp +++ b/src/ui/albumcoverchoicecontroller.cpp @@ -16,6 +16,7 @@ along with Clementine. If not, see . */ +#include "core/logging.h" #include "covers/albumcoverfetcher.h" #include "covers/albumcoverloader.h" #include "library/librarybackend.h" @@ -234,6 +235,9 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent* e) { if (IsKnownImageExtension(suffix)) return true; } + if (e->mimeData()->hasImage()) { + return true; + } return false; } @@ -248,5 +252,14 @@ QString AlbumCoverChoiceController::SaveCover(Song* song, const QDropEvent* e) { } } + if (e->mimeData()->hasImage()) { + QImage image = qvariant_cast(e->mimeData()->imageData()); + if (!image.isNull()) { + QString cover_path = SaveCoverInCache(song->artist(), song->album(), image); + SaveCover(song, cover_path); + return cover_path; + } + } + return QString(); }