forked from openlp/openlp
Merge branch 'display-mode-toggle' into 'master'
Display mode toggle Closes #905 See merge request openlp/openlp!348
This commit is contained in:
commit
54ad7496cd
@ -279,6 +279,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
self.slide_changed_time = datetime.datetime.now()
|
self.slide_changed_time = datetime.datetime.now()
|
||||||
self.fetching_screenshot = False
|
self.fetching_screenshot = False
|
||||||
self.screen_capture = None
|
self.screen_capture = None
|
||||||
|
self._current_hide_mode = None
|
||||||
# Hide Menu
|
# Hide Menu
|
||||||
self.hide_menu = QtWidgets.QToolButton(self.toolbar)
|
self.hide_menu = QtWidgets.QToolButton(self.toolbar)
|
||||||
self.hide_menu.setObjectName('hide_menu')
|
self.hide_menu.setObjectName('hide_menu')
|
||||||
@ -296,17 +297,17 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
text=translate('OpenLP.SlideController', 'Show Theme'),
|
text=translate('OpenLP.SlideController', 'Show Theme'),
|
||||||
icon=UiIcons().live_theme,
|
icon=UiIcons().live_theme,
|
||||||
checked=False, can_shortcuts=True, category=self.category,
|
checked=False, can_shortcuts=True, category=self.category,
|
||||||
triggers=self.on_theme_display)
|
triggers=self.on_toggle_theme)
|
||||||
self.blank_screen = create_action(self, 'blankScreen',
|
self.blank_screen = create_action(self, 'blankScreen',
|
||||||
text=translate('OpenLP.SlideController', 'Show Black'),
|
text=translate('OpenLP.SlideController', 'Show Black'),
|
||||||
icon=UiIcons().live_black,
|
icon=UiIcons().live_black,
|
||||||
checked=False, can_shortcuts=True, category=self.category,
|
checked=False, can_shortcuts=True, category=self.category,
|
||||||
triggers=self.on_blank_display)
|
triggers=self.on_toggle_blank)
|
||||||
self.desktop_screen = create_action(self, 'desktopScreen',
|
self.desktop_screen = create_action(self, 'desktopScreen',
|
||||||
text=translate('OpenLP.SlideController', 'Show Desktop'),
|
text=translate('OpenLP.SlideController', 'Show Desktop'),
|
||||||
icon=UiIcons().live_desktop,
|
icon=UiIcons().live_desktop,
|
||||||
checked=False, can_shortcuts=True, category=self.category,
|
checked=False, can_shortcuts=True, category=self.category,
|
||||||
triggers=self.on_hide_display)
|
triggers=self.on_toggle_desktop)
|
||||||
self.hide_menu.setDefaultAction(self.show_screen)
|
self.hide_menu.setDefaultAction(self.show_screen)
|
||||||
self.hide_menu.menu().addAction(self.show_screen)
|
self.hide_menu.menu().addAction(self.show_screen)
|
||||||
self.hide_menu.menu().addAction(self.theme_screen)
|
self.hide_menu.menu().addAction(self.theme_screen)
|
||||||
@ -941,7 +942,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
if self.service_item.is_command() and not self.service_item.is_media():
|
if self.service_item.is_command() and not self.service_item.is_media():
|
||||||
Registry().execute(
|
Registry().execute(
|
||||||
'{text}_start'.format(text=self.service_item.name.lower()),
|
'{text}_start'.format(text=self.service_item.name.lower()),
|
||||||
[self.service_item, self.is_live, self.get_hide_mode(), slide_no])
|
[self.service_item, self.is_live, self._current_hide_mode, slide_no])
|
||||||
else:
|
else:
|
||||||
self._set_theme(self.service_item)
|
self._set_theme(self.service_item)
|
||||||
# Reset blanking if needed
|
# Reset blanking if needed
|
||||||
@ -1074,11 +1075,11 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
self.set_hide_mode(None)
|
self.set_hide_mode(None)
|
||||||
|
|
||||||
def on_toggle_blank(self):
|
def on_toggle_blank(self, checked=None):
|
||||||
"""
|
"""
|
||||||
Toggle the blank screen
|
Toggle the blank screen
|
||||||
"""
|
"""
|
||||||
if self.get_hide_mode() == HideMode.Blank:
|
if self._current_hide_mode == HideMode.Blank:
|
||||||
self.set_hide_mode(None)
|
self.set_hide_mode(None)
|
||||||
else:
|
else:
|
||||||
self.set_hide_mode(HideMode.Blank)
|
self.set_hide_mode(HideMode.Blank)
|
||||||
@ -1091,11 +1092,11 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
self.set_hide_mode(HideMode.Blank)
|
self.set_hide_mode(HideMode.Blank)
|
||||||
|
|
||||||
def on_toggle_theme(self):
|
def on_toggle_theme(self, checked=None):
|
||||||
"""
|
"""
|
||||||
Toggle the Theme screen
|
Toggle the Theme screen
|
||||||
"""
|
"""
|
||||||
if self.get_hide_mode() == HideMode.Theme:
|
if self._current_hide_mode == HideMode.Theme:
|
||||||
self.set_hide_mode(None)
|
self.set_hide_mode(None)
|
||||||
else:
|
else:
|
||||||
self.set_hide_mode(HideMode.Theme)
|
self.set_hide_mode(HideMode.Theme)
|
||||||
@ -1108,11 +1109,11 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
self.set_hide_mode(HideMode.Theme)
|
self.set_hide_mode(HideMode.Theme)
|
||||||
|
|
||||||
def on_toggle_desktop(self):
|
def on_toggle_desktop(self, checked=None):
|
||||||
"""
|
"""
|
||||||
Toggle the desktop
|
Toggle the desktop
|
||||||
"""
|
"""
|
||||||
if self.get_hide_mode() == HideMode.Screen:
|
if self._current_hide_mode == HideMode.Screen:
|
||||||
self.set_hide_mode(None)
|
self.set_hide_mode(None)
|
||||||
else:
|
else:
|
||||||
self.set_hide_mode(HideMode.Screen)
|
self.set_hide_mode(HideMode.Screen)
|
||||||
@ -1131,6 +1132,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
Blank/Hide the display screen (within a plugin if required).
|
Blank/Hide the display screen (within a plugin if required).
|
||||||
"""
|
"""
|
||||||
self.log_debug('set_hide_mode {text}'.format(text=hide_mode))
|
self.log_debug('set_hide_mode {text}'.format(text=hide_mode))
|
||||||
|
self._current_hide_mode = hide_mode
|
||||||
# Update ui buttons
|
# Update ui buttons
|
||||||
if hide_mode is None:
|
if hide_mode is None:
|
||||||
self.hide_menu.setDefaultAction(self.blank_screen)
|
self.hide_menu.setDefaultAction(self.blank_screen)
|
||||||
@ -1378,8 +1380,7 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Toggles the loop state.
|
Toggles the loop state.
|
||||||
"""
|
"""
|
||||||
hide_mode = self.get_hide_mode()
|
if self._current_hide_mode is None and (self.play_slides_loop.isChecked() or self.play_slides_once.isChecked()):
|
||||||
if hide_mode is None and (self.play_slides_loop.isChecked() or self.play_slides_once.isChecked()):
|
|
||||||
self.on_start_loop()
|
self.on_start_loop()
|
||||||
else:
|
else:
|
||||||
self.on_stop_loop()
|
self.on_stop_loop()
|
||||||
@ -1528,13 +1529,13 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
if State().check_preconditions('media'):
|
if State().check_preconditions('media'):
|
||||||
if self.is_live and not item.is_media() and item.requires_media():
|
if self.is_live and not item.is_media() and item.requires_media():
|
||||||
self.media_controller.load_video(self.controller_type, item, self.get_hide_mode())
|
self.media_controller.load_video(self.controller_type, item, self._current_hide_mode)
|
||||||
elif self.is_live and self.get_hide_mode() == HideMode.Theme:
|
elif self.is_live and self._current_hide_mode == HideMode.Theme:
|
||||||
self.media_controller.load_video(self.controller_type, item, HideMode.Blank)
|
self.media_controller.load_video(self.controller_type, item, HideMode.Blank)
|
||||||
self.set_hide_mode(HideMode.Blank)
|
self.set_hide_mode(HideMode.Blank)
|
||||||
elif self.is_live or item.is_media():
|
elif self.is_live or item.is_media():
|
||||||
# avoid loading the video if this is preview and the media is background
|
# avoid loading the video if this is preview and the media is background
|
||||||
self.media_controller.load_video(self.controller_type, item, self.get_hide_mode())
|
self.media_controller.load_video(self.controller_type, item, self._current_hide_mode)
|
||||||
if not self.is_live:
|
if not self.is_live:
|
||||||
self.preview_display.show()
|
self.preview_display.show()
|
||||||
|
|
||||||
@ -1551,12 +1552,11 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
|
|
||||||
:param no_theme: Does the new item support theme-blanking.
|
:param no_theme: Does the new item support theme-blanking.
|
||||||
"""
|
"""
|
||||||
hide_mode = self.get_hide_mode()
|
if self._current_hide_mode == HideMode.Theme and no_theme:
|
||||||
if hide_mode == HideMode.Theme and no_theme:
|
|
||||||
# The new item-type doesn't support theme-blanking, so 'switch' to normal blanking.
|
# The new item-type doesn't support theme-blanking, so 'switch' to normal blanking.
|
||||||
self.set_hide_mode(HideMode.Blank)
|
self.set_hide_mode(HideMode.Blank)
|
||||||
else:
|
else:
|
||||||
self.set_hide_mode(hide_mode)
|
self.set_hide_mode(self._current_hide_mode)
|
||||||
|
|
||||||
def get_hide_mode(self):
|
def get_hide_mode(self):
|
||||||
"""
|
"""
|
||||||
@ -1564,14 +1564,8 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
if not self.is_live:
|
if not self.is_live:
|
||||||
return None
|
return None
|
||||||
elif self.blank_screen.isChecked():
|
|
||||||
return HideMode.Blank
|
|
||||||
elif self.theme_screen.isChecked():
|
|
||||||
return HideMode.Theme
|
|
||||||
elif self.desktop_screen.isChecked():
|
|
||||||
return HideMode.Screen
|
|
||||||
else:
|
else:
|
||||||
return None
|
return self._current_hide_mode
|
||||||
|
|
||||||
|
|
||||||
class PreviewController(RegistryBase, SlideController):
|
class PreviewController(RegistryBase, SlideController):
|
||||||
|
@ -301,6 +301,7 @@ def test_on_toggle_blank(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
||||||
|
slide_controller._current_hide_mode = None
|
||||||
|
|
||||||
# WHEN: on_toggle_blank() is called
|
# WHEN: on_toggle_blank() is called
|
||||||
slide_controller.on_toggle_blank()
|
slide_controller.on_toggle_blank()
|
||||||
@ -318,6 +319,7 @@ def test_on_toggle_blank_off(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Blank)
|
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Blank)
|
||||||
|
slide_controller._current_hide_mode = HideMode.Blank
|
||||||
|
|
||||||
# WHEN: on_toggle_blank() is called
|
# WHEN: on_toggle_blank() is called
|
||||||
slide_controller.on_toggle_blank()
|
slide_controller.on_toggle_blank()
|
||||||
@ -335,6 +337,7 @@ def test_on_toggle_theme(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
||||||
|
slide_controller._current_hide_mode = None
|
||||||
|
|
||||||
# WHEN: on_toggle_theme() is called
|
# WHEN: on_toggle_theme() is called
|
||||||
slide_controller.on_toggle_theme()
|
slide_controller.on_toggle_theme()
|
||||||
@ -352,6 +355,7 @@ def test_on_toggle_theme_off(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Theme)
|
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Theme)
|
||||||
|
slide_controller._current_hide_mode = HideMode.Theme
|
||||||
|
|
||||||
# WHEN: on_toggle_theme() is called
|
# WHEN: on_toggle_theme() is called
|
||||||
slide_controller.on_toggle_theme()
|
slide_controller.on_toggle_theme()
|
||||||
@ -369,6 +373,7 @@ def test_on_toggle_desktop(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
slide_controller.get_hide_mode = MagicMock(return_value=None)
|
||||||
|
slide_controller._current_hide_mode = None
|
||||||
|
|
||||||
# WHEN: on_toggle_desktop() is called
|
# WHEN: on_toggle_desktop() is called
|
||||||
slide_controller.on_toggle_desktop()
|
slide_controller.on_toggle_desktop()
|
||||||
@ -386,6 +391,7 @@ def test_on_toggle_desktop_off(settings):
|
|||||||
slide_controller = SlideController(None)
|
slide_controller = SlideController(None)
|
||||||
slide_controller.set_hide_mode = mocked_set_hide_mode
|
slide_controller.set_hide_mode = mocked_set_hide_mode
|
||||||
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Screen)
|
slide_controller.get_hide_mode = MagicMock(return_value=HideMode.Screen)
|
||||||
|
slide_controller._current_hide_mode = HideMode.Screen
|
||||||
|
|
||||||
# WHEN: on_toggle_desktop() is called
|
# WHEN: on_toggle_desktop() is called
|
||||||
slide_controller.on_toggle_desktop()
|
slide_controller.on_toggle_desktop()
|
||||||
@ -1069,6 +1075,7 @@ def test_process_item_song_vlc(mocked_execute, registry, state_media):
|
|||||||
slide_controller.displays = [MagicMock()]
|
slide_controller.displays = [MagicMock()]
|
||||||
slide_controller.split = 0
|
slide_controller.split = 0
|
||||||
slide_controller.type_prefix = 'test'
|
slide_controller.type_prefix = 'test'
|
||||||
|
slide_controller._current_hide_mode = None
|
||||||
|
|
||||||
# WHEN: _process_item is called
|
# WHEN: _process_item is called
|
||||||
slide_controller._process_item(mocked_media_item, 0)
|
slide_controller._process_item(mocked_media_item, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user