1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
from PyQt4 import QtGui, QtCore
from clMonty import monty
from clPlugin import *
from misc import *
from wgPlaylist import Playlist
from wgSongList import clrRowSel
from clSettings import settings
# Dependencies:
# playcontrol
class pluginPlaylist(Plugin):
o=None
def __init__(self, winMain):
Plugin.__init__(self, winMain, 'Playlist')
self.addMontyListener('onSongChange', self.onSongChange)
def _load(self):
self.o=Playlist(self.winMain, self, ['artist', 'title', 'track', 'album'], 'Playlist'
, self.onDoubleClick, self.onKeyPress)
def _unload(self):
self.o=None
def getPlaylist(self):
return self.o
def getInfo(self):
return "The playlist showing the songs that will be played."
def getList(self):
return self.o
def _getDockWidget(self):
return self._createDock(self.o)
def onDoubleClick(self):
monty.play(self.o.getSelItemID())
def onKeyPress(self, event):
if event.matches(QtGui.QKeySequence.Delete):
# remove selection from playlist using DELETE-key
ids=self.o.selectedIds()
self.setStatus('Deleting '+str(len(ids))+' songs from playlist ...')
doEvents()
monty.deleteFromPlaylist(ids)
self.setStatus('')
doEvents()
self.getWinMain().fillPlaylist()
elif event.key()==QtCore.Qt.Key_Q:
# queue selected songs
# Hoho, this one needs the playcontrol plugin!
self.getWinMain().getPlugin('playcontrol').addSongsToQueue(self.o.selectedIds())
return QtGui.QWidget.keyPressEvent(self.o, event)
def onSongChange(self, params):
lst=self.o
lst.colorID(int(params['newSongID']), clrRowSel)
if params['newSongID']!=-1:
lst.ensureVisible(params['newSongID'])
_rowColorModifier=0
_rowColorAdder=1
def timerEvent(self, event):
curSong=monty.getCurrentSong()
if curSong:
lst=self.lstPlaylist
# color current playing song
lst.colorID(curSong.getID(),
QtGui.QColor(140-self._rowColorModifier*5,140-self._rowColorModifier*5,180))
# make sure color changes nicely over time
self._rowColorModifier=self._rowColorModifier+self._rowColorAdder
if abs(self._rowColorModifier)>4:
self._rowColorAdder=-1*self._rowColorAdder
|