Fix the shutdown script to work with PythonQt
This commit is contained in:
parent
97a8aa54be
commit
143308d2d2
@ -1,27 +1,30 @@
|
|||||||
import clementine
|
import clementine
|
||||||
|
|
||||||
from PyQt4.QtGui import QAction
|
from PythonQt.QtGui import QAction
|
||||||
|
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
LOGGER = logging.getLogger("system-shutdown")
|
||||||
|
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.enabled = False
|
self.enabled = False
|
||||||
clementine.player.PlaylistFinished.connect(self.PlaylistFinished)
|
clementine.player.connect("PlaylistFinished()", self.PlaylistFinished)
|
||||||
self.action = QAction("Shutdown at end", None)
|
self.action = QAction("Shutdown at end", None)
|
||||||
self.action.setCheckable(True)
|
self.action.setCheckable(True)
|
||||||
self.action.triggered.connect(self.Enabled)
|
self.action.connect("triggered(bool)", self.Enabled)
|
||||||
clementine.ui.AddAction("playlist_menu", self.action)
|
clementine.ui.AddAction("playlist_menu", self.action)
|
||||||
|
|
||||||
|
|
||||||
# Slots
|
|
||||||
def PlaylistFinished(self):
|
def PlaylistFinished(self):
|
||||||
if self.enabled:
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
def Enabled(self, enabled):
|
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
|
self.enabled = enabled
|
||||||
|
|
||||||
|
|
||||||
plugin = Plugin()
|
plugin = Plugin()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user