# # Copyright (C) 2009 Anton Khirnov # # Nephilim is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Nephilim is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Nephilim. If not, see . # from PyQt4 import QtGui, QtCore from ..plugin import Plugin class Songinfo(Plugin): o = None def _load(self): self.o = SonginfoWidget(self) def _unload(self): self.o = None def info(self): return 'Provides information about a song.' def _get_dock_widget(self): return self._create_dock(self.o) class SonginfoWidget(QtGui.QWidget): plugin = None labels = {} def __init__(self, plugin): QtGui.QWidget.__init__(self) self.plugin = plugin self.setLayout(QtGui.QVBoxLayout()) for item in 'track', 'title', 'album', 'disc', 'artist', 'composer', 'date', 'genre', 'file': self.labels[item] = QtGui.QLabel('%s:'%item) self.labels[item].setWordWrap(True) self.layout().addWidget(self.labels[item]) self.connect(self.plugin.mpclient, QtCore.SIGNAL('song_changed'), self.on_song_change) def on_song_change(self): song = self.plugin.mpclient.current_song() if not song: for item in self.labels: self.labels[item].setText('%s:'%item) else: for item in self.labels: self.labels[item].setText('%s: %s'%(item, unicode(song.tag(item))))