forked from openlp/openlp
Merge branch 'toggle_transparency' into 'master'
Toggle transparency Closes #475 See merge request openlp/openlp!160
This commit is contained in:
commit
ab08968b5e
@ -137,6 +137,7 @@ class Settings(QtCore.QSettings):
|
|||||||
__default_settings__ = {
|
__default_settings__ = {
|
||||||
'settings/version': 0,
|
'settings/version': 0,
|
||||||
'advanced/add page break': False,
|
'advanced/add page break': False,
|
||||||
|
'advanced/disable transparent display': True,
|
||||||
'advanced/alternate rows': not is_win(),
|
'advanced/alternate rows': not is_win(),
|
||||||
'advanced/autoscrolling': {'dist': 1, 'pos': 0},
|
'advanced/autoscrolling': {'dist': 1, 'pos': 0},
|
||||||
'advanced/current media plugin': -1,
|
'advanced/current media plugin': -1,
|
||||||
|
@ -220,6 +220,9 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties):
|
|||||||
if path_to_str(image).startswith(':'):
|
if path_to_str(image).startswith(':'):
|
||||||
image = self.openlp_splash_screen_path
|
image = self.openlp_splash_screen_path
|
||||||
image_uri = image.as_uri()
|
image_uri = image.as_uri()
|
||||||
|
# if set to hide logo on startup, do not send the logo
|
||||||
|
if self.settings.value('core/logo hide on startup'):
|
||||||
|
image_uri = ''
|
||||||
self.run_javascript('Display.setStartupSplashScreen("{bg_color}", "{image}");'.format(bg_color=bg_color,
|
self.run_javascript('Display.setStartupSplashScreen("{bg_color}", "{image}");'.format(bg_color=bg_color,
|
||||||
image=image_uri))
|
image=image_uri))
|
||||||
|
|
||||||
@ -423,10 +426,9 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties):
|
|||||||
if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'):
|
if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'):
|
||||||
return
|
return
|
||||||
self.run_javascript('Display.show();')
|
self.run_javascript('Display.show();')
|
||||||
# Check if setting for hiding logo on startup is enabled.
|
if self.isHidden():
|
||||||
# If it is, display should remain hidden, otherwise logo is shown. (from def setup)
|
|
||||||
if self.isHidden() and not self.settings.value('core/logo hide on startup'):
|
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
|
self.webview.setVisible(True)
|
||||||
self.hide_mode = None
|
self.hide_mode = None
|
||||||
# Trigger actions when display is active again.
|
# Trigger actions when display is active again.
|
||||||
if self.is_display:
|
if self.is_display:
|
||||||
@ -443,6 +445,10 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties):
|
|||||||
# Only make visible on single monitor setup if setting enabled.
|
# Only make visible on single monitor setup if setting enabled.
|
||||||
if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'):
|
if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'):
|
||||||
return
|
return
|
||||||
|
# Use Screen mode if Transparent is disallowed via setting
|
||||||
|
if self.settings.value('advanced/disable transparent display') and mode == HideMode.Transparent:
|
||||||
|
mode = HideMode.Screen
|
||||||
|
# Now update display to the selected mode
|
||||||
if mode == HideMode.Screen:
|
if mode == HideMode.Screen:
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
elif mode == HideMode.Blank:
|
elif mode == HideMode.Blank:
|
||||||
|
@ -178,6 +178,9 @@ class AdvancedTab(SettingsTab):
|
|||||||
self.alternate_rows_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box)
|
self.alternate_rows_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box)
|
||||||
self.alternate_rows_check_box.setObjectName('alternate_rows_check_box')
|
self.alternate_rows_check_box.setObjectName('alternate_rows_check_box')
|
||||||
self.display_workaround_layout.addWidget(self.alternate_rows_check_box)
|
self.display_workaround_layout.addWidget(self.alternate_rows_check_box)
|
||||||
|
self.allow_transparent_display_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box)
|
||||||
|
self.allow_transparent_display_check_box.setObjectName('allow_transparent_display_check_box')
|
||||||
|
self.display_workaround_layout.addWidget(self.allow_transparent_display_check_box)
|
||||||
self.right_layout.addWidget(self.display_workaround_group_box)
|
self.right_layout.addWidget(self.display_workaround_group_box)
|
||||||
# Default service name
|
# Default service name
|
||||||
self.service_name_group_box = QtWidgets.QGroupBox(self.right_column)
|
self.service_name_group_box = QtWidgets.QGroupBox(self.right_column)
|
||||||
@ -324,6 +327,8 @@ class AdvancedTab(SettingsTab):
|
|||||||
self.ignore_aspect_ratio_check_box.setText(translate('OpenLP.AdvancedTab', 'Ignore Aspect Ratio'))
|
self.ignore_aspect_ratio_check_box.setText(translate('OpenLP.AdvancedTab', 'Ignore Aspect Ratio'))
|
||||||
self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager'))
|
self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager'))
|
||||||
self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists'))
|
self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists'))
|
||||||
|
self.allow_transparent_display_check_box.setText(
|
||||||
|
translate('OpenLP.AdvancedTab', 'Disable display transparency'))
|
||||||
# Slide Limits
|
# Slide Limits
|
||||||
self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
|
self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits'))
|
||||||
self.slide_label.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:'))
|
self.slide_label.setText(translate('OpenLP.GeneralTab', 'Behavior of next/previous on the last/first slide:'))
|
||||||
@ -377,6 +382,7 @@ class AdvancedTab(SettingsTab):
|
|||||||
self.alternate_rows_check_box.blockSignals(True)
|
self.alternate_rows_check_box.blockSignals(True)
|
||||||
self.alternate_rows_check_box.setChecked(self.settings.value('alternate rows'))
|
self.alternate_rows_check_box.setChecked(self.settings.value('alternate rows'))
|
||||||
self.alternate_rows_check_box.blockSignals(False)
|
self.alternate_rows_check_box.blockSignals(False)
|
||||||
|
self.allow_transparent_display_check_box.setChecked(self.settings.value('disable transparent display'))
|
||||||
if self.slide_limits == SlideLimits.End:
|
if self.slide_limits == SlideLimits.End:
|
||||||
self.end_slide_radio_button.setChecked(True)
|
self.end_slide_radio_button.setChecked(True)
|
||||||
elif self.slide_limits == SlideLimits.Wrap:
|
elif self.slide_limits == SlideLimits.Wrap:
|
||||||
@ -422,6 +428,7 @@ class AdvancedTab(SettingsTab):
|
|||||||
self.settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
|
self.settings.setValue('enable exit confirmation', self.enable_auto_close_check_box.isChecked())
|
||||||
self.settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
|
self.settings.setValue('hide mouse', self.hide_mouse_check_box.isChecked())
|
||||||
self.settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
|
self.settings.setValue('alternate rows', self.alternate_rows_check_box.isChecked())
|
||||||
|
self.settings.setValue('disable transparent display', self.allow_transparent_display_check_box.isChecked())
|
||||||
self.settings.setValue('slide limits', self.slide_limits)
|
self.settings.setValue('slide limits', self.slide_limits)
|
||||||
self.settings.setValue('ignore aspect ratio', self.ignore_aspect_ratio_check_box.isChecked())
|
self.settings.setValue('ignore aspect ratio', self.ignore_aspect_ratio_check_box.isChecked())
|
||||||
if self.x11_bypass_check_box.isChecked() != self.settings.value('x11 bypass wm'):
|
if self.x11_bypass_check_box.isChecked() != self.settings.value('x11 bypass wm'):
|
||||||
|
@ -174,15 +174,63 @@ def test_run_javascript_sync_no_wait(mock_time, mocked_webengine, mocked_addWidg
|
|||||||
mock_time.sleep.assert_not_called()
|
mock_time.sleep.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
|
@patch('openlp.core.display.webengine.WebEngineView')
|
||||||
|
@patch('openlp.core.common.registry.Registry.execute')
|
||||||
|
@patch('openlp.core.display.screens.ScreenList')
|
||||||
|
def test_show_display(mocked_screenlist, mocked_registry_execute, mocked_webengine, mocked_addWidget, mock_settings):
|
||||||
|
"""
|
||||||
|
Test show_display function
|
||||||
|
"""
|
||||||
|
# GIVEN: Display window as the active display
|
||||||
|
display_window = DisplayWindow()
|
||||||
|
display_window.is_display = True
|
||||||
|
display_window.isHidden = MagicMock(return_value=True)
|
||||||
|
display_window.setVisible = MagicMock()
|
||||||
|
display_window.run_javascript = MagicMock()
|
||||||
|
mocked_screenlist.screens = [1, 2]
|
||||||
|
|
||||||
|
# WHEN: Show display is run
|
||||||
|
display_window.show_display()
|
||||||
|
|
||||||
|
# THEN: Should show the display and set the hide mode to none
|
||||||
|
display_window.setVisible.assert_called_once_with(True)
|
||||||
|
display_window.run_javascript.assert_called_once_with('Display.show();')
|
||||||
|
mocked_registry_execute.assert_called_once_with('live_display_active')
|
||||||
|
assert display_window.hide_mode is None
|
||||||
|
|
||||||
|
|
||||||
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
|
@patch('openlp.core.display.webengine.WebEngineView')
|
||||||
|
@patch('openlp.core.display.window.ScreenList')
|
||||||
|
def test_show_display_no_display(mocked_screenlist, mocked_webengine, mocked_addWidget, mock_settings):
|
||||||
|
"""
|
||||||
|
Test show_display function when no displays are available
|
||||||
|
"""
|
||||||
|
# GIVEN: A Display window, one screen and core/display on monitor disabled
|
||||||
|
display_window = DisplayWindow()
|
||||||
|
display_window.hide_mode = HideMode.Screen
|
||||||
|
display_window.is_display = True
|
||||||
|
mocked_screenlist.return_value = [1]
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
|
# WHEN: Show display is run
|
||||||
|
display_window.show_display()
|
||||||
|
|
||||||
|
# THEN: Hide mode should still be screen
|
||||||
|
assert display_window.hide_mode == HideMode.Screen
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
@patch('openlp.core.display.webengine.WebEngineView')
|
@patch('openlp.core.display.webengine.WebEngineView')
|
||||||
def test_hide_display_to_screen(mocked_webengine, mocked_addWidget, mock_settings):
|
def test_hide_display_to_screen(mocked_webengine, mocked_addWidget, mock_settings):
|
||||||
"""
|
"""
|
||||||
Test hide to screen in the hide_display function
|
Test hide to screen in the hide_display function
|
||||||
"""
|
"""
|
||||||
# GIVEN:
|
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
display_window.setVisible = MagicMock()
|
display_window.setVisible = MagicMock()
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
# WHEN: Hide display is run with no mode (should default to Screen)
|
# WHEN: Hide display is run with no mode (should default to Screen)
|
||||||
display_window.hide_display()
|
display_window.hide_display()
|
||||||
@ -198,9 +246,10 @@ def test_hide_display_to_blank(mocked_webengine, mocked_addWidget, mock_settings
|
|||||||
"""
|
"""
|
||||||
Test hide to screen in the hide_display function
|
Test hide to screen in the hide_display function
|
||||||
"""
|
"""
|
||||||
# GIVEN:
|
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
display_window.run_javascript = MagicMock()
|
display_window.run_javascript = MagicMock()
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
# WHEN: Hide display is run with HideMode.Blank
|
# WHEN: Hide display is run with HideMode.Blank
|
||||||
display_window.hide_display(HideMode.Blank)
|
display_window.hide_display(HideMode.Blank)
|
||||||
@ -216,9 +265,10 @@ def test_hide_display_to_theme(mocked_webengine, mocked_addWidget, mock_settings
|
|||||||
"""
|
"""
|
||||||
Test hide to screen in the hide_display function
|
Test hide to screen in the hide_display function
|
||||||
"""
|
"""
|
||||||
# GIVEN:
|
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
display_window.run_javascript = MagicMock()
|
display_window.run_javascript = MagicMock()
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
# WHEN: Hide display is run with HideMode.Theme
|
# WHEN: Hide display is run with HideMode.Theme
|
||||||
display_window.hide_display(HideMode.Theme)
|
display_window.hide_display(HideMode.Theme)
|
||||||
@ -234,13 +284,55 @@ def test_hide_display_to_transparent(mocked_webengine, mocked_addWidget, mock_se
|
|||||||
"""
|
"""
|
||||||
Test hide to screen in the hide_display function
|
Test hide to screen in the hide_display function
|
||||||
"""
|
"""
|
||||||
# GIVEN:
|
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
display_window.run_javascript = MagicMock()
|
display_window.run_javascript = MagicMock()
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
# WHEN: Hide display is run with HideMode.Transparent
|
# WHEN: Hide display is run with HideMode.Transparent
|
||||||
display_window.hide_display(HideMode.Transparent)
|
display_window.hide_display(HideMode.Transparent)
|
||||||
|
|
||||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||||
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
|
||||||
assert display_window.hide_mode == HideMode.Transparent
|
assert display_window.hide_mode == HideMode.Transparent
|
||||||
|
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
||||||
|
|
||||||
|
|
||||||
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
|
@patch('openlp.core.display.webengine.WebEngineView')
|
||||||
|
def test_hide_transparent_to_screen(mocked_webengine, mocked_addWidget, mock_settings):
|
||||||
|
"""
|
||||||
|
Test that when going transparent, and the disable transparent setting is enabled,
|
||||||
|
the screen mode should be used.
|
||||||
|
"""
|
||||||
|
# GIVEN: Display window and setting advanced/disable transparent display = True
|
||||||
|
display_window = DisplayWindow()
|
||||||
|
display_window.setVisible = MagicMock()
|
||||||
|
mock_settings.value.return_value = True
|
||||||
|
|
||||||
|
# WHEN: Hide display is run with HideMode.Transparent
|
||||||
|
display_window.hide_display(HideMode.Transparent)
|
||||||
|
|
||||||
|
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||||
|
display_window.setVisible.assert_called_once_with(False)
|
||||||
|
assert display_window.hide_mode == HideMode.Screen
|
||||||
|
|
||||||
|
|
||||||
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
|
@patch('openlp.core.display.webengine.WebEngineView')
|
||||||
|
@patch('openlp.core.display.window.ScreenList')
|
||||||
|
def test_hide_display_no_display(mocked_screenlist, mocked_webengine, mocked_addWidget, mock_settings):
|
||||||
|
"""
|
||||||
|
Test show_display function when no displays are available
|
||||||
|
"""
|
||||||
|
# GIVEN: A Display window, one screen and core/display on monitor disabled
|
||||||
|
display_window = DisplayWindow()
|
||||||
|
display_window.hide_mode = None
|
||||||
|
display_window.is_display = True
|
||||||
|
mocked_screenlist.return_value = [1]
|
||||||
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
|
# WHEN: Hide display is run
|
||||||
|
display_window.hide_display(HideMode.Screen)
|
||||||
|
|
||||||
|
# THEN: Hide mode should still be none
|
||||||
|
assert display_window.hide_mode is None
|
||||||
|
Loading…
Reference in New Issue
Block a user