From 5f513a9a1f325e757309437baf45e9ee85972b6d Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 22 Jan 2016 19:06:35 +0200 Subject: [PATCH 1/9] This simple fix should make blank to desktop, black and theme available during single screen mode --- openlp/core/ui/slidecontroller.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 37c4836b9..64b63083a 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -607,7 +607,10 @@ class SlideController(DisplayController, RegistryProperties): widget.addActions([ self.previous_item, self.next_item, self.previous_service, self.next_service, - self.escape_item]) + self.escape_item, + self.desktop_screen, + self.theme_screen, + self.blank_screen]) def preview_size_changed(self): """ From dee737e3fb38b38d96c99d88e2c5c4233c72fbcb Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 23 Jan 2016 17:28:16 +0200 Subject: [PATCH 2/9] Added proper comment --- openlp/core/ui/slidecontroller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 64b63083a..4a3b91b35 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -603,6 +603,9 @@ class SlideController(DisplayController, RegistryProperties): Add actions to the widget specified by `widget` :param widget: The UI widget for the actions + This defines the controls available when Live display has stolen focus. + Examples of this happening: Clicking anything in the live window or certain single screen mode scenarios. + Needles to say, blank to modes should not be removed from here. """ widget.addActions([ self.previous_item, self.next_item, From 7c43ae6b88d7395c18d0662e222e7858542c9b91 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sat, 20 Feb 2016 22:42:31 +0100 Subject: [PATCH 3/9] Another attempt to fully fix bug 1531319, Fixes: https://launchpad.net/bugs/1531319 --- openlp/core/ui/maindisplay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a4bfa4bc5..d9a9a6468 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -408,10 +408,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.application.process_events() # Workaround for bug #1531319, should not be needed with PyQt 5.6. if is_win(): - # Workaround for bug #1531319, should not be needed with PyQt 5.6. fade_shake_timer.stop() - elif is_win(): - self.shake_web_view() # Wait for the webview to update before getting the preview. # Important otherwise first preview will miss the background ! while not self.web_loaded: @@ -429,6 +426,9 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.setVisible(True) else: self.setVisible(True) + # Workaround for bug #1531319, should not be needed with PyQt 5.6. + if is_win(): + self.shake_web_view() return self.grab() def build_html(self, service_item, image_path=''): From 6ef2cc8b598eec2e54ed89f158e80d19321a602c Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 26 Feb 2016 23:28:01 +0200 Subject: [PATCH 4/9] Added test, fixed comment. --- openlp/core/ui/slidecontroller.py | 7 +++-- .../openlp_core_ui/test_slidecontroller.py | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 4a3b91b35..350e3fb59 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -601,11 +601,13 @@ class SlideController(DisplayController, RegistryProperties): def __add_actions_to_widget(self, widget): """ Add actions to the widget specified by `widget` - - :param widget: The UI widget for the actions This defines the controls available when Live display has stolen focus. Examples of this happening: Clicking anything in the live window or certain single screen mode scenarios. Needles to say, blank to modes should not be removed from here. + For some reason this required a test. It may be found in test_slidecontroller.py as + "live_stolen_focus_shortcuts_test. If you want to modify things here, you must also modify them there. (Duh) + + :param widget: The UI widget for the actions """ widget.addActions([ self.previous_item, self.next_item, @@ -983,6 +985,7 @@ class SlideController(DisplayController, RegistryProperties): self.update_preview() self.on_toggle_loop() + def on_theme_display(self, checked=None): """ Handle the Theme screen button diff --git a/tests/functional/openlp_core_ui/test_slidecontroller.py b/tests/functional/openlp_core_ui/test_slidecontroller.py index 7f071a835..af11c00bb 100644 --- a/tests/functional/openlp_core_ui/test_slidecontroller.py +++ b/tests/functional/openlp_core_ui/test_slidecontroller.py @@ -685,6 +685,33 @@ class TestSlideController(TestCase): self.assertEqual('mocked_presentation_item_stop', mocked_execute.call_args_list[1][0][0], 'The presentation should have been stopped.') + def live_stolen_focus_shortcuts_test(self): + """ + Test that all the needed shortcuts are available in scenarios where Live has stolen focus. + These are found under def __add_actions_to_widget(self, widget): in slidecontroller.py + """ + # GIVEN: A slide controller, actions needed + slide_controller = SlideController(None) + mocked_widget = MagicMock() + slide_controller.previous_item = MagicMock() + slide_controller.next_item = MagicMock() + slide_controller.previous_service = MagicMock() + slide_controller.next_service = MagicMock() + slide_controller.escape_item = MagicMock() + slide_controller.desktop_screen = MagicMock() + slide_controller.blank_screen = MagicMock() + slide_controller.theme_screen = MagicMock() + + # WHEN: __add_actions_to_widget is called + slide_controller._SlideController__add_actions_to_widget(mocked_widget) + + # THEN: The call to addActions should be correct + mocked_widget.addActions.assert_called_with([ + slide_controller.previous_item, slide_controller.next_item, + slide_controller.previous_service, slide_controller.next_service, + slide_controller.escape_item, slide_controller.desktop_screen, + slide_controller.theme_screen, slide_controller.blank_screen + ]) class TestInfoLabel(TestCase): From e3c4f53dc4948c06d6597853d9ccff7f87756346 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 27 Feb 2016 00:03:32 +0200 Subject: [PATCH 5/9] Seems like I added one empty row at some point... Removing it... --- openlp/core/ui/slidecontroller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 350e3fb59..45047c100 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -985,7 +985,6 @@ class SlideController(DisplayController, RegistryProperties): self.update_preview() self.on_toggle_loop() - def on_theme_display(self, checked=None): """ Handle the Theme screen button From e5485183314287a592ce0d62561ffcbfc7df0349 Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Sat, 27 Feb 2016 16:25:31 +0200 Subject: [PATCH 6/9] Added 2nd empty row after last test in class. --- tests/functional/openlp_core_ui/test_slidecontroller.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/openlp_core_ui/test_slidecontroller.py b/tests/functional/openlp_core_ui/test_slidecontroller.py index af11c00bb..20e48cbe0 100644 --- a/tests/functional/openlp_core_ui/test_slidecontroller.py +++ b/tests/functional/openlp_core_ui/test_slidecontroller.py @@ -713,6 +713,7 @@ class TestSlideController(TestCase): slide_controller.theme_screen, slide_controller.blank_screen ]) + class TestInfoLabel(TestCase): def paint_event_text_fits_test(self): From 9774618d377f0f9af8bc94635c947672677b9a69 Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sun, 28 Feb 2016 02:26:38 -0800 Subject: [PATCH 7/9] Bugfix 1550891 - non-standard class reply from projector --- openlp/core/lib/projector/pjlink1.py | 10 +++++++++- .../openlp_core_lib/test_projector_pjlink1.py | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 5feda33f4..3a99dd7da 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -665,7 +665,15 @@ class PJLink1(QTcpSocket): :param data: Class that projector supports. """ - self.pjlink_class = data + # bug 1550891: Projector returns non-standard class response: + # : Expected: %1CLSS=1 + # : Received: %1CLSS=Class 1 + if len(data) > 1: + # Split non-standard information from response + clss = data.split()[-1] + else: + clss = data + self.pjlink_class = clss log.debug('(%s) Setting pjlink_class for this projector to "%s"' % (self.ip, self.pjlink_class)) return diff --git a/tests/functional/openlp_core_lib/test_projector_pjlink1.py b/tests/functional/openlp_core_lib/test_projector_pjlink1.py index 92ce02acd..067818957 100644 --- a/tests/functional/openlp_core_lib/test_projector_pjlink1.py +++ b/tests/functional/openlp_core_lib/test_projector_pjlink1.py @@ -60,3 +60,17 @@ class TestPJLink(TestCase): "Connection request should have been called with TEST_SALT")) self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN, "Connection request should have been called with TEST_PIN")) + + def non_standard_class_reply_test(self): + """ + bugfix 1550891 - CLSS request returns non-standard 'Class N' reply + """ + # GIVEN: Test object + pjlink = pjlink_test + + # WHEN: Process non-standard reply + pjlink.process_clss('Class 1') + + # THEN: Projector class should be set with proper value + self.assertEquals(pjlink.pjlink_class, '1', + 'Non-standard class reply should have set proper class') From 7c23941f359f1a6a6ca49019a639ddd54f8c0533 Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sun, 28 Feb 2016 04:35:15 -0800 Subject: [PATCH 8/9] Fix sending unicode string when expecting ascii (binary) data --- openlp/core/lib/projector/pjlink1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 3a99dd7da..c5c765d62 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -515,7 +515,7 @@ class PJLink1(QTcpSocket): self.socket_timer.start() try: self.projectorNetwork.emit(S_NETWORK_SENDING) - sent = self.write(out) + sent = self.write(out.encode('ascii')) self.waitForBytesWritten(2000) # 2 seconds should be enough if sent == -1: # Network error? From 5809a2d6f47ba1ece04c41f710d42f23a36f0bd8 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 29 Feb 2016 20:29:32 +0100 Subject: [PATCH 9/9] Added test --- .../openlp_plugins/songusage/test_songusage.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/openlp_plugins/songusage/test_songusage.py b/tests/functional/openlp_plugins/songusage/test_songusage.py index 6b103c9f1..61d8a22bb 100644 --- a/tests/functional/openlp_plugins/songusage/test_songusage.py +++ b/tests/functional/openlp_plugins/songusage/test_songusage.py @@ -81,3 +81,19 @@ class TestSongUsage(TestCase): # THEN: It should return True self.assertTrue(ret) + + @patch('openlp.plugins.songusage.songusageplugin.Manager') + def toggle_song_usage_state_test(self, MockedManager): + """ + Test that toggle_song_usage_state does toggle song_usage_state + """ + # GIVEN: A SongUsagePlugin + song_usage = SongUsagePlugin() + song_usage.set_button_state = MagicMock() + song_usage.song_usage_active = True + + # WHEN: calling toggle_song_usage_state + song_usage.toggle_song_usage_state() + + # THEN: song_usage_state should have been toogled + self.assertFalse(song_usage.song_usage_active)