← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/presentation-fixes24 into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/presentation-fixes24 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1532169 in OpenLP: "Expanding or Collapsing a Song in ServiceManager raises an Exception"
  https://bugs.launchpad.net/openlp/+bug/1532169
  Bug #1532938 in OpenLP: "Presenting with PowerPoint or Impress triggers traceback"
  https://bugs.launchpad.net/openlp/+bug/1532938

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/presentation-fixes24/+merge/282661

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

-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/presentation-fixes24 into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2016-01-09 17:22:09 +0000
+++ openlp/core/ui/servicemanager.py	2016-01-14 20:22:09 +0000
@@ -1131,7 +1131,9 @@
         :param item: The service item to be checked
         """
         pos = item.data(0, QtCore.Qt.UserRole)
-        self.service_items[pos - 1]['expanded'] = False
+        # 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,7 +1151,9 @@
         :param item: The service item to be checked
         """
         pos = item.data(0, QtCore.Qt.UserRole)
-        self.service_items[pos - 1]['expanded'] = True
+        # 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):
         """

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2015-12-31 22:46:06 +0000
+++ openlp/core/ui/slidecontroller.py	2016-01-14 20:22:09 +0000
@@ -828,13 +828,13 @@
         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 @@
                     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 @@
         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

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2016-01-14 20:22:09 +0000
@@ -349,16 +349,17 @@
             # 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
-        if self.handler == self.media_item.automatic:
-            self.handler = self.media_item.find_controller_by_type(file)
-            if not self.handler:
-                return
         else:
-            # the saved handler is not present so need to use one based on file suffix.
-            if not self.controllers[self.handler].available:
+            if self.handler == self.media_item.automatic:
                 self.handler = self.media_item.find_controller_by_type(file)
                 if not self.handler:
                     return
+            else:
+                # the saved handler is not present so need to use one based on file suffix.
+                if not self.controllers[self.handler].available:
+                    self.handler = self.media_item.find_controller_by_type(file)
+                    if not self.handler:
+                        return
         if is_live:
             controller = self.live_handler
         else:

=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py	2016-01-10 16:01:43 +0000
+++ openlp/plugins/songs/forms/editsongform.py	2016-01-14 20:22:09 +0000
@@ -515,7 +515,7 @@
             self.topics_list_view.addItem(topic_name)
         self.songbooks_list_view.clear()
         for songbook_entry in self.song.songbook_entries:
-            self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, 
+            self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
                                             songbook_entry.entry)
         self.audio_list_widget.clear()
         for media in self.song.media_files:

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2016-01-10 16:01:43 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2016-01-14 20:22:09 +0000
@@ -255,9 +255,9 @@
         search_entry = re.sub(r'[^0-9]', '', search_keywords[2])
 
         songbook_entries = (self.plugin.manager.session.query(SongBookEntry)
-                           .join(Book)
-                           .order_by(Book.name)
-                           .order_by(SongBookEntry.entry))
+                            .join(Book)
+                            .order_by(Book.name)
+                            .order_by(SongBookEntry.entry))
         for songbook_entry in songbook_entries:
             if songbook_entry.song.temporary:
                 continue

=== modified file 'tests/functional/openlp_core_lib/test_htmlbuilder.py'
--- tests/functional/openlp_core_lib/test_htmlbuilder.py	2016-01-03 11:47:07 +0000
+++ tests/functional/openlp_core_lib/test_htmlbuilder.py	2016-01-14 20:22:09 +0000
@@ -363,9 +363,8 @@
         """
         Test the webkit_version() function
         """
-        # GIVEN: Webkit 
+        # GIVEN: Webkit
         webkit_ver = float(QtWebKit.qWebKitVersion())
         # 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")
-

=== modified file 'tests/functional/openlp_core_ui/test_mainwindow.py'
--- tests/functional/openlp_core_ui/test_mainwindow.py	2016-01-09 19:10:56 +0000
+++ tests/functional/openlp_core_ui/test_mainwindow.py	2016-01-14 20:22:09 +0000
@@ -189,5 +189,3 @@
             # 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()
-
-

=== modified file 'tests/functional/openlp_plugins/presentations/test_messagelistener.py'
--- tests/functional/openlp_plugins/presentations/test_messagelistener.py	2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_plugins/presentations/test_messagelistener.py	2016-01-14 20:22:09 +0000
@@ -104,3 +104,23 @@
 
         # 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')

=== modified file 'tests/resources/projector/data.py'
--- tests/resources/projector/data.py	2016-01-09 17:21:20 +0000
+++ tests/resources/projector/data.py	2016-01-14 20:22:09 +0000
@@ -59,4 +59,3 @@
                   name='___TEST_THREE___',
                   location='location three',
                   notes='notes three')
-


Follow ups