Add the last two remaining outstanding items, the "next track" and the time remaining.

Fixes: https://launchpad.net/bugs/845692
This commit is contained in:
Raoul Snyman 2012-02-25 01:26:10 +02:00
parent d14a316309
commit 8fa7dcf080
3 changed files with 54 additions and 13 deletions

View File

@ -93,6 +93,7 @@ class UiStrings(object):
self.New = translate('OpenLP.Ui', 'New')
self.NewService = translate('OpenLP.Ui', 'New Service')
self.NewTheme = translate('OpenLP.Ui', 'New Theme')
self.NextTrack = translate('OpenLP.Ui', 'Next Track')
self.NFSs = translate('OpenLP.Ui', 'No File Selected', 'Singular')
self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural')
self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular')

View File

@ -30,7 +30,6 @@ and play multimedia within OpenLP.
"""
import cgi
import logging
import os
import sys
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
@ -136,12 +135,12 @@ class MainDisplay(Display):
QtCore.Qt.WindowStaysOnTopHint
if QtCore.QSettings().value(u'advanced/x11 bypass wm',
QtCore.QVariant(True)).toBool():
windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint
windowFlags |= QtCore.Qt.X11BypassWindowManagerHint
# FIXME: QtCore.Qt.SplashScreen is workaround to make display screen
# stay always on top on Mac OS X. For details see bug 906926.
# It needs more investigation to fix it properly.
if sys.platform == 'darwin':
windowFlags = windowFlags | QtCore.Qt.SplashScreen
windowFlags |= QtCore.Qt.SplashScreen
self.setWindowFlags(windowFlags)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setTransparency(True)
@ -495,6 +494,7 @@ class AudioPlayer(QtCore.QObject):
self.playlist = []
self.repeat = False
self.mediaObject = Phonon.MediaObject()
self.mediaObject.setTickInterval(100)
self.audioObject = Phonon.AudioOutput(Phonon.VideoCategory)
Phonon.createPath(self.mediaObject, self.audioObject)
QtCore.QObject.connect(self.mediaObject,
@ -573,3 +573,19 @@ class AudioPlayer(QtCore.QObject):
filenames = [filenames]
for filename in filenames:
self.playlist.append(Phonon.MediaSource(filename))
def next(self):
self.mediaObject.clearQueue()
self.mediaObject.clear()
self.currentIndex += 1
if len(self.playlist) <= self.currentIndex:
if self.repeat:
self.currentIndex = 0
else:
self.currentIndex = -1
if self.currentIndex >= 0:
self.mediaObject.enqueue(self.playlist[self.currentIndex])
self.mediaObject.play()
def connectSlot(self, signal, slot):
QtCore.QObject.connect(self.mediaObject, signal, slot)

View File

@ -33,7 +33,7 @@ from collections import deque
from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, \
translate, build_icon, ServiceItem, build_html, PluginManager, ServiceItem
translate, build_icon, build_html, PluginManager, ServiceItem
from openlp.core.lib.ui import UiStrings, shortcut_action
from openlp.core.lib import SlideLimits, ServiceItemAction
from openlp.core.ui import HideMode, MainDisplay, Display, ScreenList
@ -277,10 +277,10 @@ class SlideController(Controller):
self.toolbar.addToolbarWidget(u'Song Menu', self.songMenu)
self.songMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'), self.toolbar))
self.toolbar.makeWidgetsInvisible([u'Song Menu'])
# Stuff for items with background audio.
self.audioPauseItem = QtGui.QToolButton(self.toolbar)
self.audioPauseItem.setIcon(QtGui.QIcon(u':/slides/media_playback_pause.png'))
self.audioPauseItem.setIcon(
QtGui.QIcon(u':/slides/media_playback_pause.png'))
#u'Pause Audio', ,
self.audioPauseItem.setText(translate('OpenLP.SlideController',
'Pause audio.'))
@ -289,16 +289,27 @@ class SlideController(Controller):
QtCore.QObject.connect(self.audioPauseItem,
QtCore.SIGNAL(u'clicked(bool)'), self.onAudioPauseClicked)
self.audioPauseItem.setVisible(False)
audioMenu = QtGui.QMenu(
self.audioMenu = QtGui.QMenu(
translate('OpenLP.SlideController', 'Background Audio'),
self.toolbar)
trackMenu = audioMenu.addMenu(
self.nextTrackItem = shortcut_action(self.audioMenu,
'nextTrackItem', [], self.onNextTrackClicked, None, None,
unicode(UiStrings().LiveToolbar))
self.nextTrackItem.setText(translate('OpenLP.SlideController', 'Next Track'))
self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(
translate('OpenLP.SlideController', 'Tracks'))
trackMenu.addAction('first song')
trackMenu.addAction('second song')
trackMenu.addAction('third song')
self.trackMenu.addAction('first song')
self.trackMenu.addAction('second song')
self.trackMenu.addAction('third song')
self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
self.audioPauseItem.setMenu(audioMenu)
self.audioPauseItem.setMenu(self.audioMenu)
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setStyleSheet(u'background-color: palette(background); border-top-color: palette(shadow); border-left-color: palette(shadow); border-bottom-color: palette(light); border-right-color: palette(light); border-radius: 3px; border-style: inset; border-width: 1; font-family: monospace; margin: 2px;')
self.audioTimeLabel.setObjectName(u'audioTimeLabel')
self.toolbar.addToolbarWidget(u'Time Remaining', self.audioTimeLabel)
self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining'])
# Screen preview area
self.previewFrame = QtGui.QFrame(self.splitter)
self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio))
@ -657,6 +668,7 @@ class SlideController(Controller):
self.display.setup()
if self.isLive:
self.__addActionsToWidget(self.display)
self.display.audioPlayer.connectSlot(QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining)
# The SlidePreview's ratio.
try:
self.ratio = float(self.screens.current[u'size'].width()) / \
@ -1333,7 +1345,10 @@ class SlideController(Controller):
self.onToggleLoop()
def setAudioItemsVisibility(self, visible):
self.audioPauseItem.setVisible(visible)
if visible:
self.toolbar.makeWidgetsVisible([u'Song Menu', u'Pause Audio', u'Time Remaining'])
else:
self.toolbar.makeWidgetsInvisible([u'Song Menu', u'Pause Audio', u'Time Remaining'])
def onAudioPauseClicked(self, checked):
if not self.audioPauseItem.isVisible():
@ -1444,3 +1459,12 @@ class SlideController(Controller):
return HideMode.Screen
else:
return None
def onNextTrackClicked(self):
self.display.audioPlayer.next()
def onAudioTimeRemaining(self, time):
seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000
minutes = seconds // 60
seconds = seconds % 60
self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds))