forked from openlp/openlp
HEAD
This commit is contained in:
commit
00455847a7
@ -96,9 +96,21 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties):
|
|||||||
Process the form saving the settings
|
Process the form saving the settings
|
||||||
"""
|
"""
|
||||||
log.debug('Processing settings exit')
|
log.debug('Processing settings exit')
|
||||||
for tabIndex in range(self.stacked_layout.count()):
|
# We add all the forms into the stacked layout, even if the plugin is inactive,
|
||||||
self.stacked_layout.widget(tabIndex).save()
|
# but we don't add the item to the list on the side if the plugin is inactive,
|
||||||
# if the display of image background are changing we need to regenerate the image cache
|
# so loop through the list items, and then find the tab for that item.
|
||||||
|
for item_index in range(self.setting_list_widget.count()):
|
||||||
|
# Get the list item
|
||||||
|
list_item = self.setting_list_widget.item(item_index)
|
||||||
|
if not list_item:
|
||||||
|
continue
|
||||||
|
# Now figure out if there's a tab for it, and save the tab.
|
||||||
|
plugin_name = list_item.data(QtCore.Qt.UserRole)
|
||||||
|
for tab_index in range(self.stacked_layout.count()):
|
||||||
|
tab_widget = self.stacked_layout.widget(tab_index)
|
||||||
|
if tab_widget.tab_title == plugin_name:
|
||||||
|
tab_widget.save()
|
||||||
|
# if the image background has been changed we need to regenerate the image cache
|
||||||
if 'images_config_updated' in self.processes or 'config_screen_changed' in self.processes:
|
if 'images_config_updated' in self.processes or 'config_screen_changed' in self.processes:
|
||||||
self.register_post_process('images_regenerate')
|
self.register_post_process('images_regenerate')
|
||||||
# Now lets process all the post save handlers
|
# Now lets process all the post save handlers
|
||||||
|
@ -84,6 +84,34 @@ class TestSettingsForm(TestCase):
|
|||||||
mocked_add_widget.assert_called_with(general_tab)
|
mocked_add_widget.assert_called_with(general_tab)
|
||||||
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
|
self.assertEqual(0, mocked_add_item.call_count, 'addItem should not have been called')
|
||||||
|
|
||||||
|
def accept_with_inactive_plugins_test(self):
|
||||||
|
"""
|
||||||
|
Test that the accept() method works correctly when some of the plugins are inactive
|
||||||
|
"""
|
||||||
|
# GIVEN: A visible general tab and an invisible theme tab in a Settings Form
|
||||||
|
settings_form = SettingsForm(None)
|
||||||
|
general_tab = QtGui.QWidget(None)
|
||||||
|
general_tab.tab_title = 'mock-general'
|
||||||
|
general_tab.tab_title_visible = 'Mock General'
|
||||||
|
general_tab.icon_path = ':/icon/openlp-logo-16x16.png'
|
||||||
|
mocked_general_save = MagicMock()
|
||||||
|
general_tab.save = mocked_general_save
|
||||||
|
settings_form.insert_tab(general_tab, is_visible=True)
|
||||||
|
themes_tab = QtGui.QWidget(None)
|
||||||
|
themes_tab.tab_title = 'mock-themes'
|
||||||
|
themes_tab.tab_title_visible = 'Mock Themes'
|
||||||
|
themes_tab.icon_path = ':/icon/openlp-logo-16x16.png'
|
||||||
|
mocked_theme_save = MagicMock()
|
||||||
|
themes_tab.save = mocked_theme_save
|
||||||
|
settings_form.insert_tab(themes_tab, is_visible=False)
|
||||||
|
|
||||||
|
# WHEN: The accept() method is called
|
||||||
|
settings_form.accept()
|
||||||
|
|
||||||
|
# THEN: The general tab's save() method should have been called, but not the themes tab
|
||||||
|
mocked_general_save.assert_called_with()
|
||||||
|
self.assertEqual(0, mocked_theme_save.call_count, 'The Themes tab\'s save() should not have been called')
|
||||||
|
|
||||||
def list_item_changed_invalid_item_test(self):
|
def list_item_changed_invalid_item_test(self):
|
||||||
"""
|
"""
|
||||||
Test that the list_item_changed() slot handles a non-existent item
|
Test that the list_item_changed() slot handles a non-existent item
|
||||||
|
Loading…
Reference in New Issue
Block a user