Fix the shutdown script to work with PythonQt

This commit is contained in:
David Sansome 2011-05-30 14:53:18 +00:00
parent 97a8aa54be
commit 143308d2d2
1 changed files with 10 additions and 7 deletions

View File

@ -1,27 +1,30 @@
import clementine
from PyQt4.QtGui import QAction
from PythonQt.QtGui import QAction
import logging
import sys
LOGGER = logging.getLogger("system-shutdown")
class Plugin:
def __init__(self):
self.enabled = False
clementine.player.PlaylistFinished.connect(self.PlaylistFinished)
clementine.player.connect("PlaylistFinished()", self.PlaylistFinished)
self.action = QAction("Shutdown at end", None)
self.action.setCheckable(True)
self.action.triggered.connect(self.Enabled)
self.action.connect("triggered(bool)", self.Enabled)
clementine.ui.AddAction("playlist_menu", self.action)
# Slots
def PlaylistFinished(self):
if self.enabled:
print "Reached the end of the playlist - shutting down."
LOGGER.info("Reached the end of the playlist - shutting down")
sys.exit(0)
def Enabled(self, enabled):
print "Shutdown at end of playlist enabled: %s" % enabled
LOGGER.info("Shutdown at end of playlist enabled: %s" % str(enabled))
self.enabled = enabled
plugin = Plugin()