2 # Copyright (C) 2009 Anton Khirnov <wyskas@gmail.com>
4 # Nephilim is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # Nephilim is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Nephilim. If not, see <http://www.gnu.org/licenses/>.
18 from PyQt4
import QtGui
, QtCore
20 from ..plugin
import Plugin
22 class Songinfo(Plugin
):
24 info
= 'Displays song metadata provided by MPD.'
29 self
.o
= SonginfoWidget(self
)
34 def _get_dock_widget(self
):
35 return self
._create
_dock
(self
.o
)
37 class SonginfoWidget(QtGui
.QWidget
):
41 def __init__(self
, plugin
):
42 QtGui
.QWidget
.__init
__(self
)
45 self
.setLayout(QtGui
.QVBoxLayout())
47 for item
in 'track', 'title', 'album', 'disc', 'artist', 'composer', 'date', 'genre', 'file':
48 self
.labels
[item
] = QtGui
.QLabel('<b>%s</b>:'%item
)
49 self
.labels
[item
].setWordWrap(True)
50 self
.layout().addWidget(self
.labels
[item
])
52 self
.plugin
.mpclient
.song_changed
.connect(self
.on_song_change
)
54 def on_song_change(self
):
55 song
= self
.plugin
.mpclient
.current_song()
57 for item
in self
.labels
:
58 self
.labels
[item
].setText('<b>%s</b>:'%item
)
60 for item
in self
.labels
:
61 self
.labels
[item
].setText('<b>%s</b>: %s'%(item
, unicode(song
.tag(item
))))