diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-08-21 13:40:16 +0200 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-08-21 14:54:50 +0200 |
commit | 0e23f7776fd104d8713cb705438c21559addc1d9 (patch) | |
tree | fb3303d6f6a0c86ac92febca1dd827c2218c60c7 /nephilim/plugins/AlbumCover.py | |
parent | 4636982682d69c0fc5fea724344f02c94c6cb741 (diff) |
switch to new-style PyQt4 signals.
Diffstat (limited to 'nephilim/plugins/AlbumCover.py')
-rw-r--r-- | nephilim/plugins/AlbumCover.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/nephilim/plugins/AlbumCover.py b/nephilim/plugins/AlbumCover.py index f54b101..5250e1e 100644 --- a/nephilim/plugins/AlbumCover.py +++ b/nephilim/plugins/AlbumCover.py @@ -60,7 +60,7 @@ class AlbumCoverWidget(QtGui.QLabel): self.cover = None self.cover_loaded = False self.setPixmap(QtGui.QPixmap('gfx/no-cd-cover.png')) - self.plugin.emit(QtCore.SIGNAL('cover_changed'), None) + self.plugin.cover_changed.emit(QtGui.QPixmap()) return if song != self.plugin.mpclient.current_song(): @@ -69,7 +69,7 @@ class AlbumCoverWidget(QtGui.QLabel): self.cover = cover self.cover_loaded = True self.setPixmap(self.cover.scaled(self.size(), QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)) - self.plugin.emit(QtCore.SIGNAL('cover_changed'), self.cover) + self.plugin.cover_changed.emit(self.cover) self.logger.info('Cover set.') def __view_cover(self): @@ -112,6 +112,9 @@ class AlbumCover(Plugin): __cover_dir = None __cover_path = None + # SIGNALS + cover_changed = QtCore.pyqtSignal(QtGui.QPixmap) + #### private #### def __init__(self, parent, mpclient, name): Plugin.__init__(self, parent, mpclient, name) @@ -212,7 +215,7 @@ class AlbumCover(Plugin): ('artist', song.artist()), ('album', song.album())]) self.fetch2(song, url) - self.connect(self.srep, QtCore.SIGNAL('finished()'), self.__handle_search_res) + self.srep.finished.connect(self.__handle_search_res) def __handle_search_res(self): url = None @@ -233,7 +236,7 @@ class AlbumCover(Plugin): self.logger.info('Found %s song URL: %s.'%(self.name, url)) self.mrep = self.nam.get(QtNetwork.QNetworkRequest(url)) - self.connect(self.mrep, QtCore.SIGNAL('finished()'), self.__handle_cover) + self.mrep.finished.connect(self.__handle_cover) def __handle_cover(self): data = self.mrep.readAll() @@ -245,10 +248,14 @@ class AlbumCover(Plugin): class FetcherLocal(QtCore.QObject): """This fetcher tries to find cover files in the same directory as current song.""" + #public, read-only name = 'local' logger = None settings = None + # SIGNALS + finished = QtCore.pyqtSignal('song', 'metadata') + def __init__(self, plugin): QtCore.QObject.__init__(self, plugin) self.logger = plugin.logger @@ -272,7 +279,7 @@ class AlbumCover(Plugin): os.path.dirname(song.filepath()))) if not dir: self.logger.error('Error opening directory' + self.__cover_dir) - return self.emit(QtCore.SIGNAL('finished'), song, None) + return self.finished.emit(song, None) dir.setNameFilters(filter) files = dir.entryList() @@ -280,7 +287,7 @@ class AlbumCover(Plugin): cover = QtGui.QPixmap(dir.filePath(files[0])) if not cover.isNull(): self.logger.info('Found a cover: %s'%dir.filePath(files[0])) - return self.emit(QtCore.SIGNAL('finished'), song, cover) + return self.finished.emit(song, cover) # if this failed, try any supported image dir.setNameFilters(exts) @@ -289,21 +296,18 @@ class AlbumCover(Plugin): cover = QtGui.QPixmap(dir.filePath(files[0])) if not cover.isNull(): self.logger.info('Found a cover: %s'%dir.filePath(files[0])) - return self.emit(QtCore.SIGNAL('finished'), song, cover) + return self.finished.emit(song, cover) self.logger.info('No matching cover found') - self.emit(QtCore.SIGNAL('finished'), song, None) + self.finished.emit(song, None) #### public #### def _load(self): self.o = AlbumCoverWidget(self) - self.connect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) - self.connect(self.mpclient, QtCore.SIGNAL('disconnected'), self.refresh) + self.mpclient.song_changed.connect(self.refresh) self.refresh_fetchers() def _unload(self): self.o = None - self.disconnect(self.mpclient, QtCore.SIGNAL('song_changed'), self.refresh) - self.disconnect(self.mpclient, QtCore.SIGNAL('disconnected'), self.refresh) - self.disconnect(self.mpclient, QtCore.SIGNAL('state_changed'),self.refresh) + self.mpclient.song_changed.disconnect(self.refresh) def info(self): return "Display the album cover of the currently playing album." @@ -340,7 +344,7 @@ class AlbumCover(Plugin): for site in self.available_fetchers: if site.name == name: self.__fetchers.append(site(self)) - self.connect(self.__fetchers[-1], QtCore.SIGNAL('finished'), self.__new_cover_fetched) + self.__fetchers[-1].finished.connect(self.__new_cover_fetched) def save_cover_file(self, cover, path = None): """Save cover to a file specified in path. |