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

Proposed by Azaziah
Status: Superseded
Proposed branch: lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank
Merge into: lp:openlp
Diff against target: 256 lines (+94/-6)
6 files modified
openlp/core/common/settings.py (+1/-0)
openlp/core/lib/mediamanageritem.py (+2/-0)
openlp/core/ui/generaltab.py (+7/-0)
openlp/core/ui/slidecontroller.py (+32/-5)
openlp/plugins/presentations/lib/messagelistener.py (+5/-1)
tests/functional/openlp_core_ui/test_slidecontroller.py (+47/-0)
To merge this branch: bzr merge lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Information
Tomas Groth Pending
Tim Bentley Pending
Review via email: mp+293173@code.launchpad.net

This proposal supersedes a proposal from 2016-04-20.

This proposal has been superseded by a proposal from 2016-07-15.

Description of the change

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.
-----------------------------------------------------------------------------
In this re-proposal:

Added this to program startup code,
should replace_service_manager_item ever crash the program:

Settings().setValue('core/is live item edited and replaced', False)

--------------------------------
lp:~suutari-olli/openlp/click-slide-to-go-live-from-blank (revision 2648)
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-01-Pull/1504/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-02-Functional-Tests/1415/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-03-Interface-Tests/1353/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1149/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/740/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05a-Code_Analysis/807/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05b-Test_Coverage/675/

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

Just tested a bit.
You have introduced the "Click live slide to unblank" setting, but a "Unblank display when adding new item" also exists in the general tab. You should probably move yours to be under the exiting one to keep similar settings in the same place. Currently your code doesn't honor the "Unblank display when adding new item", which it will have to do. As it is now the item goes live no matter if the setting is enabled or not.
Also the new setting should be "false" as default, this is new behavior, so users should enabled it if they want it.
Also added a code-comment below.

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

Hi Tomas and thank you for your comments!

"Unblank display when adding new item" also exists in the general tab. You should probably move yours to be under the exiting one to keep similar settings in the same place. Currently your code doesn't honor the "Unblank display when adding new item

# Done and Done, now also honoring double clicking preview

Also the new setting should be "false" as default, this is new behavior, so users should enabled it if they want it.

# Done
# Currently this is default behavior for Escape item and probably easier
to use than our current blank to modes. I think this and some other settings
should eventually be changed to be more user friendly by default.

Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

Looks good now. As you mention in one of your source-comments the previous slide is shortly visible when display is unblanked. Don't know if it can be helped.
Added a comment to the code below.
Besides that, you need tests :)

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

Thanks again,

if by previous slide being shortly visible you mean it happens once you change slide inside the Live Panel
and the transition effect is applied, yes that can be changed. I've heard people complaining there's no transition effects when unblanking or changing items so maybe it should be left as it is since it would mean loosing effects.

If you were talking about this happening on song edit:
Think it would be possible but would require quite a effort,
maybe we can let it pass for the time being, it's still mostly fixed.

I really suck at writing tests, is one enough for a rookie?

I also replied to the code comment.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Looks good to me. Nice tests.

review: Approve
Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Couple of tests and some tests are needed.

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

I need to start working on tests...

Fixed the diff comments.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Check my comment. I'll try to look at this more in-depth over the weekend and give you more feedback.

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

> Check my comment. I'll try to look at this more in-depth over the weekend and
> give you more feedback.

Thank you for checking this out, I've replied to your comment.

I'm away from my coding station until next week, so no new commits
(if required) will be made until then.

I wish you all the best for your day.

Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

I noticed the comment was not saved, so here it is. ^^ Sorry about that :/

Revision history for this message
Azaziah (suutari-olli) wrote : Posted in a previous version of this proposal

I commented on replace live item function and resetting the setting.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I still do not agree with using settings for temporary flags. Find another way.

review: Needs Fixing
Revision history for this message
Azaziah (suutari-olli) wrote :

"I still do not agree with using settings for temporary flags. Find another way."

Well I can't think of an other way.

I tried to fix: https://bugs.launchpad.net/openlp/+bug/1531691 without settings,
but it didn't work properly and was way more complex.

Since we need to trigger actions in many files/functions based on temporary flags,
what would be a proper solution without the use of settings?

Also replied to diff comments.

Thank you for your review.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I've just merged the flags section of the Registry object.

Having said that, and looking at your branch, I'm not entirely convinced this is the way to go about this. While you can explain to me what the difference is between this and the other auto-unblank setting, you can't explain it to our users, and I refuse to be lumped with the problem (I'm about the only person who actually actively deals with our users).

I recommend rather merging this with the current "auto-unblank" setting and make a single setting with a set of modes instead.

review: Needs Information
Revision history for this message
Azaziah (suutari-olli) wrote :

> I've just merged the flags section of the Registry object.
>
> Having said that, and looking at your branch, I'm not entirely convinced this
> is the way to go about this. While you can explain to me what the difference
> is between this and the other auto-unblank setting, you can't explain it to
> our users, and I refuse to be lumped with the problem (I'm about the only
> person who actually actively deals with our users).
>
> I recommend rather merging this with the current "auto-unblank" setting and
> make a single setting with a set of modes instead.

I'll be looking forward to moving the flags to registry.

This branch adds the unblanking of display by clicking slides in Live.

Currently this is possible when using Escape item, but not while using the real blank to modes.
The current behavior is highly confusing.
This setting will make things more understandable and easier to manage.

So ultimately this just makes it possible for users to easily resume Live presentation by clicking a slide they wish to show.

It's not related to sending items to Live, It's more about unblanking display and resuming the projection of the current Live item. Thus they are a very different thing.

After this is merged, I think we should begin working on removing the Escape item,
It's very much a broken and confusing format.

I am sorry about the current user support situation, hope things will be better someday.
Ultimately it would be great if the customer support would be something you wouldn't have to do.

2649. By Azaziah

merged trunk on 14.6.16

2650. By Azaziah

- Turned the two new hidden settings into registry flags

2651. By Azaziah

Comment cleanup / Improvements

2652. By Azaziah

- Merged trunk on 27.6.16

2653. By Azaziah

- Tried to make the new text work with the registry changes but failed.
 > Test is broken, do not merge!

2654. By Azaziah

Merged trunk on 14.7.16

2655. By Azaziah

pep8 fixes, test still broken.

2656. By Azaziah

Fixed the tests.

2657. By Azaziah

- Reduced comments
- Removed unrequired reg_value from test.

2658. By Azaziah

- Fixed the issue where items sent to Preview from Service may cause tracebacks.

2659. By Azaziah

- Moved the 2nd new registry flag from one init to an another init which also has the 1st

2660. By Azaziah

- Moved them to another init since something broke

2661. By Azaziah

- removed one unrequired if statement.

2662. By Azaziah

- Merged trunk on 31.7.16

2663. By Azaziah

- Merged trunk on 10/8/16.

2664. By Azaziah

- Merged trunk and resolved conflict that was created by ui-messages-part-1 branch.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/settings.py'
2--- openlp/core/common/settings.py 2016-05-18 18:40:27 +0000
3+++ openlp/core/common/settings.py 2016-07-14 18:14:22 +0000
4@@ -141,6 +141,7 @@
5 'core/auto preview': False,
6 'core/audio start paused': True,
7 'core/auto unblank': False,
8+ 'core/click live slide to unblank': False,
9 'core/blank warning': False,
10 'core/ccli number': '',
11 'core/has run wizard': False,
12
13=== modified file 'openlp/core/lib/mediamanageritem.py'
14--- openlp/core/lib/mediamanageritem.py 2016-05-17 13:15:53 +0000
15+++ openlp/core/lib/mediamanageritem.py 2016-07-14 18:14:22 +0000
16@@ -488,6 +488,8 @@
17 'You must select one or more items to preview.'))
18 else:
19 log.debug('%s Preview requested' % self.plugin.name)
20+ # Reset the flag for: "has doubleclick added item to service" to False.
21+ Registry().set_flag('has doubleclick added item to service', False)
22 service_item = self.build_service_item()
23 if service_item:
24 service_item.from_plugin = True
25
26=== modified file 'openlp/core/ui/generaltab.py'
27--- openlp/core/ui/generaltab.py 2016-05-20 16:22:06 +0000
28+++ openlp/core/ui/generaltab.py 2016-07-14 18:14:22 +0000
29@@ -209,6 +209,9 @@
30 self.auto_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
31 self.auto_unblank_check_box.setObjectName('auto_unblank_check_box')
32 self.settings_layout.addRow(self.auto_unblank_check_box)
33+ self.click_live_slide_to_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box)
34+ self.click_live_slide_to_unblank_check_box.setObjectName('click_live_slide_to_unblank')
35+ self.settings_layout.addRow(self.click_live_slide_to_unblank_check_box)
36 self.auto_preview_check_box = QtWidgets.QCheckBox(self.settings_group_box)
37 self.auto_preview_check_box.setObjectName('auto_preview_check_box')
38 self.settings_layout.addRow(self.auto_preview_check_box)
39@@ -259,6 +262,8 @@
40 self.save_check_service_check_box.setText(translate('OpenLP.GeneralTab',
41 'Prompt to save before starting a new service'))
42 self.auto_unblank_check_box.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item'))
43+ self.click_live_slide_to_unblank_check_box.setText(translate('OpenLP.GeneralTab',
44+ 'Unblank display when changing slide in Live'))
45 self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab',
46 'Automatically preview next item in service'))
47 self.timeout_label.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:'))
48@@ -292,6 +297,7 @@
49 self.password_edit.setText(settings.value('songselect password'))
50 self.save_check_service_check_box.setChecked(settings.value('save prompt'))
51 self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
52+ self.click_live_slide_to_unblank_check_box.setChecked(settings.value('click live slide to unblank'))
53 self.display_on_monitor_check.setChecked(self.screens.display)
54 self.warning_check_box.setChecked(settings.value('blank warning'))
55 self.auto_open_check_box.setChecked(settings.value('auto open'))
56@@ -336,6 +342,7 @@
57 settings.setValue('update check', self.check_for_updates_check_box.isChecked())
58 settings.setValue('save prompt', self.save_check_service_check_box.isChecked())
59 settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked())
60+ settings.setValue('click live slide to unblank', self.click_live_slide_to_unblank_check_box.isChecked())
61 settings.setValue('auto preview', self.auto_preview_check_box.isChecked())
62 settings.setValue('loop delay', self.timeout_spin_box.value())
63 settings.setValue('ccli number', self.number_edit.displayText())
64
65=== modified file 'openlp/core/ui/slidecontroller.py'
66--- openlp/core/ui/slidecontroller.py 2016-05-20 16:22:06 +0000
67+++ openlp/core/ui/slidecontroller.py 2016-07-14 18:14:22 +0000
68@@ -139,6 +139,7 @@
69 Set up the Slide Controller.
70 """
71 super(SlideController, self).__init__(parent)
72+ Registry().set_flag('replace service manager item', False)
73
74 def post_set_up(self):
75 """
76@@ -797,12 +798,18 @@
77
78 def replace_service_manager_item(self, item):
79 """
80- Replacement item following a remote edit
81+ Replacement item following a remote edit.
82+ This action also takes place when a song that is sent to live from Service Manager is edited.
83+ If display is blanked, it will get unblanked if automatic unblanking is enabled. We prevent this from happening
84+ by setting a flag to "True" and then to "False" after the processing is done.
85+ The flag is also set to "False" on startup so display may be unblanked properly.
86
87 :param item: The current service item
88 """
89 if item == self.service_item:
90+ Registry().set_flag('replace service manager item', True)
91 self._process_item(item, self.preview_widget.current_slide_number())
92+ Registry().set_flag('replace service manager item', False)
93
94 def add_service_manager_item(self, item, slide_no):
95 """
96@@ -971,9 +978,12 @@
97
98 def on_slide_unblank(self):
99 """
100- Handle the slidecontroller unblank event
101+ Handle the slidecontroller unblank event.
102+ If we are re-processing service item, don't unblank the display
103+ (Found in def replace_service_manager_item)
104 """
105- self.on_blank_display(False)
106+ if not Registry().get_flag('replace service manager item') is True:
107+ self.on_blank_display(False)
108
109 def on_blank_display(self, checked=None):
110 """
111@@ -1104,6 +1114,14 @@
112 self.log_debug('Could not get lock in slide_selected after waiting %f, skip to avoid deadlock.'
113 % timeout)
114 return
115+ # If "click live slide to unblank" is enabled, unblank the display. And start = Item is sent to Live.
116+ # Note: If this if statement is placed at the bottom of this function instead of top slide transitions are lost.
117+ if self.is_live and Settings().value('core/click live slide to unblank'):
118+ # With this display stays blanked when "auto unblank" setting is not enabled and new item is sent to Live.
119+ if not Settings().value('core/auto unblank') and start:
120+ ()
121+ if not start:
122+ Registry().execute('slidecontroller_live_unblank')
123 row = self.preview_widget.current_slide_number()
124 old_selected_row = self.selected_row
125 self.selected_row = 0
126@@ -1286,6 +1304,8 @@
127 self.play_slides_once.setText(UiStrings().PlaySlidesToEnd)
128 self.play_slides_menu.setDefaultAction(self.play_slides_loop)
129 self.play_slides_once.setChecked(False)
130+ if Settings().value('core/click live slide to unblank'):
131+ Registry().execute('slidecontroller_live_unblank')
132 else:
133 self.play_slides_loop.setIcon(build_icon(':/media/media_time.png'))
134 self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
135@@ -1309,6 +1329,8 @@
136 self.play_slides_loop.setText(UiStrings().PlaySlidesInLoop)
137 self.play_slides_menu.setDefaultAction(self.play_slides_once)
138 self.play_slides_loop.setChecked(False)
139+ if Settings().value('core/click live slide to unblank'):
140+ Registry().execute('slidecontroller_live_unblank')
141 else:
142 self.play_slides_once.setIcon(build_icon(':/media/media_time'))
143 self.play_slides_once.setText(UiStrings().PlaySlidesToEnd)
144@@ -1363,7 +1385,7 @@
145 Triggered when a preview slide item is doubleclicked
146 """
147 if self.service_item:
148- if Settings().value('advanced/double click live'):
149+ if Settings().value('advanced/double click live') and Settings().value('core/auto unblank'):
150 # Live and Preview have issues if we have video or presentations
151 # playing in both at the same time.
152 if self.service_item.is_command():
153@@ -1372,8 +1394,13 @@
154 if self.service_item.is_media():
155 self.on_media_close()
156 self.on_go_live()
157- else:
158+ # If ('advanced/double click live') is not enabled, double clicking preview adds the item to Service.
159+ # Prevent same item in preview from being sent to Service multiple times.
160+ # Changing the preview slide resets this flag to False.
161+ # Do note that this still allows to add item to Service multiple times if icon is clicked.
162+ elif not Registry().get_flag('has doubleclick added item to service') is True:
163 self.on_preview_add_to_service()
164+ Registry().set_flag('has doubleclick added item to service', True)
165
166 def on_go_live(self, field=None):
167 """
168
169=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
170--- openlp/plugins/presentations/lib/messagelistener.py 2016-05-21 18:19:18 +0000
171+++ openlp/plugins/presentations/lib/messagelistener.py 2016-07-14 18:14:22 +0000
172@@ -26,7 +26,7 @@
173
174 from PyQt5 import QtCore
175
176-from openlp.core.common import Registry
177+from openlp.core.common import Registry, Settings
178 from openlp.core.ui import HideMode
179 from openlp.core.lib import ServiceItemContext, ServiceItem
180 from openlp.plugins.presentations.lib.pdfcontroller import PDF_CONTROLLER_FILETYPES
181@@ -419,6 +419,8 @@
182 is_live = message[1]
183 if is_live:
184 self.live_handler.next()
185+ if Settings().value('core/click live slide to unblank'):
186+ Registry().execute('slidecontroller_live_unblank')
187 else:
188 self.preview_handler.next()
189
190@@ -431,6 +433,8 @@
191 is_live = message[1]
192 if is_live:
193 self.live_handler.previous()
194+ if Settings().value('core/click live slide to unblank'):
195+ Registry().execute('slidecontroller_live_unblank')
196 else:
197 self.preview_handler.previous()
198
199
200=== modified file 'tests/functional/openlp_core_ui/test_slidecontroller.py'
201--- tests/functional/openlp_core_ui/test_slidecontroller.py 2016-06-01 21:42:54 +0000
202+++ tests/functional/openlp_core_ui/test_slidecontroller.py 2016-07-14 18:14:22 +0000
203@@ -713,6 +713,53 @@
204 slide_controller.theme_screen, slide_controller.blank_screen
205 ])
206
207+ @patch('openlp.core.ui.slidecontroller.Settings')
208+ def on_preview_double_click_unblank_display_test(self, MockedSettings):
209+ # GIVEN: A slide controller, actions needed, settins set to True.
210+ slide_controller = SlideController(None)
211+ mocked_settings = MagicMock()
212+ mocked_settings.return_value = True
213+ MockedSettings.return_value = mocked_settings
214+ slide_controller.service_item = MagicMock()
215+ slide_controller.service_item.is_media = MagicMock()
216+ slide_controller.on_media_close = MagicMock()
217+ slide_controller.on_go_live = MagicMock()
218+ slide_controller.on_preview_add_to_service = MagicMock()
219+ slide_controller.media_reset = MagicMock()
220+
221+ Registry.create()
222+ reg_value = True
223+ Registry().set_flag('has doubleclick added item to service', reg_value)
224+ temp = Registry().get_flag('has doubleclick added item to service')
225+
226+ # WHEN: on_preview_double_click is called
227+ slide_controller.on_preview_double_click()
228+
229+ # THEN: The call to addActions should be correct
230+ self.assertEqual(1, slide_controller.on_go_live.call_count, 'on_go_live should have been called once.')
231+ self.assertEqual(0, slide_controller.on_preview_add_to_service.call_count, 'Should have not been called.')
232+
233+ @patch('openlp.core.ui.slidecontroller.Settings')
234+ def on_preview_double_click_add_to_service_test(self, MockedSettings):
235+ # GIVEN: A slide controller, actions needed, settins set to False.
236+ slide_controller = SlideController(None)
237+ mocked_settings = MagicMock()
238+ mocked_settings.value.return_value = False
239+ MockedSettings.return_value = mocked_settings
240+ slide_controller.service_item = MagicMock()
241+ slide_controller.service_item.is_media = MagicMock()
242+ slide_controller.on_media_close = MagicMock()
243+ slide_controller.on_go_live = MagicMock()
244+ slide_controller.on_preview_add_to_service = MagicMock()
245+ slide_controller.media_reset = MagicMock()
246+
247+ # WHEN: on_preview_double_click is called
248+ slide_controller.on_preview_double_click()
249+
250+ # THEN: The call to addActions should be correct
251+ self.assertEqual(0, slide_controller.on_go_live.call_count, 'on_go_live Should have not been called.')
252+ self.assertEqual(1, slide_controller.on_preview_add_to_service.call_count, 'Should have been called once.')
253+
254 @patch(u'openlp.core.ui.slidecontroller.SlideController.image_manager')
255 @patch(u'PyQt5.QtCore.QTimer.singleShot')
256 def test_update_preview_live(self, mocked_singleShot, mocked_image_manager):