summaryrefslogtreecommitdiff
path: root/nephilim/plugins/AlbumCover.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-04-30 21:00:30 +0200
committerAnton Khirnov <wyskas@gmail.com>2009-04-30 21:00:30 +0200
commit24afb5d8f9cdfe720774b818fb96b26f5e2db9fa (patch)
treef90faf73d93b5a899bcffd818ab3132ffc5de5d1 /nephilim/plugins/AlbumCover.py
parent146d24fcf9eeeb0bc9f3087ae2b185e89154efe6 (diff)
AlbumCover: some fixes for threading.
Diffstat (limited to 'nephilim/plugins/AlbumCover.py')
-rw-r--r--nephilim/plugins/AlbumCover.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py
index 05d2c90..f4b246f 100644
--- a/nephilim/plugins/AlbumCover.py
+++ b/nephilim/plugins/AlbumCover.py
@@ -75,9 +75,12 @@ class wgAlbumCover(QtGui.QLabel):
if event.button() == QtCore.Qt.RightButton:
self._menu.popup(event.globalPos())
- def set_cover(self, cover, write = False):
+ def set_cover(self, song, cover, write = False):
"""Set cover for current song, attempt to write it to a file
if write is True and it's globally allowed."""
+ if song.filepath() != self.plugin.mpclient().current_song().filepath():
+ return
+
logging.info('Setting cover')
if not cover or cover.isNull():
self.cover = None
@@ -108,7 +111,7 @@ class wgAlbumCover(QtGui.QLabel):
def run(self):
cover, write = self.fetch_func(self.song)
- self.parent().emit(QtCore.SIGNAL('new_cover_fetched'), cover, write)
+ self.parent().emit(QtCore.SIGNAL('new_cover_fetched'), self.song, cover, write)
def _fetch_cover(self):
song = self.plugin.mpclient().current_song()
@@ -119,10 +122,10 @@ class wgAlbumCover(QtGui.QLabel):
fetch_func = self._fetch_auto
elif self.sender().objectName() == 'refresh':
fetch_func = self._fetch_auto
- elif self.sender().objectName() == 'select_file_action':
- fetch_func = self._fetch_local_manual
elif self.sender().objectName() == 'fetch_amazon_action':
fetch_func = self._fetch_amazon_manual
+ elif self.sender().objectName() == 'select_file_action':
+ return self._fetch_local_manual(song) #must be done in this thread
else:
return logging.error('Unknown sender.')
thread = self.FetchThread(self, fetch_func, song)
@@ -165,14 +168,14 @@ class wgAlbumCover(QtGui.QLabel):
return cover, write
- def _fetch_local_manual(self):
+ def _fetch_local_manual(self, song):
file = QtGui.QFileDialog.getOpenFileName(self,
'Select album cover for %s - %s'%(song.artist(), song.album()),
self._cover_dirname, '')
cover = QtGui.QImage(file)
if cover.isNull():
return None, False
- return cover, True
+ self.emit(QtCore.SIGNAL('new_cover_fetched'), song, cover, True)
def _fetch_local(self, song):
logging.info('Trying to guess local cover name.')