Support drag and drop of images to the cover in the edit tag dialog.

Fixes issue #1406
This commit is contained in:
John Maguire 2011-07-07 14:20:34 +00:00
parent ea3cf5f92d
commit b188241ec7
1 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,7 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#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<QImage>(e->mimeData()->imageData());
if (!image.isNull()) {
QString cover_path = SaveCoverInCache(song->artist(), song->album(), image);
SaveCover(song, cover_path);
return cover_path;
}
}
return QString();
}