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
|
Emit delegatePaint on paint event of the last added QOpenGLWidget child
|
||||||
"""
|
"""
|
||||||
if obj == self._child and ev.type() == QtCore.QEvent.Paint:
|
if obj == self._child:
|
||||||
self.delegatePaint.emit()
|
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)
|
return super(WebEngineView, self).eventFilter(obj, ev)
|
||||||
|
|
||||||
|
def display_clicked(self):
|
||||||
|
"""
|
||||||
|
Dummy method to be overridden
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def event(self, ev):
|
def event(self, ev):
|
||||||
"""
|
"""
|
||||||
Handle events
|
Handle events
|
||||||
|
@ -146,6 +146,7 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
|
|||||||
self.webview = WebEngineView(self)
|
self.webview = WebEngineView(self)
|
||||||
self.webview.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
self.webview.setAttribute(QtCore.Qt.WA_TranslucentBackground)
|
||||||
self.webview.page().setBackgroundColor(QtCore.Qt.transparent)
|
self.webview.page().setBackgroundColor(QtCore.Qt.transparent)
|
||||||
|
self.webview.display_clicked = self.disable_display
|
||||||
self.layout.addWidget(self.webview)
|
self.layout.addWidget(self.webview)
|
||||||
self.webview.loadFinished.connect(self.after_loaded)
|
self.webview.loadFinished.connect(self.after_loaded)
|
||||||
display_base_path = AppLocation.get_directory(AppLocation.AppDir) / 'core' / 'display' / 'html'
|
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();')
|
self.run_javascript('Display.show();')
|
||||||
if self.isHidden():
|
if self.isHidden():
|
||||||
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:
|
||||||
@ -445,24 +445,29 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
|
|||||||
# 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
|
# Update display to the selected mode
|
||||||
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)
|
if self.settings.value('advanced/disable transparent display'):
|
||||||
|
self.setVisible(False)
|
||||||
|
else:
|
||||||
|
self.run_javascript('Display.toTransparent();')
|
||||||
elif mode == HideMode.Blank:
|
elif mode == HideMode.Blank:
|
||||||
self.run_javascript('Display.toBlack();')
|
self.run_javascript('Display.toBlack();')
|
||||||
elif mode == HideMode.Theme:
|
elif mode == HideMode.Theme:
|
||||||
self.run_javascript('Display.toTheme();')
|
self.run_javascript('Display.toTheme();')
|
||||||
else:
|
|
||||||
self.run_javascript('Display.toTransparent();')
|
|
||||||
if mode != HideMode.Screen:
|
if mode != HideMode.Screen:
|
||||||
if self.isHidden():
|
if self.isHidden():
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
self.webview.setVisible(True)
|
|
||||||
self.hide_mode = mode
|
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):
|
def set_scale(self, scale):
|
||||||
"""
|
"""
|
||||||
Set the HTML scale
|
Set the HTML scale
|
||||||
|
@ -41,7 +41,6 @@ class HideMode(object):
|
|||||||
Blank = 1
|
Blank = 1
|
||||||
Theme = 2
|
Theme = 2
|
||||||
Screen = 3
|
Screen = 3
|
||||||
Transparent = 4
|
|
||||||
|
|
||||||
|
|
||||||
class DisplayControllerType(object):
|
class DisplayControllerType(object):
|
||||||
|
@ -454,7 +454,7 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties):
|
|||||||
controller.media_info.is_playing = True
|
controller.media_info.is_playing = True
|
||||||
if not controller.media_info.is_background:
|
if not controller.media_info.is_background:
|
||||||
display = self._define_display(controller)
|
display = self._define_display(controller)
|
||||||
display.hide_display(HideMode.Transparent)
|
display.hide_display(HideMode.Screen)
|
||||||
controller._set_theme(controller.service_item)
|
controller._set_theme(controller.service_item)
|
||||||
display.load_verses([{"verse": "v1", "text": "", "footer": " "}])
|
display.load_verses([{"verse": "v1", "text": "", "footer": " "}])
|
||||||
return True
|
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.setVisible.assert_called_once_with(True)
|
||||||
display_window.run_javascript.assert_called_once_with('Display.show();')
|
display_window.run_javascript.assert_called_once_with('Display.show();')
|
||||||
mocked_registry_execute.assert_called_once_with('live_display_active')
|
mocked_registry_execute.assert_called_once_with('live_display_active')
|
||||||
assert display_window.hide_mode is None
|
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@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
|
# GIVEN: A Display window, one screen and core/display on monitor disabled
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
display_window.hide_mode = HideMode.Screen
|
display_window.run_javascript = MagicMock()
|
||||||
display_window.is_display = True
|
display_window.is_display = True
|
||||||
mocked_screenlist.return_value = [1]
|
mocked_screenlist.return_value = [1]
|
||||||
mock_settings.value.return_value = False
|
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
|
# WHEN: Show display is run
|
||||||
display_window.show_display()
|
display_window.show_display()
|
||||||
|
|
||||||
# THEN: Hide mode should still be screen
|
# THEN: Shouldn't run the js show fn
|
||||||
assert display_window.hide_mode == HideMode.Screen
|
assert display_window.run_javascript.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@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
|
# GIVEN: Display window and setting advanced/disable transparent display = False
|
||||||
display_window = DisplayWindow()
|
display_window = DisplayWindow()
|
||||||
|
display_window.run_javascript = MagicMock()
|
||||||
display_window.setVisible = MagicMock()
|
display_window.setVisible = MagicMock()
|
||||||
mock_settings.value.return_value = False
|
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()
|
||||||
|
|
||||||
# THEN: Should hide the display and set the hide mode
|
# THEN: Should hide the display with the js transparency function (not setVisible)
|
||||||
display_window.setVisible.assert_called_once_with(False)
|
display_window.setVisible.call_count == 0
|
||||||
assert display_window.hide_mode == HideMode.Screen
|
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@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
|
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||||
display_window.run_javascript.assert_called_once_with('Display.toBlack();')
|
display_window.run_javascript.assert_called_once_with('Display.toBlack();')
|
||||||
assert display_window.hide_mode == HideMode.Blank
|
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@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
|
# THEN: Should run the correct javascript on the display and set the hide mode
|
||||||
display_window.run_javascript.assert_called_once_with('Display.toTheme();')
|
display_window.run_javascript.assert_called_once_with('Display.toTheme();')
|
||||||
assert display_window.hide_mode == HideMode.Theme
|
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@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
|
# 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()
|
||||||
|
display_window.setVisible = MagicMock()
|
||||||
mock_settings.value.return_value = False
|
mock_settings.value.return_value = False
|
||||||
|
|
||||||
# WHEN: Hide display is run with HideMode.Transparent
|
# WHEN: Hide display is run with HideMode.Screen
|
||||||
display_window.hide_display(HideMode.Transparent)
|
display_window.hide_display(HideMode.Screen)
|
||||||
|
|
||||||
# THEN: Should run the correct javascript on the display and set the hide mode
|
# THEN: Should run the correct javascript on the display and not set the visiblity
|
||||||
assert display_window.hide_mode == HideMode.Transparent
|
|
||||||
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
display_window.run_javascript.assert_called_once_with('Display.toTransparent();')
|
||||||
|
assert display_window.setVisible.call_count == 0
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
@ -309,12 +308,11 @@ def test_hide_transparent_to_screen(mocked_webengine, mocked_addWidget, mock_set
|
|||||||
display_window.setVisible = MagicMock()
|
display_window.setVisible = MagicMock()
|
||||||
mock_settings.value.return_value = True
|
mock_settings.value.return_value = True
|
||||||
|
|
||||||
# WHEN: Hide display is run with HideMode.Transparent
|
# WHEN: Hide display is run with HideMode.Screen
|
||||||
display_window.hide_display(HideMode.Transparent)
|
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)
|
display_window.setVisible.assert_called_once_with(False)
|
||||||
assert display_window.hide_mode == HideMode.Screen
|
|
||||||
|
|
||||||
|
|
||||||
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
@patch('PyQt5.QtWidgets.QVBoxLayout')
|
||||||
|
Loading…
Reference in New Issue
Block a user