Fix Projector Manager dock so View->Lock Panels will lock/unlock the UI features

bzr-revno: 2445
This commit is contained in:
Ken Roberts 2014-11-09 13:20:09 +00:00 committed by Tim Bentley
commit 3fa0635d79
2 changed files with 38 additions and 6 deletions

View File

@ -641,10 +641,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
if view_mode == 'default':
self.mode_default_item.setChecked(True)
elif view_mode == 'setup':
self.set_view_mode(True, True, False, True, False)
self.set_view_mode(True, True, False, True, False, True)
self.mode_setup_item.setChecked(True)
elif view_mode == 'live':
self.set_view_mode(False, True, False, False, True)
self.set_view_mode(False, True, False, False, True, True)
self.mode_live_item.setChecked(True)
def app_startup(self):
@ -1000,21 +1000,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
"""
Put OpenLP into "Default" view mode.
"""
self.set_view_mode(True, True, True, True, True, 'default')
self.set_view_mode(True, True, True, True, True, True, 'default')
def on_mode_setup_item_clicked(self):
"""
Put OpenLP into "Setup" view mode.
"""
self.set_view_mode(True, True, False, True, False, 'setup')
self.set_view_mode(True, True, False, True, False, True, 'setup')
def on_mode_live_item_clicked(self):
"""
Put OpenLP into "Live" view mode.
"""
self.set_view_mode(False, True, False, False, True, 'live')
self.set_view_mode(False, True, False, False, True, True, 'live')
def set_view_mode(self, media=True, service=True, theme=True, preview=True, live=True, mode=''):
def set_view_mode(self, media=True, service=True, theme=True, preview=True, live=True, projector=True, mode=''):
"""
Set OpenLP to a different view mode.
"""
@ -1024,6 +1024,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
self.media_manager_dock.setVisible(media)
self.service_manager_dock.setVisible(service)
self.theme_manager_dock.setVisible(theme)
self.projector_manager_dock.setVisible(projector)
self.set_preview_panel_visibility(preview)
self.set_live_panel_visibility(live)
@ -1186,18 +1187,22 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
self.theme_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
self.service_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
self.media_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
self.projector_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures)
self.view_media_manager_item.setEnabled(False)
self.view_service_manager_item.setEnabled(False)
self.view_theme_manager_item.setEnabled(False)
self.view_projector_manager_item.setEnabled(False)
self.view_preview_panel.setEnabled(False)
self.view_live_panel.setEnabled(False)
else:
self.theme_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures)
self.service_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures)
self.media_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures)
self.projector_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures)
self.view_media_manager_item.setEnabled(True)
self.view_service_manager_item.setEnabled(True)
self.view_theme_manager_item.setEnabled(True)
self.view_projector_manager_item.setEnabled(True)
self.view_preview_panel.setEnabled(True)
self.view_live_panel.setEnabled(True)
Settings().setValue('user interface/lock panel', lock)

View File

@ -62,6 +62,7 @@ class TestMainWindow(TestCase, TestMixin):
patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \
patch('openlp.core.ui.mainwindow.ServiceManager') as mocked_service_manager, \
patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \
patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
self.main_window = MainWindow()
@ -85,3 +86,29 @@ class TestMainWindow(TestCase, TestMixin):
# THEN: The current widget should have been set.
self.main_window.media_tool_box.setCurrentIndex.assert_called_with(2)
def projector_manager_dock_locked_test(self):
"""
Projector Manager enable UI options - bug #1390702
"""
# GIVEN: A mocked projector manager dock item:
projector_dock = self.main_window.projector_manager_dock
# WHEN: main_window.lock_panel action is triggered
self.main_window.lock_panel.triggered.emit(True)
# THEN: Projector manager dock should have been called with disable UI features
projector_dock.setFeatures.assert_called_with(0)
def projector_manager_dock_unlocked_test(self):
"""
Projector Manager disable UI options - bug #1390702
"""
# GIVEN: A mocked projector manager dock item:
projector_dock = self.main_window.projector_manager_dock
# WHEN: main_window.lock_panel action is triggered
self.main_window.lock_panel.triggered.emit(False)
# THEN: Projector manager dock should have been called with enable UI features
projector_dock.setFeatures.assert_called_with(7)