Stop the display window from minimizing when the OpenLP window is not active on macOS

This commit is contained in:
Raoul Snyman 2022-01-29 15:53:08 -07:00
parent ff0605cb21
commit fa802a5f3b
No known key found for this signature in database
GPG Key ID: 7347E1FA47B16091
2 changed files with 33 additions and 1 deletions

View File

@ -29,7 +29,7 @@ import re
from PyQt5 import QtCore, QtWebChannel, QtWidgets
from openlp.core.common import is_win
from openlp.core.common import is_win, is_macosx
from openlp.core.common.applocation import AppLocation
from openlp.core.common.enum import ServiceItemType
from openlp.core.common.i18n import translate
@ -84,6 +84,8 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint
if self.settings.value('advanced/x11 bypass wm'):
flags |= QtCore.Qt.X11BypassWindowManagerHint
if is_macosx():
self.setAttribute(QtCore.Qt.WA_MacAlwaysShowToolWindow, True)
# Need to import this inline to get around a QtWebEngine issue
from openlp.core.display.webengine import WebEngineView
self._is_initialised = False

View File

@ -93,6 +93,36 @@ def test_x11_override_off(display_window_env, mock_settings):
assert x11_bit != QtCore.Qt.X11BypassWindowManagerHint
@patch('openlp.core.display.window.is_macosx')
def test_macos_toolwindow_attribute_set(mocked_is_macosx, mock_settings, display_window_env):
"""
Test that on macOS, the Qt.WA_MacAlwaysShowToolWindow attribute is set
"""
# GIVEN: We're on macOS
mocked_is_macosx.return_value = True
# WHEN: A DisplayWindow is created
display_window = DisplayWindow()
# THEN: The attribute is set
assert display_window.testAttribute(QtCore.Qt.WA_MacAlwaysShowToolWindow) is True
@patch('openlp.core.display.window.is_macosx')
def test_not_macos_toolwindow_attribute_set(mocked_is_macosx, mock_settings, display_window_env):
"""
Test that on systems other than macOS, the Qt.WA_MacAlwaysShowToolWindow attribute is NOT set
"""
# GIVEN: We're on macOS
mocked_is_macosx.return_value = False
# WHEN: A DisplayWindow is created
display_window = DisplayWindow()
# THEN: The attribute is set
assert display_window.testAttribute(QtCore.Qt.WA_MacAlwaysShowToolWindow) is False
def test_set_scale_not_initialised(display_window_env, mock_settings):
"""
Test that the scale js is not run if the page is not initialised