diff options
author | jerous <jerous@gmail.com> | 2008-09-28 23:25:42 +0200 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-09-28 23:30:46 +0200 |
commit | 77c264ce529f29e701df1425559923d81b51c742 (patch) | |
tree | 749ed760d1f0d8f646459cf199b26312f1141d09 /plugins | |
parent | 1c295e042d73ab93d3336bf07271726b34b2a47d (diff) |
unload all plugins on quitting instead of just deleting the objects
PlayControl: save queue on exit
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/PlayControl.py | 24 | ||||
-rw-r--r-- | plugins/Playlist.py | 2 |
2 files changed, 22 insertions, 4 deletions
diff --git a/plugins/PlayControl.py b/plugins/PlayControl.py index 52e5adf..a23283d 100644 --- a/plugins/PlayControl.py +++ b/plugins/PlayControl.py @@ -47,7 +47,7 @@ class wgPlayControl(QtGui.QWidget): " contains the songs of the album the current song is playing. None, if the album is not set" curAlbumSongs=None - " queued songs: Song*" + " queued songs: int*" queuedSongs=[] # what mode where we in before the queue started? beforeQueuedMode=None @@ -134,7 +134,6 @@ class wgPlayControl(QtGui.QWidget): self.connect(self.cmbRepeat, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbRepeatChanged) self.connect(self.cmbShuffle, QtCore.SIGNAL('currentIndexChanged(int)'),self.onCmbShuffleChanged) - def addSongsToQueue(self, songs): self.queuedSongs.extend(songs) self._onQueueUpdate() @@ -208,7 +207,7 @@ class wgPlayControl(QtGui.QWidget): # pick the next song from the queue. Simple as that :) if len(self.queuedSongs): # pick the front - nextID=self.queuedSongs.pop(0).getID() + nextID=self.queuedSongs.pop(0) self._onQueueUpdate() else: # no songs anymore, so we must restore the old mode! @@ -318,6 +317,23 @@ class wgPlayControl(QtGui.QWidget): else: monty.random(0) + # save and load the queue + def saveQueue(self): + # save the ids as a list of space-separated numbers + self.p.extended("saving queue") + settings.set('playcontrol.queue', str(self.queuedSongs)[1:-1].replace(',', '')) + def loadQueue(self): + # just read all the numbers! + self.p.extended("loading queue") + self.queuedSongs=[] + i=0 + ids=settings.get('playcontrol.queue', '').split(' ') + for id in ids: + try: + self.queuedSongs.append(int(id)) + except: + pass + self._onQueueUpdate() class pluginPlayControl(Plugin): o=None @@ -333,7 +349,9 @@ class pluginPlayControl(Plugin): def _load(self): self.o=wgPlayControl(None) self.o.p=self + self.o.loadQueue() def _unload(self): + self.o.saveQueue() self.o=None def getInfo(self): return "Have total control over the playing!" diff --git a/plugins/Playlist.py b/plugins/Playlist.py index 66c4398..f236360 100644 --- a/plugins/Playlist.py +++ b/plugins/Playlist.py @@ -48,7 +48,7 @@ class pluginPlaylist(Plugin): elif event.key()==QtCore.Qt.Key_Q: # queue selected songs # Hoho, this one needs the playcontrol plugin! - self.getWinMain().getPlugin('playcontrol').addSongsToQueue(self.o.selectedSongs()) + self.getWinMain().getPlugin('playcontrol').addSongsToQueue(self.o.selectedIds()) return QtGui.QWidget.keyPressEvent(self.o, event) def onSongChange(self, params): |