← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank into lp:openlp

 

Azaziah has proposed merging lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Raoul Snyman (raoul-snyman)
  Tomas Groth (tomasgroth)
Related bugs:
  Bug #1462420 in OpenLP: "Double click on the preview duplicated the element in the service manger"
  https://bugs.launchpad.net/openlp/+bug/1462420
  Bug #1531691 in OpenLP: "Song is sent back to live after edit if blanked"
  https://bugs.launchpad.net/openlp/+bug/1531691

For more details, see:
https://code.launchpad.net/~suutari-olli/openlp/click-slide-to-go-live-from-blank/+merge/300276

This branch introduces the functionality of unblanking
display from Blank to Black/Theme/Desktop for:

a) Clicking slide in "Live panel"
b) Next/Previous shortcuts (Green arrows)
c) Go to verse x.
d) When starting automatic playback (To end or Loop)
Also added "Unblank display when changing slide in Live" to advanced
options tab for disabling/enabling this behavior for a-c.

Additionally this branch also includes fix for bug
https://bugs.launchpad.net/openlp/+bug/1531691
Do note that this branch does not fix this for Escape item blanking,
creating yet an another Escape exclusive bug.

-----------------------------------------------------------------------------
The only reason Escape item has been a good alternative for other
blank to methods is the functionality of resuming Live by clicking
slides and the fact it worked in single screen scenarios.
I can’t see any reason why it should not be removed after this branch
is merged since the single screen issue was already fixed earlier.

-----------------------------------------------------------------------------
Added 3 tests for checking display is re-blanked if it was
blanked before re-processing edited Live item.
Also fixed the issue where Next/Previous slide does not
unblank display for PowerPoint/Impress.

-----------------------------------------------------------------------------
Better fix for bug where display is unblanked on editing current live item.
This now sets a hidden setting to true while processing Live item and then changes it back to false.
Display is thus not unblanked at all during the process. (Old fix showed the edited slide for a small time)

Downside: All the new tests were based on the old
method and thus they were removed.

Fixed bug 1462420 (Double clicking preview adds items to service unlimited times)
- Added a hidden setting for controlling this behavior.
  It is reset if any item is sent to preview from library.
- Sending the same item to service multiple times is still
  possible by using the "Add button (icon)"
-----------------------------------------------------------------------------
- Added two tests for checking if doubleclicking preview should
  add item to service or send it to live.
-----------------------------------------------------------------------------

lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank (revision 2661)
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-01-Pull/1653/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-02-Functional-Tests/1564/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-03-Interface-Tests/1502/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1268/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/858/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05a-Code_Analysis/926/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05b-Test_Coverage/794/
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/common/settings.py'
--- openlp/core/common/settings.py	2016-05-18 18:40:27 +0000
+++ openlp/core/common/settings.py	2016-07-17 16:16:57 +0000
@@ -141,6 +141,7 @@
         'core/auto preview': False,
         'core/audio start paused': True,
         'core/auto unblank': False,
+        'core/click live slide to unblank': False,
         'core/blank warning': False,
         'core/ccli number': '',
         'core/has run wizard': False,

=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2016-05-17 13:15:53 +0000
+++ openlp/core/lib/mediamanageritem.py	2016-07-17 16:16:57 +0000
@@ -488,6 +488,7 @@
                                                         'You must select one or more items to preview.'))
         else:
             log.debug('%s Preview requested' % self.plugin.name)
+            Registry().set_flag('has doubleclick added item to service', False)
             service_item = self.build_service_item()
             if service_item:
                 service_item.from_plugin = True

=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py	2016-05-20 16:22:06 +0000
+++ openlp/core/ui/generaltab.py	2016-07-17 16:16:57 +0000
@@ -209,6 +209,9 @@
         self.auto_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
         self.auto_unblank_check_box.setObjectName('auto_unblank_check_box')
         self.settings_layout.addRow(self.auto_unblank_check_box)
+        self.click_live_slide_to_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
+        self.click_live_slide_to_unblank_check_box.setObjectName('click_live_slide_to_unblank')
+        self.settings_layout.addRow(self.click_live_slide_to_unblank_check_box)
         self.auto_preview_check_box = QtWidgets.QCheckBox(self.settings_group_box)
         self.auto_preview_check_box.setObjectName('auto_preview_check_box')
         self.settings_layout.addRow(self.auto_preview_check_box)
@@ -259,6 +262,8 @@
         self.save_check_service_check_box.setText(translate('OpenLP.GeneralTab',
                                                   'Prompt to save before starting a new service'))
         self.auto_unblank_check_box.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item'))
+        self.click_live_slide_to_unblank_check_box.setText(translate('OpenLP.GeneralTab',
+                                                           'Unblank display when changing slide in Live'))
         self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab',
                                                       'Automatically preview next item in service'))
         self.timeout_label.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:'))
@@ -292,6 +297,7 @@
         self.password_edit.setText(settings.value('songselect password'))
         self.save_check_service_check_box.setChecked(settings.value('save prompt'))
         self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
+        self.click_live_slide_to_unblank_check_box.setChecked(settings.value('click live slide to unblank'))
         self.display_on_monitor_check.setChecked(self.screens.display)
         self.warning_check_box.setChecked(settings.value('blank warning'))
         self.auto_open_check_box.setChecked(settings.value('auto open'))
@@ -336,6 +342,7 @@
         settings.setValue('update check', self.check_for_updates_check_box.isChecked())
         settings.setValue('save prompt', self.save_check_service_check_box.isChecked())
         settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked())
+        settings.setValue('click live slide to unblank', self.click_live_slide_to_unblank_check_box.isChecked())
         settings.setValue('auto preview', self.auto_preview_check_box.isChecked())
         settings.setValue('loop delay', self.timeout_spin_box.value())
         settings.setValue('ccli number', self.number_edit.displayText())

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2016-05-20 16:22:06 +0000
+++ openlp/core/ui/slidecontroller.py	2016-07-17 16:16:57 +0000
@@ -88,6 +88,8 @@
         self.is_live = False
         self.display = None
         self.controller_type = None
+        Registry().set_flag('has doubleclick added item to service', True)
+        Registry().set_flag('replace service manager item', False)
 
     def send_to_plugins(self, *args):
         """
@@ -797,12 +799,15 @@
 
     def replace_service_manager_item(self, item):
         """
-        Replacement item following a remote edit
+        Replacement item following a remote edit.
+        This action  also takes place when a song that is sent to live from Service Manager is edited.
 
         :param item: The current service item
         """
         if item == self.service_item:
+            Registry().set_flag('replace service manager item', True)
             self._process_item(item, self.preview_widget.current_slide_number())
+            Registry().set_flag('replace service manager item', False)
 
     def add_service_manager_item(self, item, slide_no):
         """
@@ -971,9 +976,10 @@
 
     def on_slide_unblank(self):
         """
-        Handle the slidecontroller unblank event
+        Handle the slidecontroller unblank event.
         """
-        self.on_blank_display(False)
+        if not Registry().get_flag('replace service manager item') is True:
+            self.on_blank_display(False)
 
     def on_blank_display(self, checked=None):
         """
@@ -1104,6 +1110,11 @@
                 self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.'
                                % timeout)
             return
+        # If "click live slide to unblank" is enabled, unblank the display. And start = Item is sent to Live.
+        # Note: If this if statement is placed at the bottom of this function instead of top slide transitions are lost.
+        if self.is_live and Settings().value('core/click live slide to unblank'):
+            if not start:
+                Registry().execute('slidecontroller_live_unblank')
         row = self.preview_widget.current_slide_number()
         old_selected_row = self.selected_row
         self.selected_row = 0
@@ -1286,6 +1297,8 @@
             self.play_slides_once.setText(UiStrings().PlaySlidesToEnd)
             self.play_slides_menu.setDefaultAction(self.play_slides_loop)
             self.play_slides_once.setChecked(False)
+            if Settings().value('core/click live slide to unblank'):
+                Registry().execute('slidecontroller_live_unblank')
         else:
             self.play_slides_loop.setIcon(build_icon(':/media/media_time.png'))
             self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
@@ -1309,6 +1322,8 @@
             self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
             self.play_slides_menu.setDefaultAction(self.play_slides_once)
             self.play_slides_loop.setChecked(False)
+            if Settings().value('core/click live slide to unblank'):
+                Registry().execute('slidecontroller_live_unblank')
         else:
             self.play_slides_once.setIcon(build_icon(':/media/media_time'))
             self.play_slides_once.setText(UiStrings().PlaySlidesToEnd)
@@ -1363,7 +1378,7 @@
         Triggered when a preview slide item is doubleclicked
         """
         if self.service_item:
-            if Settings().value('advanced/double click live'):
+            if Settings().value('advanced/double click live') and Settings().value('core/auto unblank'):
                 # Live and Preview have issues if we have video or presentations
                 # playing in both at the same time.
                 if self.service_item.is_command():
@@ -1372,8 +1387,13 @@
                 if self.service_item.is_media():
                     self.on_media_close()
                 self.on_go_live()
-            else:
+            # If ('advanced/double click live') is not enabled, double clicking preview adds the item to Service.
+            # Prevent same item in preview from being sent to Service multiple times.
+            # Changing the preview slide resets this flag to False.
+            # Do note that this still allows to add item to Service multiple times if icon is clicked.
+            elif not Registry().get_flag('has doubleclick added item to service') is True:
                 self.on_preview_add_to_service()
+                Registry().set_flag('has doubleclick added item to service', True)
 
     def on_go_live(self, field=None):
         """

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2016-05-21 18:19:18 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2016-07-17 16:16:57 +0000
@@ -26,7 +26,7 @@
 
 from PyQt5 import QtCore
 
-from openlp.core.common import Registry
+from openlp.core.common import Registry, Settings
 from openlp.core.ui import HideMode
 from openlp.core.lib import ServiceItemContext, ServiceItem
 from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
@@ -419,6 +419,8 @@
         is_live = message[1]
         if is_live:
             self.live_handler.next()
+            if Settings().value('core/click live slide to unblank'):
+                Registry().execute('slidecontroller_live_unblank')
         else:
             self.preview_handler.next()
 
@@ -431,6 +433,8 @@
         is_live = message[1]
         if is_live:
             self.live_handler.previous()
+            if Settings().value('core/click live slide to unblank'):
+                Registry().execute('slidecontroller_live_unblank')
         else:
             self.preview_handler.previous()
 

=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
--- tests/functional/openlp_core_ui/test_slidecontroller.py	2016-06-01 21:42:54 +0000
+++ tests/functional/openlp_core_ui/test_slidecontroller.py	2016-07-17 16:16:57 +0000
@@ -713,6 +713,52 @@
             slide_controller.theme_screen, slide_controller.blank_screen
         ])
 
+    @patch('openlp.core.ui.slidecontroller.Settings')
+    def on_preview_double_click_unblank_display_test(self, MockedSettings):
+        # GIVEN: A slide controller, actions needed, settins set to True.
+        slide_controller = SlideController(None)
+        mocked_settings = MagicMock()
+        mocked_settings.return_value = True
+        MockedSettings.return_value = mocked_settings
+        slide_controller.service_item = MagicMock()
+        slide_controller.service_item.is_media = MagicMock()
+        slide_controller.on_media_close = MagicMock()
+        slide_controller.on_go_live = MagicMock()
+        slide_controller.on_preview_add_to_service = MagicMock()
+        slide_controller.media_reset = MagicMock()
+        Registry.create()
+        Registry().set_flag('has doubleclick added item to service', True)
+
+        # WHEN: on_preview_double_click is called
+        slide_controller.on_preview_double_click()
+
+        # THEN: The call to addActions should be correct
+        self.assertEqual(1, slide_controller.on_go_live.call_count, 'on_go_live should have been called once.')
+        self.assertEqual(0, slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.')
+
+    @patch('openlp.core.ui.slidecontroller.Settings')
+    def on_preview_double_click_add_to_service_test(self, MockedSettings):
+        # GIVEN: A slide controller, actions needed, settins set to False.
+        slide_controller = SlideController(None)
+        mocked_settings = MagicMock()
+        mocked_settings.value.return_value = False
+        MockedSettings.return_value = mocked_settings
+        slide_controller.service_item = MagicMock()
+        slide_controller.service_item.is_media = MagicMock()
+        slide_controller.on_media_close = MagicMock()
+        slide_controller.on_go_live = MagicMock()
+        slide_controller.on_preview_add_to_service = MagicMock()
+        slide_controller.media_reset = MagicMock()
+        Registry.create()
+        Registry().set_flag('has doubleclick added item to service', False)
+
+        # WHEN: on_preview_double_click is called
+        slide_controller.on_preview_double_click()
+
+        # THEN: The call to addActions should be correct
+        self.assertEqual(0, slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.')
+        self.assertEqual(1, slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.')
+
     @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
     @patch(u'PyQt5.QtCore.QTimer.singleShot')
     def test_update_preview_live(self, mocked_singleShot, mocked_image_manager):


Follow ups