This commit is contained in:
Phill Ridout 2014-12-29 17:25:36 +00:00
commit 36417083ce
8 changed files with 55 additions and 15 deletions

View File

@ -217,6 +217,8 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties):
if self.current_media_players[source].state != MediaState.Paused: if self.current_media_players[source].state != MediaState.Paused:
display = self._define_display(self.display_controllers[source]) display = self._define_display(self.display_controllers[source])
display.controller.seek_slider.setSliderPosition(0) display.controller.seek_slider.setSliderPosition(0)
display.controller.mediabar.actions['playbackPlay'].setVisible(True)
display.controller.mediabar.actions['playbackPause'].setVisible(False)
self.timer.stop() self.timer.stop()
def get_media_display_css(self): def get_media_display_css(self):

View File

@ -883,7 +883,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
# TODO for future: make group explains itself more visually # TODO for future: make group explains itself more visually
else: else:
self.auto_play_slides_menu.menuAction().setVisible(False) self.auto_play_slides_menu.menuAction().setVisible(False)
if service_item['service_item'].is_capable(ItemCapabilities.HasVariableStartTime): if service_item['service_item'].is_capable(ItemCapabilities.HasVariableStartTime) and \
not service_item['service_item'].is_capable(ItemCapabilities.IsOptical):
self.time_action.setVisible(True) self.time_action.setVisible(True)
if service_item['service_item'].is_capable(ItemCapabilities.CanAutoStartForLive): if service_item['service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
self.auto_start_action.setVisible(True) self.auto_start_action.setVisible(True)
@ -1478,8 +1479,6 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
if self.service_items and item < len(self.service_items) and \ if self.service_items and item < len(self.service_items) and \
self.service_items[item]['service_item'].is_capable(ItemCapabilities.CanPreview): self.service_items[item]['service_item'].is_capable(ItemCapabilities.CanPreview):
self.preview_controller.add_service_manager_item(self.service_items[item]['service_item'], 0) self.preview_controller.add_service_manager_item(self.service_items[item]['service_item'], 0)
next_item = self.service_manager_list.topLevelItem(item)
self.service_manager_list.setCurrentItem(next_item)
self.live_controller.preview_widget.setFocus() self.live_controller.preview_widget.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

@ -33,6 +33,7 @@ The :mod:`slidecontroller` module contains the most important part of OpenLP - t
import os import os
import copy import copy
from collections import deque from collections import deque
from threading import Lock
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
@ -131,6 +132,8 @@ class SlideController(DisplayController, RegistryProperties):
self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height() self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height()
except ZeroDivisionError: except ZeroDivisionError:
self.ratio = 1 self.ratio = 1
self.process_queue_lock = Lock()
self.slide_selected_lock = Lock()
self.timer_id = 0 self.timer_id = 0
self.song_edit = False self.song_edit = False
self.selected_row = 0 self.selected_row = 0
@ -531,9 +534,9 @@ class SlideController(DisplayController, RegistryProperties):
Process the service item request queue. The key presses can arrive Process the service item request queue. The key presses can arrive
faster than the processing so implement a FIFO queue. faster than the processing so implement a FIFO queue.
""" """
if self.keypress_queue: # Make sure only one thread get in here. Just return if already locked.
while len(self.keypress_queue) and not self.keypress_loop: if self.keypress_queue and self.process_queue_lock.acquire(False):
self.keypress_loop = True while len(self.keypress_queue):
keypress_command = self.keypress_queue.popleft() keypress_command = self.keypress_queue.popleft()
if keypress_command == ServiceItemAction.Previous: if keypress_command == ServiceItemAction.Previous:
self.service_manager.previous_item() self.service_manager.previous_item()
@ -542,7 +545,7 @@ class SlideController(DisplayController, RegistryProperties):
self.service_manager.previous_item(last_slide=True) self.service_manager.previous_item(last_slide=True)
else: else:
self.service_manager.next_item() self.service_manager.next_item()
self.keypress_loop = False self.process_queue_lock.release()
def screen_size_changed(self): def screen_size_changed(self):
""" """
@ -1040,6 +1043,10 @@ class SlideController(DisplayController, RegistryProperties):
:param start: :param start:
""" """
# Only one thread should be in here at the time. If already locked just skip, since the update will be
# done by the thread holding the lock. If it is a "start" slide, we must wait for the lock.
if not self.slide_selected_lock.acquire(start):
return
row = self.preview_widget.current_slide_number() row = self.preview_widget.current_slide_number()
self.selected_row = 0 self.selected_row = 0
if -1 < row < self.preview_widget.slide_count(): if -1 < row < self.preview_widget.slide_count():
@ -1062,6 +1069,8 @@ class SlideController(DisplayController, RegistryProperties):
self.update_preview() self.update_preview()
self.preview_widget.change_slide(row) self.preview_widget.change_slide(row)
self.display.setFocus() self.display.setFocus()
# Release lock
self.slide_selected_lock.release()
def on_slide_change(self, row): def on_slide_change(self, row):
""" """
@ -1406,7 +1415,6 @@ class LiveController(RegistryMixin, OpenLPMixin, SlideController):
self.split = 1 self.split = 1
self.type_prefix = 'live' self.type_prefix = 'live'
self.keypress_queue = deque() self.keypress_queue = deque()
self.keypress_loop = False
self.category = UiStrings().LiveToolbar self.category = UiStrings().LiveToolbar
ActionList.get_instance().add_category(str(self.category), CategoryOrder.standard_toolbar) ActionList.get_instance().add_category(str(self.category), CategoryOrder.standard_toolbar)

View File

@ -56,7 +56,9 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties):
self.hour_spin_box.setValue(hour) self.hour_spin_box.setValue(hour)
self.minute_spin_box.setValue(minutes) self.minute_spin_box.setValue(minutes)
self.second_spin_box.setValue(seconds) self.second_spin_box.setValue(seconds)
hours, minutes, seconds = self._time_split(self.item['service_item'].media_length) hours, minutes, seconds = self._time_split(self.item['service_item'].end_time)
if hours == 0 and minutes == 0 and seconds == 0:
hours, minutes, seconds = self._time_split(self.item['service_item'].media_length)
self.hour_finish_spin_box.setValue(hours) self.hour_finish_spin_box.setValue(hours)
self.minute_finish_spin_box.setValue(minutes) self.minute_finish_spin_box.setValue(minutes)
self.second_finish_spin_box.setValue(seconds) self.second_finish_spin_box.setValue(seconds)

View File

@ -93,10 +93,10 @@ class BGExtract(RegistryProperties):
""" """
if isinstance(tag, NavigableString): if isinstance(tag, NavigableString):
return None, str(tag) return None, str(tag)
elif tag.get('class')[0] == "versenum" or tag.get('class')[0] == 'versenum mid-line': elif tag.get('class') and (tag.get('class')[0] == 'versenum' or tag.get('class')[0] == 'versenum mid-line'):
verse = str(tag.string).replace('[', '').replace(']', '').strip() verse = str(tag.string).replace('[', '').replace(']', '').strip()
return verse, None return verse, None
elif tag.get('class')[0] == 'chapternum': elif tag.get('class') and tag.get('class')[0] == 'chapternum':
verse = '1' verse = '1'
return verse, None return verse, None
else: else:

View File

@ -84,13 +84,15 @@ class AuthorType(object):
NoType, NoType,
Words, Words,
Music, Music,
WordsAndMusic WordsAndMusic,
Translation
] ]
TranslatedTypes = [ TranslatedTypes = [
Types[NoType], Types[NoType],
Types[Words], Types[Words],
Types[Music], Types[Music],
Types[WordsAndMusic] Types[WordsAndMusic],
Types[Translation]
] ]
@staticmethod @staticmethod

View File

@ -158,9 +158,9 @@ class TestDB(TestCase):
# THEN: It should return only the name # THEN: It should return only the name
self.assertEqual("John Doe", display_name) self.assertEqual("John Doe", display_name)
def test_author_get_display_name_with_type(self): def test_author_get_display_name_with_type_words(self):
""" """
Test that the display name of an author with a type is correct Test that the display name of an author with a type is correct (Words)
""" """
# GIVEN: An author # GIVEN: An author
author = Author() author = Author()
@ -172,6 +172,20 @@ class TestDB(TestCase):
# THEN: It should return the name with the type in brackets # THEN: It should return the name with the type in brackets
self.assertEqual("John Doe (Words)", display_name) self.assertEqual("John Doe (Words)", display_name)
def test_author_get_display_name_with_type_translation(self):
"""
Test that the display name of an author with a type is correct (Translation)
"""
# GIVEN: An author
author = Author()
author.display_name = "John Doe"
# WHEN: We call the get_display_name() function
display_name = author.get_display_name(AuthorType.Translation)
# THEN: It should return the name with the type in brackets
self.assertEqual("John Doe (Translation)", display_name)
def test_upgrade_old_song_db(self): def test_upgrade_old_song_db(self):
""" """
Test that we can upgrade an old song db to the current schema Test that we can upgrade an old song db to the current schema

View File

@ -85,6 +85,19 @@ class TestBibleHTTP(TestCase):
# THEN: We should get back a valid service item # THEN: We should get back a valid service item
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed' assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
def bible_gateway_extract_verse_nkjv_test(self):
"""
Test the Bible Gateway retrieval of verse list for NKJV bible John 3
"""
# GIVEN: A new Bible Gateway extraction class
handler = BGExtract()
# WHEN: The Books list is called
results = handler.get_bible_chapter('NKJV', 'John', 3)
# THEN: We should get back a valid service item
assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed'
def crosswalk_extract_books_test(self): def crosswalk_extract_books_test(self):
""" """
Test Crosswalk retrieval of book list for NIV bible Test Crosswalk retrieval of book list for NIV bible