Tim Bentley 2017-11-11 08:36:22 -07:00 committed by Raoul Snyman
commit 5ae5d8c07e
4 changed files with 43 additions and 3 deletions

View File

@ -27,7 +27,7 @@ from openlp.core.api.endpoint.core import TRANSLATED_STRINGS
log = logging.getLogger(__name__)
remote_endpoint = Endpoint('remote', template_dir='remotes', static_dir='remotes')
remote_endpoint = Endpoint('remote', template_dir='remotes')
@remote_endpoint.route('{view}')

View File

@ -151,8 +151,9 @@ class Registry(object):
trace_error_handler(log)
log.exception('Exception for function {function}'.format(function=function))
else:
trace_error_handler(log)
log.exception('Event {event} called but not registered'.format(event=event))
if log.getEffectiveLevel() == logging.DEBUG:
trace_error_handler(log)
log.exception('Event {event} called but not registered'.format(event=event))
return results
def get_flag(self, key):

View File

@ -236,6 +236,9 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
self.hide_menu.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.hide_menu.setMenu(QtWidgets.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.toolbar.add_toolbar_widget(self.hide_menu)
self.toolbar.add_toolbar_action('goPreview', icon=':/general/general_live.png',
tooltip=translate('OpenLP.SlideController', 'Move to preview.'),
triggers=self.on_go_preview)
# The order of the blank to modes in Shortcuts list comes from here.
self.desktop_screen_enable = create_action(self, 'desktopScreenEnable',
text=translate('OpenLP.SlideController', 'Show Desktop'),
@ -1420,6 +1423,15 @@ class SlideController(DisplayController, LogMixin, RegistryProperties):
self.live_controller.add_service_manager_item(self.service_item, row)
self.live_controller.preview_widget.setFocus()
def on_go_preview(self, field=None):
"""
If live copy slide item to preview controller from live Controller
"""
row = self.preview_widget.current_slide_number()
if -1 < row < self.preview_widget.slide_count():
self.preview_controller.add_service_manager_item(self.service_item, row)
self.preview_controller.preview_widget.setFocus()
def on_media_start(self, item):
"""
Respond to the arrival of a media service item

View File

@ -208,6 +208,33 @@ class TestSlideController(TestCase):
mocked_on_theme_display.assert_called_once_with(False)
mocked_on_hide_display.assert_called_once_with(False)
def test_on_go_live_preview_controller(self):
"""
Test that when the on_go_preview() method is called the message is sent to the preview controller and focus is
set correctly.
"""
# GIVEN: A new SlideController instance and plugin preview then pressing go live should respond
mocked_display = MagicMock()
mocked_preview_controller = MagicMock()
mocked_preview_widget = MagicMock()
mocked_service_item = MagicMock()
mocked_service_item.from_service = False
mocked_preview_widget.current_slide_number.return_value = 1
mocked_preview_widget.slide_count = MagicMock(return_value=2)
mocked_preview_controller.preview_widget = MagicMock()
Registry.create()
Registry().register('preview_controller', mocked_preview_controller)
slide_controller = SlideController(None)
slide_controller.service_item = mocked_service_item
slide_controller.preview_widget = mocked_preview_widget
slide_controller.display = mocked_display
# WHEN: on_go_live() is called
slide_controller.on_go_preview()
# THEN: the preview controller should have the service item and the focus set to live
mocked_preview_controller.preview_widget.setFocus.assert_called_once_with()
def test_on_go_live_live_controller(self):
"""
Test that when the on_go_live() method is called the message is sent to the live controller and focus is