summaryrefslogtreecommitdiff
path: root/nephilim/plugins/PlayControl.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-03-15 21:08:18 +0100
committerAnton Khirnov <wyskas@gmail.com>2009-03-15 21:08:18 +0100
commit8b9ed85df5090cabe2d176e87b1ffa0f10372051 (patch)
tree73a18664b14e3b393c30c4abc7bf9ef80cd879b7 /nephilim/plugins/PlayControl.py
parent3d6d2a41e88b4c37cf58f3d58bd38c0df627cf1d (diff)
PlayControl: change QPushButtons to QActions.
Diffstat (limited to 'nephilim/plugins/PlayControl.py')
-rw-r--r--nephilim/plugins/PlayControl.py89
1 files changed, 40 insertions, 49 deletions
diff --git a/nephilim/plugins/PlayControl.py b/nephilim/plugins/PlayControl.py
index d8b2d81..114be0d 100644
--- a/nephilim/plugins/PlayControl.py
+++ b/nephilim/plugins/PlayControl.py
@@ -8,14 +8,16 @@ from ..plugin import Plugin
class wgPlayControl(QtGui.QToolBar):
"""Displays controls for interacting with playing, like play, volume ..."""
" control buttons"
- btnPlayPause = None
- btnStop = None
- btnPrevious = None
- btnNext = None
- slrVolume=None
- repeat = None
- random = None
- p = None
+ play_icon = None
+ pause_icon = None
+ play_action = None
+ stop_action = None
+ prev_action = None
+ next_action = None
+ vol_slider = None
+ repeat = None
+ random = None
+ p = None
class VolumeSlider(QtGui.QSlider):
@@ -43,37 +45,31 @@ class wgPlayControl(QtGui.QToolBar):
self.setMovable(True)
self.p = p
- self.slrVolume = self.VolumeSlider(self)
- self.connect(self.slrVolume, QtCore.SIGNAL('valueChanged(int)'),self.onVolumeSliderChange)
+ self.play_icon = QtGui.QIcon('gfx/media-playback-start.svg')
+ self.pause_icon = QtGui.QIcon('gfx/media-playback-pause.svg')
- self.btnPlayPause=Button("play", self.onBtnPlayPauseClick, 'gfx/media-playback-start.svg', True)
- self.btnStop=Button("stop", self.onBtnStopClick, 'gfx/media-playback-stop.svg', True)
- self.btnPrevious=Button("prev", self.onBtnPreviousClick, 'gfx/media-skip-backward.svg', True)
- self.btnNext=Button("next", self.onBtnNextClick, 'gfx/media-skip-forward.svg', True)
+ self.play_action = self.addAction(self.play_icon, 'play', self.on_play_click)
+ self.stop_action = self.addAction(QtGui.QIcon('gfx/media-playback-stop.svg'), 'stop', self.on_stop_click)
+ self.prev_action = self.addAction(QtGui.QIcon('gfx/media-skip-backward.svg'), 'previous', self.on_prev_click)
+ self.next_action = self.addAction(QtGui.QIcon('gfx/media-skip-forward.svg'), 'next', self.on_next_click)
+ self.addSeparator()
+
+ self.vol_slider = self.VolumeSlider(self)
+ self.connect(self.vol_slider, QtCore.SIGNAL('valueChanged(int)'),self.onVolumeSliderChange)
+ self.addWidget(self.vol_slider)
+ self.addSeparator()
- self.random = QtGui.QPushButton(QtGui.QIcon('gfx/media-playlist-shuffle.svgz'), '', self)
- self.random.setToolTip('Random')
+ self.random = self.addAction(QtGui.QIcon('gfx/media-playlist-shuffle.svgz'), 'random')
self.random.setCheckable(True)
self.connect(self.random, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient().random)
self.connect(self.p.mpclient(), QtCore.SIGNAL('random_changed'), self.random.setChecked)
- self.repeat = QtGui.QPushButton(QtGui.QIcon('gfx/media-playlist-repeat.svg'), '', self)
- self.repeat.setToolTip('Repeat')
+ self.repeat = self.addAction(QtGui.QIcon('gfx/media-playlist-repeat.svg'), 'repeat')
self.repeat.setCheckable(True)
self.connect(self.p.mpclient(), QtCore.SIGNAL('repeat_changed'), self.repeat.setChecked)
self.connect(self.repeat, QtCore.SIGNAL('toggled(bool)'), self.p.mpclient().repeat)
- self.addWidget(self.btnPlayPause)
- self.addWidget(self.btnStop)
- self.addWidget(self.btnPrevious)
- self.addWidget(self.btnNext)
- self.addSeparator()
- self.addWidget(self.slrVolume)
- self.addSeparator()
- self.addWidget(self.random)
- self.addWidget(self.repeat)
-
- self.connect(self, QtCore.SIGNAL('orientationChanged(Qt::Orientation)'), self.slrVolume.setOrientation)
+ self.connect(self, QtCore.SIGNAL('orientationChanged(Qt::Orientation)'), self.vol_slider.setOrientation)
self.connect(self.p.mpclient(), QtCore.SIGNAL('state_changed'), self.onStateChange)
self.connect(self.p.mpclient(), QtCore.SIGNAL('volume_changed'), self.onVolumeChange)
@@ -82,41 +78,36 @@ class wgPlayControl(QtGui.QToolBar):
status = self.p.mpclient().status()
if new_state == 'play':
- self.btnPlayPause.changeIcon('gfx/media-playback-pause.svg')
- self.btnPlayPause.setToolTip('pauze')
+ self.play_action.setIcon(self.play_icon)
+ self.play_action.setToolTip('pause')
elif new_state == 'pause' or new_state == 'stop':
- self.btnPlayPause.changeIcon('gfx/media-playback-start.svg')
- self.btnPlayPause.setToolTip('play')
+ self.play_action.setIcon(self.pause_icon)
+ self.play_action.setToolTip('play')
def onVolumeChange(self, new_vol):
- self.slrVolume.setValue(new_vol)
+ self.vol_slider.setValue(new_vol)
- def onBtnPlayPauseClick(self):
+ def on_play_click(self):
status=self.p.mpclient().status()
if status['state']=='play':
+ logging.info('Toggling playback')
self.p.mpclient().pause()
- logging.info("Toggling playback")
elif status['state']=='stop':
+ logging.info('Pausing playback')
self.p.mpclient().play(None)
- logging.info("Pausing playback")
else:
self.p.mpclient().resume()
- def onBtnStopClick(self):
+ def on_stop_click(self):
+ logging.info('Stopping playback')
self.p.mpclient().stop()
- logging.info("Stopping playback")
- def onBtnPreviousClick(self):
+ def on_prev_click(self):
+ logging.info('Playing previous')
self.p.mpclient().previous()
- logging.info("Playing previous")
- def onBtnNextClick(self):
+ def on_next_click(self):
+ logging.info('Playing next')
self.p.mpclient().next()
- logging.info("Playing next")
def onVolumeSliderChange(self):
- v=self.slrVolume.value()
- self.p.mpclient().set_volume(v)
- if v<=1:
- mode='mute'
- else:
- mode=('0', 'min', 'med', 'max')[int(3*v/100)]
+ self.p.mpclient().set_volume(self.vol_slider.value())
class PlayControl(Plugin):
o = None