from tracker_backend_gi import TrackerBackendGI
from albumItem import AlbumItem
-from album_art_spec import getCoverArtThumbFileName
+from aa_spec import getCoverArtThumbFileName, getCoverArtFileName
class DownloadThread (QtCore.QThread):
def run (self):
print "Running the thread"
+ MAX_OPTIONS = 4
counter = 0
- for x in self.downloader.get_possible_url (self.album.artist,
- self.album.title, 4):
- if counter == 4:
+ for img, thumb in self.downloader.get_alternatives (self.album.artist,
+ self.album.title, MAX_OPTIONS):
+ if counter >= MAX_OPTIONS:
break
- print "Setting url", x
- model.updateData (counter, x)
+
+ self.model.updateData (counter, img, thumb)
counter += 1
- self.exec_ ()
class MussorgskyController (QtCore.QObject):
self.download = DownloadThread (model, album)
self.download.start ()
+ @QtCore.Slot (QtCore.QObject, QtCore.QObject)
+ def albumSelected (self, model, album):
+ """
+ Starts a thread to look for possible images online.
+ The thread will update the model (and the changes are visible in the UI)
+ """
+ print "clicked on", album.title
+ self.download = DownloadThread (model, album)
+ self.download.start ()
+
+ @QtCore.Slot (str, QtCore.QObject)
+ def coverSelected (self, coverObject, albumObject):
+ """
+ The user has clicked in one cover!
+ """
+ print "Selected cover"
+ filename = getCoverArtFileName (albumObject.title)
+ thumbnail = getCoverArtThumbFileName (albumObject.title)
+
+ os.rename (cover.url, filename)
+ os.rename (cover.thumb, thumbnail)
+
+ albumObject.album_art = thumbnail
+ albumObject.album_art_changed.emit ()
+
+ @QtCore.Slot (QtCore.QObject)
+ def resetAlternatives (self, coversModel):
+ print "Reseting alternatives", coversModel
+ QtGui.QPixmapCache.clear ()
+ coversModel.resetAlternatives ()
+
def get_all_albums (self):
"""