From d681afb2b4b2838d56619e689163b04b1255a0ed Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 25 Feb 2012 02:01:24 +0200 Subject: [PATCH] Added an icon in for the Next button, and added in direct-to-track skipping too. Fixes: https://launchpad.net/bugs/845692 --- openlp/core/ui/maindisplay.py | 19 +++++++- openlp/core/ui/slidecontroller.py | 58 ++++++++++++++++------- resources/images/media_playback_next.png | Bin 0 -> 506 bytes resources/images/openlp-2.qrc | 1 + 4 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 resources/images/media_playback_next.png diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 684382e21..fb45ecff0 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -575,6 +575,7 @@ class AudioPlayer(QtCore.QObject): self.playlist.append(Phonon.MediaSource(filename)) def next(self): + isPlaying = self.mediaObject.state() == Phonon.PlayingState self.mediaObject.clearQueue() self.mediaObject.clear() self.currentIndex += 1 @@ -585,7 +586,23 @@ class AudioPlayer(QtCore.QObject): self.currentIndex = -1 if self.currentIndex >= 0: self.mediaObject.enqueue(self.playlist[self.currentIndex]) - self.mediaObject.play() + if isPlaying: + self.mediaObject.play() + + def goTo(self, index): + isPlaying = self.mediaObject.state() == Phonon.PlayingState + self.mediaObject.clearQueue() + self.mediaObject.clear() + self.currentIndex = index + 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]) + if isPlaying: + self.mediaObject.play() def connectSlot(self, signal, slot): QtCore.QObject.connect(self.mediaObject, signal, slot) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index d8f6bd1a9..ade6b4bc4 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -46,9 +46,10 @@ class SlideList(QtGui.QTableWidget): Customised version of QTableWidget which can respond to keyboard events. """ - def __init__(self, parent=None, name=None): + def __init__(self, parent=None): QtGui.QTableWidget.__init__(self, parent.controller) + class Controller(QtGui.QWidget): """ Controller is a general controller widget. @@ -293,23 +294,33 @@ class SlideController(Controller): translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) self.nextTrackItem = shortcut_action(self.audioMenu, - 'nextTrackItem', [], self.onNextTrackClicked, None, None, - unicode(UiStrings().LiveToolbar)) - self.nextTrackItem.setText(translate('OpenLP.SlideController', 'Next Track')) + u'nextTrackItem', [], self.onNextTrackClicked, + u':/slides/media_playback_next.png', + category=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')) - self.trackMenu.addAction('first song') - self.trackMenu.addAction('second song') - self.trackMenu.addAction('third song') self.audioPauseItem.setPopupMode(QtGui.QToolButton.MenuButtonPopup) 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.setAlignment( + QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter) + self.audioTimeLabel.setStyleSheet( + u'background-color: palette(background); ' + u'border-top-color: palette(shadow); ' + u'border-left-color: palette(shadow); ' + u'border-bottom-color: palette(light); ' + u'border-right-color: palette(light); ' + u'border-radius: 3px; border-style: inset; ' + u'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']) + 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)) @@ -570,7 +581,7 @@ class SlideController(Controller): # Reset the shortcut. self.current_shortcut = u'' - def setPreviewHotkeys(self, parent=None): + def setPreviewHotkeys(self): self.previousItem.setObjectName(u'previousItemPreview') self.nextItem.setObjectName(u'nextItemPreview') action_list = ActionList.get_instance() @@ -647,7 +658,7 @@ class SlideController(Controller): self.keypress_loop = True keypressCommand = self.keypress_queue.popleft() if keypressCommand == ServiceItemAction.Previous: - Receiver.send_message('servicemanager_previous_item', None) + Receiver.send_message('servicemanager_previous_item') elif keypressCommand == ServiceItemAction.PreviousLastSlide: # Go to the last slide of the previous item Receiver.send_message('servicemanager_previous_item', u'last slide') @@ -680,7 +691,7 @@ class SlideController(Controller): self.previewDisplay.setup() serviceItem = ServiceItem() self.previewDisplay.webView.setHtml(build_html(serviceItem, - self.previewDisplay.screen, None, self.isLive, None, + self.previewDisplay.screen, None, self.isLive, plugins=PluginManager.get_instance().plugins)) self.mediaController.setup_display(self.previewDisplay) if self.serviceItem: @@ -892,6 +903,14 @@ class SlideController(Controller): log.debug(u'Starting to play...') self.display.audioPlayer.addToPlaylist( self.serviceItem.background_audio) + self.trackMenu.clear() + for counter in range(len(self.serviceItem.background_audio)): + action = self.trackMenu.addAction(os.path.basename( + self.serviceItem.background_audio[counter])) + action.setData(counter) + QtCore.QObject.connect(action, + QtCore.SIGNAL(u'triggered(bool)'), + self.onTrackTriggered) self.display.audioPlayer.repeat = QtCore.QSettings().value( self.parent().generalSettingsSection + \ u'/audio repeat list', @@ -947,7 +966,7 @@ class SlideController(Controller): self.slideList[unicode(row)] = row - 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) - if slideHeight != 0: + if not slideHeight: self.previewListWidget.setRowHeight(framenumber, slideHeight) self.previewListWidget.setVerticalHeaderLabels(text) if self.serviceItem.is_text(): @@ -1149,7 +1168,7 @@ class SlideController(Controller): else: Receiver.send_message(u'live_display_show') - def onSlideSelected(self, start=False): + def onSlideSelected(self): """ Slide selected in controller """ @@ -1466,5 +1485,10 @@ class SlideController(Controller): def onAudioTimeRemaining(self, time): seconds = self.display.audioPlayer.mediaObject.remainingTime() // 1000 minutes = seconds // 60 - seconds = seconds % 60 + seconds %= 60 self.audioTimeLabel.setText(u' %02d:%02d ' % (minutes, seconds)) + + def onTrackTriggered(self): + action = self.sender() + index = action.data().toInt()[0] + self.display.audioPlayer.goTo(index) diff --git a/resources/images/media_playback_next.png b/resources/images/media_playback_next.png new file mode 100644 index 0000000000000000000000000000000000000000..0d22924eef18d1f675d39e9c1468682f47365f5a GIT binary patch literal 506 zcmVMzCV_|S* zE^l&Yo9;Xs0004bNklPHu8N*UY6P4s` zVoj6z5W7`$3L^Rz8)eWJ2x3qkLcDl+8P$3TJFJagzh4L;#9`?m%etMslV{z7?64$+ z5Ftb-*-P8QrY#*ETbkO#y|j}E5n?B4_clFpr0<&(Ume-DsomR2M2J?p?zu0%8~E!& z;fGVttZStr($dDT<=A__{4+5zHc~jVWn-9@Vl7+p(NAx^atzp1SLj=^wjayg6`vJe z+V#*I7g#ZEabo4 zQA=k%b*3;fHZe9*cx_fK6(Q!6T5raxzHqLoy+I)a<`IIOF{_oABo&%w-$tV_5c6?07*qoM6N<$g1p4kZvX%Q literal 0 HcmV?d00001 diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index dc444d445..1b833a4db 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -68,6 +68,7 @@ media_playback_start.png media_playback_stop.png media_playback_pause.png + media_playback_next.png openlp-logo-16x16.png