Add Autoplay feature to Service items and Service Manager

bzr-revno: 2152
This commit is contained in:
Dmitriy Marmyshev 2013-01-21 06:45:00 +00:00 committed by Tim Bentley
commit a20c077698
3 changed files with 111 additions and 6 deletions

View File

@ -183,6 +183,9 @@ class ServiceItem(object):
self.background_audio = [] self.background_audio = []
self.theme_overwritten = False self.theme_overwritten = False
self.temporary_edit = False self.temporary_edit = False
self.auto_play_slides_once = False
self.auto_play_slides_loop = False
self.timed_slide_interval = 0
self.will_auto_start = False self.will_auto_start = False
self.has_original_files = True self.has_original_files = True
self._new_item() self._new_item()
@ -344,6 +347,9 @@ class ServiceItem(object):
u'search': self.search_string, u'search': self.search_string,
u'data': self.data_string, u'data': self.data_string,
u'xml_version': self.xml_version, u'xml_version': self.xml_version,
u'auto_play_slides_once': self.auto_play_slides_once,
u'auto_play_slides_loop': self.auto_play_slides_loop,
u'timed_slide_interval': self.timed_slide_interval,
u'start_time': self.start_time, u'start_time': self.start_time,
u'end_time': self.end_time, u'end_time': self.end_time,
u'media_length': self.media_length, u'media_length': self.media_length,
@ -398,6 +404,9 @@ class ServiceItem(object):
self.start_time = header.get(u'start_time', 0) self.start_time = header.get(u'start_time', 0)
self.end_time = header.get(u'end_time', 0) self.end_time = header.get(u'end_time', 0)
self.media_length = header.get(u'media_length', 0) self.media_length = header.get(u'media_length', 0)
self.auto_play_slides_once = header.get(u'auto_play_slides_once', False)
self.auto_play_slides_loop = header.get(u'auto_play_slides_loop', False)
self.timed_slide_interval = header.get(u'timed_slide_interval', 0)
self.will_auto_start = header.get(u'will_auto_start', False) self.will_auto_start = header.get(u'will_auto_start', False)
self.has_original_files = True self.has_original_files = True
if u'background_audio' in header: if u'background_audio' in header:
@ -427,7 +436,6 @@ class ServiceItem(object):
self.add_from_command(path, text_image[u'title'], text_image[u'image']) self.add_from_command(path, text_image[u'title'], text_image[u'image'])
else: else:
self.add_from_command(text_image[u'path'], text_image[u'title'], text_image[u'image']) self.add_from_command(text_image[u'path'], text_image[u'title'], text_image[u'image'])
self._new_item() self._new_item()
def get_display_title(self): def get_display_title(self):

View File

@ -257,6 +257,20 @@ class ServiceManager(QtGui.QWidget):
text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'), text=translate('OpenLP.ServiceManager', 'Create New &Custom Slide'),
icon=u':/general/general_edit.png', triggers=self.create_custom) icon=u':/general/general_edit.png', triggers=self.create_custom)
self.menu.addSeparator() self.menu.addSeparator()
# Add AutoPlay menu actions
self.autoPlaySlidesGroup = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides'))
self.menu.addMenu(self.autoPlaySlidesGroup)
self.autoPlaySlidesLoop = create_widget_action(self.autoPlaySlidesGroup,
text=translate('OpenLP.ServiceManager', 'Auto play slides &Loop'),
checked=False, triggers=self.toggleAutoPlaySlidesLoop)
self.autoPlaySlidesOnce = create_widget_action(self.autoPlaySlidesGroup,
text=translate('OpenLP.ServiceManager', 'Auto play slides &Once'),
checked=False, triggers=self.toggleAutoPlaySlidesOnce)
self.autoPlaySlidesGroup.addSeparator()
self.timedSlideInterval = create_widget_action(self.autoPlaySlidesGroup,
text=translate('OpenLP.ServiceManager', '&Delay between slides'),
checked=False, triggers=self.onTimedSlideInterval)
self.menu.addSeparator()
self.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'), self.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'),
icon=u':/general/general_preview.png', triggers=self.makePreview) icon=u':/general/general_preview.png', triggers=self.makePreview)
# Add already existing make live action to the menu. # Add already existing make live action to the menu.
@ -766,6 +780,22 @@ class ServiceManager(QtGui.QWidget):
self.maintainAction.setVisible(True) self.maintainAction.setVisible(True)
if item.parent() is None: if item.parent() is None:
self.notesAction.setVisible(True) self.notesAction.setVisible(True)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanLoop) and \
len(serviceItem[u'service_item'].get_frames()) > 1:
self.autoPlaySlidesGroup.menuAction().setVisible(True)
self.autoPlaySlidesOnce.setChecked(serviceItem[u'service_item'].auto_play_slides_once)
self.autoPlaySlidesLoop.setChecked(serviceItem[u'service_item'].auto_play_slides_loop)
self.timedSlideInterval.setChecked(serviceItem[u'service_item'].timed_slide_interval > 0)
if serviceItem[u'service_item'].timed_slide_interval > 0:
delay_suffix = u' '
delay_suffix += unicode(serviceItem[u'service_item'].timed_slide_interval)
delay_suffix += u' s'
else:
delay_suffix = u' ...'
self.timedSlideInterval.setText(translate('OpenLP.ServiceManager', '&Delay between slides') + delay_suffix)
# TODO for future: make group explains itself more visually
else:
self.autoPlaySlidesGroup.menuAction().setVisible(False)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime): if serviceItem[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime):
self.timeAction.setVisible(True) self.timeAction.setVisible(True)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive): if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
@ -811,6 +841,59 @@ class ServiceManager(QtGui.QWidget):
if self.startTimeForm.exec_(): if self.startTimeForm.exec_():
self.repaintServiceList(item, -1) self.repaintServiceList(item, -1)
def toggleAutoPlaySlidesOnce(self):
"""
Toggle Auto play slide once.
Inverts auto play once option for the item
"""
item = self.findServiceItem()[0]
service_item = self.serviceItems[item][u'service_item']
service_item.auto_play_slides_once = not service_item.auto_play_slides_once
if service_item.auto_play_slides_once:
service_item.auto_play_slides_loop = False
self.autoPlaySlidesLoop.setChecked(False)
if service_item.auto_play_slides_once and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value(u'loop delay', 5)
self.setModified()
def toggleAutoPlaySlidesLoop(self):
"""
Toggle Auto play slide loop.
"""
item = self.findServiceItem()[0]
service_item = self.serviceItems[item][u'service_item']
service_item.auto_play_slides_loop = not service_item.auto_play_slides_loop
if service_item.auto_play_slides_loop:
service_item.auto_play_slides_once = False
self.autoPlaySlidesOnce.setChecked(False)
if service_item.auto_play_slides_loop and service_item.timed_slide_interval == 0:
service_item.timed_slide_interval = Settings().value(u'loop delay', 5)
self.setModified()
def onTimedSlideInterval(self):
"""
on set times slide interval.
Shows input dialog for enter interval in seconds for delay
"""
item = self.findServiceItem()[0]
service_item = self.serviceItems[item][u'service_item']
if service_item.timed_slide_interval == 0:
timed_slide_interval = Settings().value(u'loop delay', 5)
else:
timed_slide_interval = service_item.timed_slide_interval
timed_slide_interval, ok = QtGui.QInputDialog.getInteger(self, translate('OpenLP.ServiceManager',
'Input delay'), translate('OpenLP.ServiceManager', 'Delay between slides in seconds.'),
timed_slide_interval, 0, 180, 1)
if ok:
service_item.timed_slide_interval = timed_slide_interval
if service_item.timed_slide_interval <> 0 and not service_item.auto_play_slides_loop\
and not service_item.auto_play_slides_once:
service_item.auto_play_slides_loop = True
elif service_item.timed_slide_interval == 0:
service_item.auto_play_slides_loop = False
service_item.auto_play_slides_once = False
self.setModified()
def onAutoStart(self): def onAutoStart(self):
""" """
Toggles to Auto Start Setting. Toggles to Auto Start Setting.
@ -1291,6 +1374,8 @@ class ServiceManager(QtGui.QWidget):
if self.serviceItems and item < len(self.serviceItems) and \ if self.serviceItems and item < len(self.serviceItems) and \
self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview): self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview):
self.mainwindow.previewController.addServiceManagerItem(self.serviceItems[item][u'service_item'], 0) self.mainwindow.previewController.addServiceManagerItem(self.serviceItems[item][u'service_item'], 0)
next_item = self.serviceManagerList.topLevelItem(item)
self.serviceManagerList.setCurrentItem(next_item)
self.mainwindow.liveController.previewListWidget.setFocus() self.mainwindow.liveController.previewListWidget.setFocus()
else: else:
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'), critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),

View File

@ -692,6 +692,14 @@ class SlideController(DisplayController):
self.slideSelected() self.slideSelected()
else: else:
self._processItem(item, slidenum) self._processItem(item, slidenum)
if self.isLive and item.auto_play_slides_loop and item.timed_slide_interval > 0:
self.playSlidesLoop.setChecked(item.auto_play_slides_loop)
self.delaySpinBox.setValue(int(item.timed_slide_interval))
self.onPlaySlidesLoop()
elif self.isLive and item.auto_play_slides_once and item.timed_slide_interval > 0:
self.playSlidesOnce.setChecked(item.auto_play_slides_once)
self.delaySpinBox.setValue(int(item.timed_slide_interval))
self.onPlaySlidesOnce()
def _processItem(self, serviceItem, slideno): def _processItem(self, serviceItem, slideno):
""" """
@ -881,6 +889,7 @@ class SlideController(DisplayController):
Settings().remove(self.parent().generalSettingsSection + u'/screen blank') Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin() self.blankPlugin()
self.updatePreview() self.updatePreview()
self.onToggleLoop()
def onThemeDisplay(self, checked=None): def onThemeDisplay(self, checked=None):
""" """
@ -899,6 +908,7 @@ class SlideController(DisplayController):
Settings().remove(self.parent().generalSettingsSection + u'/screen blank') Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin() self.blankPlugin()
self.updatePreview() self.updatePreview()
self.onToggleLoop()
def onHideDisplay(self, checked=None): def onHideDisplay(self, checked=None):
""" """
@ -917,6 +927,7 @@ class SlideController(DisplayController):
Settings().remove(self.parent().generalSettingsSection + u'/screen blank') Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.hidePlugin(checked) self.hidePlugin(checked)
self.updatePreview() self.updatePreview()
self.onToggleLoop()
def blankPlugin(self): def blankPlugin(self):
""" """
@ -1092,7 +1103,8 @@ class SlideController(DisplayController):
""" """
Toggles the loop state. Toggles the loop state.
""" """
if self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked(): hide_mode = self.hideMode()
if hide_mode is None and (self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked()):
self.onStartLoop() self.onStartLoop()
else: else:
self.onStopLoop() self.onStopLoop()
@ -1126,11 +1138,11 @@ class SlideController(DisplayController):
self.playSlidesLoop.setText(UiStrings().StopPlaySlidesInLoop) self.playSlidesLoop.setText(UiStrings().StopPlaySlidesInLoop)
self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png')) self.playSlidesOnce.setIcon(build_icon(u':/media/media_time.png'))
self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd) self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd)
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
self.playSlidesOnce.setChecked(False)
else: else:
self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png'))
self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop) self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop)
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
self.playSlidesOnce.setChecked(False)
self.onToggleLoop() self.onToggleLoop()
def onPlaySlidesOnce(self, checked=None): def onPlaySlidesOnce(self, checked=None):
@ -1147,11 +1159,11 @@ class SlideController(DisplayController):
self.playSlidesOnce.setText(UiStrings().StopPlaySlidesToEnd) self.playSlidesOnce.setText(UiStrings().StopPlaySlidesToEnd)
self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png')) self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png'))
self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop) self.playSlidesLoop.setText(UiStrings().PlaySlidesInLoop)
self.playSlidesMenu.setDefaultAction(self.playSlidesOnce)
self.playSlidesLoop.setChecked(False)
else: else:
self.playSlidesOnce.setIcon(build_icon(u':/media/media_time')) self.playSlidesOnce.setIcon(build_icon(u':/media/media_time'))
self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd) self.playSlidesOnce.setText(UiStrings().PlaySlidesToEnd)
self.playSlidesMenu.setDefaultAction(self.playSlidesOnce)
self.playSlidesLoop.setChecked(False)
self.onToggleLoop() self.onToggleLoop()
def setAudioItemsVisibility(self, visible): def setAudioItemsVisibility(self, visible):