diff options
author | Max Linke <kain88@mixxx.org> | 2014-09-08 18:13:39 +0200 |
---|---|---|
committer | Max Linke <kain88@mixxx.org> | 2014-09-11 11:57:51 +0200 |
commit | 7a95dffc427f6d3559d3ff6cb54981e3a9f7d9f3 (patch) | |
tree | b52ad5d936fddb8de5face3fcc1c8f2782e943ce /src/widget/wcoverartmenu.cpp | |
parent | 25bd8f77c214f9b5abc5be68119449ccfe79688a (diff) |
Make cover in dlgtrackinfo work with cancel
We want that changes to the cover in dlgtrackinfo behave similar to
changing other values of the track. This required me to rework how
WCoverArtMenu works. WCoverArtMenu is now only a common menu that DOES
NOT CHANGE the database instead the widget implementing the menu does
this now when it sees fit. Another important change to make this work is
that 'CoverArtCache::searchImage' can now be called from any class
without the need use 'requestCover'. This is necessary to reload the
cover from the ID3tags/folder without updating the DB. This is ok in
this case because we only search for 1 cover and we will only block the
UI thread for a fraction of a second. I also think this is ok in this
special case because changing covers won't happen very often and a user
will to this one track at a time anyway, while the normal cover display
requires us to provides covers for several tracks simultaneously.
Diffstat (limited to 'src/widget/wcoverartmenu.cpp')
-rw-r--r-- | src/widget/wcoverartmenu.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/widget/wcoverartmenu.cpp b/src/widget/wcoverartmenu.cpp index 9959dea2a9..2464bb968b 100644 --- a/src/widget/wcoverartmenu.cpp +++ b/src/widget/wcoverartmenu.cpp @@ -5,6 +5,7 @@ #include "dlgcoverartfullsize.h" #include "wcoverartmenu.h" #include "library/coverartcache.h" +#include "library/dao/coverartdao.h" WCoverArtMenu::WCoverArtMenu(QWidget *parent) : QMenu(parent), @@ -114,24 +115,25 @@ void WCoverArtMenu::slotChange() { newCover = selectedCover; } - bool res = CoverArtCache::instance()->changeCoverArt(m_pTrack->getId(), - newCover); - if (!res) { - QMessageBox::warning(this, tr("Change Cover Art"), - tr("Could not change the cover art!")); - return; - } - - emit(coverLocationUpdated(newCover, m_sCoverLocation)); - m_sCoverLocation = newCover; + QPixmap px(newCover); + emit(coverLocationUpdated(newCover, m_sCoverLocation, px)); } void WCoverArtMenu::slotReload() { if (m_iTrackId < 1) { return; } - CoverArtCache::instance()->changeCoverArt(m_iTrackId); - CoverArtCache::instance()->requestPixmap(m_iTrackId); + CoverArtDAO::CoverArtInfo info; + info.trackId = m_iTrackId; + info.album = m_pTrack->getAlbum(); + info.trackDirectory = m_pTrack->getDirectory(); + info.trackLocation = m_pTrack->getLocation(); + info.trackBaseName = QFileInfo(m_pTrack->getFilename()).baseName(); + CoverArtCache::FutureResult res = + CoverArtCache::instance()->searchImage(info, QSize(0,0), false); + QPixmap px; + px.convertFromImage(res.img); + emit(coverLocationUpdated(res.coverLocation, m_sCoverLocation, px)); } void WCoverArtMenu::slotUnset() { @@ -139,11 +141,6 @@ void WCoverArtMenu::slotUnset() { return; } QString newLoc = CoverArtCache::instance()->getDefaultCoverLocation(); - if (!CoverArtCache::instance()->changeCoverArt(m_iTrackId, newLoc)) { - QMessageBox::warning(this, tr("Unset Cover Art"), - tr("Could not unset the cover art!")); - return; - } - emit(coverLocationUpdated(newLoc, m_sCoverLocation)); - m_sCoverLocation = newLoc; + QPixmap px = CoverArtCache::instance()->getDefaultCoverArt(); + emit(coverLocationUpdated(newLoc, m_sCoverLocation, px)); } |