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

Proposed by Tomas Groth on 2016-01-14
Status: Merged
Approved by: Tim Bentley on 2016-01-14
Approved revision: 2611
Merged at revision: 2607
Proposed branch: lp:~tomasgroth/openlp/presentation-fixes24
Merge into: lp:openlp
Diff against target: 214 lines (+51/-29)
9 files modified
openlp/core/ui/servicemanager.py (+6/-2)
openlp/core/ui/slidecontroller.py (+13/-12)
openlp/plugins/presentations/lib/messagelistener.py (+7/-6)
openlp/plugins/songs/forms/editsongform.py (+1/-1)
openlp/plugins/songs/lib/mediaitem.py (+3/-3)
tests/functional/openlp_core_lib/test_htmlbuilder.py (+1/-2)
tests/functional/openlp_core_ui/test_mainwindow.py (+0/-2)
tests/functional/openlp_plugins/presentations/test_messagelistener.py (+20/-0)
tests/resources/projector/data.py (+0/-1)
To merge this branch: bzr merge lp:~tomasgroth/openlp/presentation-fixes24
Reviewer Review Type Date Requested Status
Tim Bentley Approve on 2016-01-14
Raoul Snyman 2016-01-14 Approve on 2016-01-14
Review via email: mp+282661@code.launchpad.net

Description of the change

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/servicemanager.py'
2--- openlp/core/ui/servicemanager.py 2016-01-09 17:22:09 +0000
3+++ openlp/core/ui/servicemanager.py 2016-01-14 20:22:09 +0000
4@@ -1131,7 +1131,9 @@
5 :param item: The service item to be checked
6 """
7 pos = item.data(0, QtCore.Qt.UserRole)
8- self.service_items[pos - 1]['expanded'] = False
9+ # Only set root items as collapsed, and since we only have 2 levels we find them by checking for children
10+ if item.childCount():
11+ self.service_items[pos - 1]['expanded'] = False
12
13 def on_expand_all(self, field=None):
14 """
15@@ -1149,7 +1151,9 @@
16 :param item: The service item to be checked
17 """
18 pos = item.data(0, QtCore.Qt.UserRole)
19- self.service_items[pos - 1]['expanded'] = True
20+ # Only set root items as expanded, and since we only have 2 levels we find them by checking for children
21+ if item.childCount():
22+ self.service_items[pos - 1]['expanded'] = True
23
24 def on_service_top(self, field=None):
25 """
26
27=== modified file 'openlp/core/ui/slidecontroller.py'
28--- openlp/core/ui/slidecontroller.py 2015-12-31 22:46:06 +0000
29+++ openlp/core/ui/slidecontroller.py 2016-01-14 20:22:09 +0000
30@@ -828,13 +828,13 @@
31 self.selected_row = 0
32 # take a copy not a link to the servicemanager copy.
33 self.service_item = copy.copy(service_item)
34+ if self.service_item.is_command():
35+ Registry().execute(
36+ '%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
37 # Reset blanking if needed
38 if old_item and self.is_live and (old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay) or
39 self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay)):
40 self._reset_blank(self.service_item.is_capable(ItemCapabilities.ProvidesOwnDisplay))
41- if service_item.is_command():
42- Registry().execute(
43- '%s_start' % service_item.name.lower(), [self.service_item, self.is_live, self.hide_mode(), slide_no])
44 self.info_label.setText(self.service_item.title)
45 self.slide_list = {}
46 if self.is_live:
47@@ -886,28 +886,28 @@
48 self.service_item.bg_image_bytes = \
49 self.image_manager.get_image_bytes(frame['path'], ImageSource.ImagePlugin)
50 self.preview_widget.replace_service_item(self.service_item, width, slide_no)
51- self.enable_tool_bar(service_item)
52+ self.enable_tool_bar(self.service_item)
53 # Pass to display for viewing.
54 # Postpone image build, we need to do this later to avoid the theme
55 # flashing on the screen
56 if not self.service_item.is_image():
57 self.display.build_html(self.service_item)
58- if service_item.is_media():
59- self.on_media_start(service_item)
60+ if self.service_item.is_media():
61+ self.on_media_start(self.service_item)
62 self.slide_selected(True)
63- if service_item.from_service:
64+ if self.service_item.from_service:
65 self.preview_widget.setFocus()
66 if old_item:
67 # Close the old item after the new one is opened
68 # This avoids the service theme/desktop flashing on screen
69 # However opening a new item of the same type will automatically
70 # close the previous, so make sure we don't close the new one.
71- if old_item.is_command() and not service_item.is_command() or \
72- old_item.is_command() and not old_item.is_media() and service_item.is_media():
73+ if old_item.is_command() and not self.service_item.is_command() or \
74+ old_item.is_command() and not old_item.is_media() and self.service_item.is_media():
75 Registry().execute('%s_stop' % old_item.name.lower(), [old_item, self.is_live])
76- if old_item.is_media() and not service_item.is_media():
77+ if old_item.is_media() and not self.service_item.is_media():
78 self.on_media_close()
79- Registry().execute('slidecontroller_%s_started' % self.type_prefix, [service_item])
80+ Registry().execute('slidecontroller_%s_started' % self.type_prefix, [self.service_item])
81
82 def on_slide_selected_index(self, message):
83 """
84@@ -1138,8 +1138,9 @@
85 Creates an image of the current screen and updates the preview frame.
86 """
87 win_id = QtWidgets.QApplication.desktop().winId()
88+ screen = QtWidgets.QApplication.primaryScreen()
89 rect = self.screens.current['size']
90- win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
91+ win_image = screen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height())
92 win_image.setDevicePixelRatio(self.slide_preview.devicePixelRatio())
93 self.slide_preview.setPixmap(win_image)
94 self.slide_image = win_image
95
96=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
97--- openlp/plugins/presentations/lib/messagelistener.py 2015-12-31 22:46:06 +0000
98+++ openlp/plugins/presentations/lib/messagelistener.py 2016-01-14 20:22:09 +0000
99@@ -349,16 +349,17 @@
100 # When presenting PDF/XPS/OXPS, we are using the image presentation code,
101 # so handler & processor is set to None, and we skip adding the handler.
102 self.handler = None
103- if self.handler == self.media_item.automatic:
104- self.handler = self.media_item.find_controller_by_type(file)
105- if not self.handler:
106- return
107 else:
108- # the saved handler is not present so need to use one based on file suffix.
109- if not self.controllers[self.handler].available:
110+ if self.handler == self.media_item.automatic:
111 self.handler = self.media_item.find_controller_by_type(file)
112 if not self.handler:
113 return
114+ else:
115+ # the saved handler is not present so need to use one based on file suffix.
116+ if not self.controllers[self.handler].available:
117+ self.handler = self.media_item.find_controller_by_type(file)
118+ if not self.handler:
119+ return
120 if is_live:
121 controller = self.live_handler
122 else:
123
124=== modified file 'openlp/plugins/songs/forms/editsongform.py'
125--- openlp/plugins/songs/forms/editsongform.py 2016-01-10 16:01:43 +0000
126+++ openlp/plugins/songs/forms/editsongform.py 2016-01-14 20:22:09 +0000
127@@ -515,7 +515,7 @@
128 self.topics_list_view.addItem(topic_name)
129 self.songbooks_list_view.clear()
130 for songbook_entry in self.song.songbook_entries:
131- self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
132+ self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name,
133 songbook_entry.entry)
134 self.audio_list_widget.clear()
135 for media in self.song.media_files:
136
137=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
138--- openlp/plugins/songs/lib/mediaitem.py 2016-01-10 16:01:43 +0000
139+++ openlp/plugins/songs/lib/mediaitem.py 2016-01-14 20:22:09 +0000
140@@ -255,9 +255,9 @@
141 search_entry = re.sub(r'[^0-9]', '', search_keywords[2])
142
143 songbook_entries = (self.plugin.manager.session.query(SongBookEntry)
144- .join(Book)
145- .order_by(Book.name)
146- .order_by(SongBookEntry.entry))
147+ .join(Book)
148+ .order_by(Book.name)
149+ .order_by(SongBookEntry.entry))
150 for songbook_entry in songbook_entries:
151 if songbook_entry.song.temporary:
152 continue
153
154=== modified file 'tests/functional/openlp_core_lib/test_htmlbuilder.py'
155--- tests/functional/openlp_core_lib/test_htmlbuilder.py 2016-01-03 11:47:07 +0000
156+++ tests/functional/openlp_core_lib/test_htmlbuilder.py 2016-01-14 20:22:09 +0000
157@@ -363,9 +363,8 @@
158 """
159 Test the webkit_version() function
160 """
161- # GIVEN: Webkit
162+ # GIVEN: Webkit
163 webkit_ver = float(QtWebKit.qWebKitVersion())
164 # WHEN: Retrieving the webkit version
165 # THEN: Webkit versions should match
166 self.assertEquals(webkit_version(), webkit_ver, "The returned webkit version doesn't match the installed one")
167-
168
169=== modified file 'tests/functional/openlp_core_ui/test_mainwindow.py'
170--- tests/functional/openlp_core_ui/test_mainwindow.py 2016-01-09 19:10:56 +0000
171+++ tests/functional/openlp_core_ui/test_mainwindow.py 2016-01-14 20:22:09 +0000
172@@ -189,5 +189,3 @@
173 # THEN: The media manager dock is made visible
174 self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
175 mocked_widget.on_focus.assert_called_with()
176-
177-
178
179=== modified file 'tests/functional/openlp_plugins/presentations/test_messagelistener.py'
180--- tests/functional/openlp_plugins/presentations/test_messagelistener.py 2015-12-31 22:46:06 +0000
181+++ tests/functional/openlp_plugins/presentations/test_messagelistener.py 2016-01-14 20:22:09 +0000
182@@ -104,3 +104,23 @@
183
184 # THEN: The controllers will be setup.
185 self.assertTrue(len(controllers), 'We have loaded a controller')
186+
187+ @patch('openlp.plugins.presentations.lib.mediaitem.MessageListener._setup')
188+ def start_pdf_presentation_test(self, media_mock):
189+ """
190+ Test the startup of pdf presentation succeed.
191+ """
192+ # GIVEN: A sservice item with a pdf
193+ mock_item = MagicMock()
194+ mock_item.processor = 'Pdf'
195+ mock_item.get_frame_path.return_value = "test.pdf"
196+ self.media_item.generate_slide_data = MagicMock()
197+ ml = MessageListener(self.media_item)
198+ ml.media_item = self.media_item
199+ ml.preview_handler = MagicMock()
200+
201+ # WHEN: request the presentation to start
202+ ml.startup([mock_item, False, False, False])
203+
204+ # THEN: The handler should be set to None
205+ self.assertIsNone(ml.handler, 'The handler should be None')
206
207=== modified file 'tests/resources/projector/data.py'
208--- tests/resources/projector/data.py 2016-01-09 17:21:20 +0000
209+++ tests/resources/projector/data.py 2016-01-14 20:22:09 +0000
210@@ -59,4 +59,3 @@
211 name='___TEST_THREE___',
212 location='location three',
213 notes='notes three')
214-