Merge branch 'issue-784' into 'master'

Issue 784 - Fix up preview panel code which has memory failure

Closes #784

See merge request openlp/openlp!436
This commit is contained in:
Raoul Snyman 2022-03-01 19:21:27 +00:00
commit 2ec1520c3f
2 changed files with 125 additions and 9 deletions

View File

@ -650,14 +650,22 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
# This will store currently used layout preset so it remains enabled on next startup. # This will store currently used layout preset so it remains enabled on next startup.
# If any panel is enabled/disabled after preset is set, this setting is not saved. # If any panel is enabled/disabled after preset is set, this setting is not saved.
view_mode = self.settings.value('core/view mode') view_mode = self.settings.value('core/view mode')
if view_mode == 'default' and self.settings.value('user interface/is preset layout'): # If we are using a default mode set accordingly
self.mode_default_item.setChecked(True) if self.settings.value('user interface/is preset layout'):
elif view_mode == 'setup' and self.settings.value('user interface/is preset layout'): if view_mode == 'default':
self.set_view_mode(True, True, False, True, False, True) self.set_view_mode(True, True, True, True, True, True)
self.mode_setup_item.setChecked(True) self.mode_default_item.setChecked(True)
elif view_mode == 'live' and self.settings.value('user interface/is preset layout'): elif view_mode == 'setup':
self.set_view_mode(False, True, False, False, True, True) self.set_view_mode(True, True, False, True, False, True)
self.mode_live_item.setChecked(True) self.mode_setup_item.setChecked(True)
elif view_mode == 'live':
self.set_view_mode(False, True, False, False, True, True)
self.mode_live_item.setChecked(True)
else:
self.set_view_mode(True, True, True,
self.settings.value('user interface/preview panel'),
self.settings.value('user interface/live panel'),
True)
def first_time(self): def first_time(self):
""" """
@ -977,7 +985,8 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
self.settings.setValue('user interface/is preset layout', True) self.settings.setValue('user interface/is preset layout', True)
self.settings.setValue('projector/show after wizard', True) self.settings.setValue('projector/show after wizard', True)
def set_view_mode(self, media=True, service=True, theme=True, preview=True, live=True, projector=True, mode=''): def set_view_mode(self, media=True, service=True, theme=True, preview=True,
live=True, projector=True, mode='') -> None:
""" """
Set OpenLP to a different view mode. Set OpenLP to a different view mode.
""" """

View File

@ -580,3 +580,110 @@ def test_projector_manager_dock_unlocked(main_window_reduced):
# THEN: Projector manager dock should have been called with enable UI features # THEN: Projector manager dock should have been called with enable UI features
projector_dock.setFeatures.assert_called_with(7) projector_dock.setFeatures.assert_called_with(7)
@patch('openlp.core.ui.mainwindow.MainWindow.set_view_mode')
def test_load_settings_view_mode_default_mode(mocked_view_mode, main_window, settings):
"""
Test that the view mode is called with the correct parameters for default mode
"""
# GIVEN a newly opened OpenLP instance, mocked screens and settings for a valid window position
# mock out some other calls in load_settings()
main_window.control_splitter = MagicMock()
main_window._live_controller = MagicMock()
main_window._preview_controller = MagicMock()
main_window.settings.setValue('core/view mode', 'default')
main_window.settings.setValue('user interface/is preset layout', True)
# WHENL we call to show method
main_window.show()
# THEN:
# The default mode should have been called.
mocked_view_mode.assert_called_with(True, True, True, True, True, True)
@patch('openlp.core.ui.mainwindow.MainWindow.set_view_mode')
def test_load_settings_view_mode_setup_mode(mocked_view_mode, main_window, settings):
"""
Test that the view mode is called with the correct parameters for setup mode
"""
# GIVEN a newly opened OpenLP instance, mocked screens and settings for a valid window position
# mock out some other calls in load_settings()
main_window.control_splitter = MagicMock()
main_window._live_controller = MagicMock()
main_window._preview_controller = MagicMock()
main_window.settings.setValue('core/view mode', 'setup')
main_window.settings.setValue('user interface/is preset layout', True)
# WHENL we call to show method
main_window.show()
# THEN:
# The default mode should have been called.
mocked_view_mode.assert_called_with(True, True, False, True, False, True)
@patch('openlp.core.ui.mainwindow.MainWindow.set_view_mode')
def test_load_settings_view_mode_live_mode(mocked_view_mode, main_window, settings):
"""
Test that the view mode is called with the correct parameters for live mode
"""
# GIVEN a newly opened OpenLP instance, mocked screens and settings for a valid window position
# mock out some other calls in load_settings()
main_window.control_splitter = MagicMock()
main_window._live_controller = MagicMock()
main_window._preview_controller = MagicMock()
main_window.settings.setValue('core/view mode', 'live')
main_window.settings.setValue('user interface/is preset layout', True)
# WHENL we call to show method
main_window.show()
# THEN:
# The default mode should have been called.
mocked_view_mode.assert_called_with(False, True, False, False, True, True)
@patch('openlp.core.ui.mainwindow.MainWindow.set_view_mode')
def test_load_settings_view_mode_preview(mocked_view_mode, main_window, settings):
"""
Test that the view mode is called with the correct parameters for default
"""
# GIVEN a newly opened OpenLP instance, mocked screens and settings for a valid window position
# mock out some other calls in load_settings()
main_window.control_splitter = MagicMock()
main_window._live_controller = MagicMock()
main_window._preview_controller = MagicMock()
main_window.settings.setValue('core/view mode', 'default')
main_window.settings.setValue('user interface/is preset layout', False)
main_window.settings.setValue('user interface/preview panel', False)
# WHENL we call to show method
main_window.show()
# THEN:
# The default mode should have been called.
mocked_view_mode.assert_called_with(True, True, True, False, True, True)
@patch('openlp.core.ui.mainwindow.MainWindow.set_view_mode')
def test_load_settings_view_mode_live(mocked_view_mode, main_window, settings):
"""
Test that the view mode is called with the correct parameters for default
"""
# GIVEN a newly opened OpenLP instance, mocked screens and settings for a valid window position
# mock out some other calls in load_settings()
main_window.control_splitter = MagicMock()
main_window._live_controller = MagicMock()
main_window._preview_controller = MagicMock()
main_window.settings.setValue('core/view mode', 'default')
main_window.settings.setValue('user interface/is preset layout', False)
main_window.settings.setValue('user interface/live panel', False)
# WHENL we call to show method
main_window.show()
# THEN:
# The default mode should have been called.
mocked_view_mode.assert_called_with(True, True, True, True, False, True)