forked from openlp/openlp
Always use transparency when going to desktop
Except when the display workaround is enabled of course :)
This commit is contained in:
parent
c24f018775
commit
f4e30c15cc
@ -81,10 +81,19 @@ class WebEngineView(QtWebEngineWidgets.QWebEngineView):
|
||||
"""
|
||||
Emit delegatePaint on paint event of the last added QOpenGLWidget child
|
||||
"""
|
||||
if obj == self._child and ev.type() == QtCore.QEvent.Paint:
|
||||
self.delegatePaint.emit()
|
||||
if obj == self._child:
|
||||
if ev.type() == QtCore.QEvent.MouseButtonPress or ev.type() == QtCore.QEvent.TouchBegin:
|
||||
self.display_clicked()
|
||||
if ev.type() == QtCore.QEvent.Paint:
|
||||
self.delegatePaint.emit()
|
||||
return super(WebEngineView, self).eventFilter(obj, ev)
|
||||
|
||||
def display_clicked(self):
|
||||
"""
|
||||
Dummy method to be overridden
|
||||
"""
|
||||
pass
|
||||
|
||||
def event(self, ev):
|
||||
"""
|
||||
Handle events
|
||||
|
@ -146,6 +146,7 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
|
||||
self.webview = WebEngineView(self)
|
||||
self.webview.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
||||
self.webview.page().setBackgroundColor(QtCore.Qt.transparent)
|
||||
self.webview.display_clicked = self.disable_display
|
||||
self.layout.addWidget(self.webview)
|
||||
self.webview.loadFinished.connect(self.after_loaded)
|
||||
display_base_path = AppLocation.get_directory(AppLocation.AppDir) / 'core' / 'display' / 'html'
|
||||
@ -428,7 +429,6 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
|
||||
self.run_javascript('Display.show();')
|
||||
if self.isHidden():
|
||||
self.setVisible(True)
|
||||
self.webview.setVisible(True)
|
||||
self.hide_mode = None
|
||||
# Trigger actions when display is active again.
|
||||
if self.is_display:
|
||||
@ -445,24 +445,29 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
|
||||
# Only make visible on single monitor setup if setting enabled.
|
||||
if len(ScreenList()) == 1 and not self.settings.value('core/display on monitor'):
|
||||
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
|
||||
# Update display to the selected mode
|
||||
if mode == HideMode.Screen:
|
||||
self.setVisible(False)
|
||||
if self.settings.value('advanced/disable transparent display'):
|
||||
self.setVisible(False)
|
||||
else:
|
||||
self.run_javascript('Display.toTransparent();')
|
||||
elif mode == HideMode.Blank:
|
||||
self.run_javascript('Display.toBlack();')
|
||||
elif mode == HideMode.Theme:
|
||||
self.run_javascript('Display.toTheme();')
|
||||
else:
|
||||
self.run_javascript('Display.toTransparent();')
|
||||
if mode != HideMode.Screen:
|
||||
if self.isHidden():
|
||||
self.setVisible(True)
|
||||
self.webview.setVisible(True)
|
||||
self.hide_mode = mode
|
||||
|
||||
def disable_display(self):
|
||||
"""
|
||||
Removes the display if showing desktop
|
||||
This allows users to click though the screen even if the screen is only transparent
|
||||
"""
|
||||
if self.is_display and self.hide_mode == HideMode.Screen:
|
||||
self.setVisible(False)
|
||||
|
||||
def set_scale(self, scale):
|
||||
"""
|
||||
Set the HTML scale
|
||||
|
@ -41,7 +41,6 @@ class HideMode(object):
|
||||
Blank = 1
|
||||
Theme = 2
|
||||
Screen = 3
|
||||
Transparent = 4
|
||||
|
||||
|
||||
class DisplayControllerType(object):
|
||||
|
@ -454,7 +454,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties):
|
||||
controller.media_info.is_playing = True
|
||||
if not controller.media_info.is_background:
|
||||
display = self._define_display(controller)
|
||||
display.hide_display(HideMode.Transparent)
|
||||
display.hide_display(HideMode.Screen)
|
||||
controller._set_theme(controller.service_item)
|
||||
display.load_verses([{"verse": "v1", "text": "", "footer": " "}])
|
||||
return True
|
||||
|
@ -197,7 +197,6 @@ def test_show_display(mocked_screenlist, mocked_registry_execute, mocked_webengi
|
||||
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')
|
||||
@ -209,7 +208,7 @@ def test_show_display_no_display(mocked_screenlist, mocked_webengine, mocked_add
|
||||
"""
|
||||
# GIVEN: A Display window, one screen and core/display on monitor disabled
|
||||
display_window = DisplayWindow()
|
||||
display_window.hide_mode = HideMode.Screen
|
||||
display_window.run_javascript = MagicMock()
|
||||
display_window.is_display = True
|
||||
mocked_screenlist.return_value = [1]
|
||||
mock_settings.value.return_value = False
|
||||
@ -217,8 +216,8 @@ def test_show_display_no_display(mocked_screenlist, mocked_webengine, mocked_add
|
||||
# WHEN: Show display is run
|
||||
display_window.show_display()
|
||||
|
||||
# THEN: Hide mode should still be screen
|
||||
assert display_window.hide_mode == HideMode.Screen
|
||||
# THEN: Shouldn't run the js show fn
|
||||
assert display_window.run_javascript.call_count == 0
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@ -229,15 +228,16 @@ def test_hide_display_to_screen(mocked_webengine, mocked_addWidget, mock_setting
|
||||
"""
|
||||
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||
display_window = DisplayWindow()
|
||||
display_window.run_javascript = MagicMock()
|
||||
display_window.setVisible = MagicMock()
|
||||
mock_settings.value.return_value = False
|
||||
|
||||
# WHEN: Hide display is run with no mode (should default to Screen)
|
||||
display_window.hide_display()
|
||||
|
||||
# THEN: Should hide the display and set the hide mode
|
||||
display_window.setVisible.assert_called_once_with(False)
|
||||
assert display_window.hide_mode == HideMode.Screen
|
||||
# THEN: Should hide the display with the js transparency function (not setVisible)
|
||||
display_window.setVisible.call_count == 0
|
||||
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@ -256,7 +256,6 @@ def test_hide_display_to_blank(mocked_webengine, mocked_addWidget, mock_settings
|
||||
|
||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||
display_window.run_javascript.assert_called_once_with('Display.toBlack();')
|
||||
assert display_window.hide_mode == HideMode.Blank
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@ -275,7 +274,6 @@ def test_hide_display_to_theme(mocked_webengine, mocked_addWidget, mock_settings
|
||||
|
||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||
display_window.run_javascript.assert_called_once_with('Display.toTheme();')
|
||||
assert display_window.hide_mode == HideMode.Theme
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@ -287,14 +285,15 @@ def test_hide_display_to_transparent(mocked_webengine, mocked_addWidget, mock_se
|
||||
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||
display_window = DisplayWindow()
|
||||
display_window.run_javascript = MagicMock()
|
||||
display_window.setVisible = MagicMock()
|
||||
mock_settings.value.return_value = False
|
||||
|
||||
# WHEN: Hide display is run with HideMode.Transparent
|
||||
display_window.hide_display(HideMode.Transparent)
|
||||
# WHEN: Hide display is run with HideMode.Screen
|
||||
display_window.hide_display(HideMode.Screen)
|
||||
|
||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||
assert display_window.hide_mode == HideMode.Transparent
|
||||
# THEN: Should run the correct javascript on the display and not set the visiblity
|
||||
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
||||
assert display_window.setVisible.call_count == 0
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
@ -309,12 +308,11 @@ def test_hide_transparent_to_screen(mocked_webengine, mocked_addWidget, mock_set
|
||||
display_window.setVisible = MagicMock()
|
||||
mock_settings.value.return_value = True
|
||||
|
||||
# WHEN: Hide display is run with HideMode.Transparent
|
||||
display_window.hide_display(HideMode.Transparent)
|
||||
# WHEN: Hide display is run with HideMode.Screen
|
||||
display_window.hide_display(HideMode.Screen)
|
||||
|
||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||
# THEN: Should run setVisible(False)
|
||||
display_window.setVisible.assert_called_once_with(False)
|
||||
assert display_window.hide_mode == HideMode.Screen
|
||||
|
||||
|
||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||
|
Loading…
Reference in New Issue
Block a user