forked from openlp/openlp
Fix taking screenshots while using powerpoint or impress.
Fix traceback when expanding and collapsing songs. In _process_item, postpone check for _reset_blank, since the service_item can change type while being execute (Pdf->Image). For the same reason always use the serviceitem that might have been converted. Fix crash when sending Pdf live. Pep8 fixes bzr-revno: 2607 Fixes: https://launchpad.net/bugs/1532169, https://launchpad.net/bugs/1532938
This commit is contained in:
commit
4ecd2085ed
@ -1131,6 +1131,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
:param item: The service item to be checked
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole)
|
||||
# Only set root items as collapsed, and since we only have 2 levels we find them by checking for children
|
||||
if item.childCount():
|
||||
self.service_items[pos - 1]['expanded'] = False
|
||||
|
||||
def on_expand_all(self, field=None):
|
||||
@ -1149,6 +1151,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
||||
:param item: The service item to be checked
|
||||
"""
|
||||
pos = item.data(0, QtCore.Qt.UserRole)
|
||||
# Only set root items as expanded, and since we only have 2 levels we find them by checking for children
|
||||
if item.childCount():
|
||||
self.service_items[pos - 1]['expanded'] = True
|
||||
|
||||
def on_service_top(self, field=None):
|
||||
|
@ -828,13 +828,13 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.selected_row = 0
|
||||
# take a copy not a link to the servicemanager copy.
|
||||
self.service_item = copy.copy(service_item)
|
||||
if self.service_item.is_command():
|
||||
Registry().execute(
|
||||
'%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
|
||||
# Reset blanking if needed
|
||||
if old_item and self.is_live and (old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay) or
|
||||
self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)):
|
||||
self._reset_blank(self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay))
|
||||
if service_item.is_command():
|
||||
Registry().execute(
|
||||
'%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
|
||||
self.info_label.setText(self.service_item.title)
|
||||
self.slide_list = {}
|
||||
if self.is_live:
|
||||
@ -886,28 +886,28 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
self.service_item.bg_image_bytes = \
|
||||
self.image_manager.get_image_bytes(frame['path'], ImageSource.ImagePlugin)
|
||||
self.preview_widget.replace_service_item(self.service_item, width, slide_no)
|
||||
self.enable_tool_bar(service_item)
|
||||
self.enable_tool_bar(self.service_item)
|
||||
# Pass to display for viewing.
|
||||
# Postpone image build, we need to do this later to avoid the theme
|
||||
# flashing on the screen
|
||||
if not self.service_item.is_image():
|
||||
self.display.build_html(self.service_item)
|
||||
if service_item.is_media():
|
||||
self.on_media_start(service_item)
|
||||
if self.service_item.is_media():
|
||||
self.on_media_start(self.service_item)
|
||||
self.slide_selected(True)
|
||||
if service_item.from_service:
|
||||
if self.service_item.from_service:
|
||||
self.preview_widget.setFocus()
|
||||
if old_item:
|
||||
# Close the old item after the new one is opened
|
||||
# This avoids the service theme/desktop flashing on screen
|
||||
# However opening a new item of the same type will automatically
|
||||
# close the previous, so make sure we don't close the new one.
|
||||
if old_item.is_command() and not service_item.is_command() or \
|
||||
old_item.is_command() and not old_item.is_media() and service_item.is_media():
|
||||
if old_item.is_command() and not self.service_item.is_command() or \
|
||||
old_item.is_command() and not old_item.is_media() and self.service_item.is_media():
|
||||
Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
|
||||
if old_item.is_media() and not service_item.is_media():
|
||||
if old_item.is_media() and not self.service_item.is_media():
|
||||
self.on_media_close()
|
||||
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [service_item])
|
||||
Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
|
||||
|
||||
def on_slide_selected_index(self, message):
|
||||
"""
|
||||
@ -1138,8 +1138,9 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
Creates an image of the current screen and updates the preview frame.
|
||||
"""
|
||||
win_id = QtWidgets.QApplication.desktop().winId()
|
||||
screen = QtWidgets.QApplication.primaryScreen()
|
||||
rect = self.screens.current['size']
|
||||
win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
win_image = screen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
|
||||
win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio())
|
||||
self.slide_preview.setPixmap(win_image)
|
||||
self.slide_image = win_image
|
||||
|
@ -349,6 +349,7 @@ class MessageListener(object):
|
||||
# When presenting PDF/XPS/OXPS, we are using the image presentation code,
|
||||
# so handler & processor is set to None, and we skip adding the handler.
|
||||
self.handler = None
|
||||
else:
|
||||
if self.handler == self.media_item.automatic:
|
||||
self.handler = self.media_item.find_controller_by_type(file)
|
||||
if not self.handler:
|
||||
|
@ -368,4 +368,3 @@ class Htmbuilder(TestCase, TestMixin):
|
||||
# WHEN: Retrieving the webkit version
|
||||
# THEN: Webkit versions should match
|
||||
self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one")
|
||||
|
||||
|
@ -189,5 +189,3 @@ class TestMainWindow(TestCase, TestMixin):
|
||||
# THEN: The media manager dock is made visible
|
||||
self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
|
||||
mocked_widget.on_focus.assert_called_with()
|
||||
|
||||
|
||||
|
@ -104,3 +104,23 @@ class TestMessageListener(TestCase, TestMixin):
|
||||
|
||||
# THEN: The controllers will be setup.
|
||||
self.assertTrue(len(controllers), 'We have loaded a controller')
|
||||
|
||||
@patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
|
||||
def start_pdf_presentation_test(self, media_mock):
|
||||
"""
|
||||
Test the startup of pdf presentation succeed.
|
||||
"""
|
||||
# GIVEN: A sservice item with a pdf
|
||||
mock_item = MagicMock()
|
||||
mock_item.processor = 'Pdf'
|
||||
mock_item.get_frame_path.return_value = "test.pdf"
|
||||
self.media_item.generate_slide_data = MagicMock()
|
||||
ml = MessageListener(self.media_item)
|
||||
ml.media_item = self.media_item
|
||||
ml.preview_handler = MagicMock()
|
||||
|
||||
# WHEN: request the presentation to start
|
||||
ml.startup([mock_item, False, False, False])
|
||||
|
||||
# THEN: The handler should be set to None
|
||||
self.assertIsNone(ml.handler, 'The handler should be None')
|
||||
|
@ -59,4 +59,3 @@ TEST3_DATA = dict(ip='333.333.333.333',
|
||||
name='___TEST_THREE___',
|
||||
location='location three',
|
||||
notes='notes three')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user