Implemented feature, cleaned pep8 errors

This commit is contained in:
Ian Knight 2016-04-16 16:30:48 +09:30
parent 17d9bf0adc
commit 26e8dde0ea
3 changed files with 36 additions and 24 deletions

View File

@ -107,7 +107,7 @@ class Settings(QtCore.QSettings):
__default_settings__ = {
'advanced/add page break': False,
'advanced/alternate rows': not is_win(),
'advanced/autoscrolling': {'dist':1, 'pos':0},
'advanced/autoscrolling': {'dist': 1, 'pos': 0},
'advanced/current media plugin': -1,
'advanced/data path': '',
'advanced/default color': '#ffffff',

View File

@ -49,9 +49,10 @@ class AdvancedTab(SettingsTab):
self.default_color = '#ffffff'
self.data_exists = False
self.icon_path = ':/system/system_settings.png'
self.autoscroll_map = [None, {'dist':-1, 'pos':0}, {'dist':-1, 'pos':1}, {'dist':-1, 'pos':2},
{'dist':0, 'pos':0}, {'dist':0, 'pos':1}, {'dist':0, 'pos':2}, {'dist':0, 'pos':3},
{'dist':1, 'pos':0}, {'dist':1, 'pos':1}, {'dist':1, 'pos':2}, {'dist':1, 'pos':3}]
self.autoscroll_map = [None, {'dist': -1, 'pos': 0}, {'dist': -1, 'pos': 1}, {'dist': -1, 'pos': 2},
{'dist': 0, 'pos': 0}, {'dist': 0, 'pos': 1}, {'dist': 0, 'pos': 2},
{'dist': 0, 'pos': 3}, {'dist': 1, 'pos': 0}, {'dist': 1, 'pos': 1},
{'dist': 1, 'pos': 2}, {'dist': 1, 'pos': 3}]
advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced')
super(AdvancedTab, self).__init__(parent, 'Advanced', advanced_translated)
@ -298,19 +299,30 @@ class AdvancedTab(SettingsTab):
'Max height for non-text slides\nin slide controller:'))
self.slide_max_height_spin_box.setSpecialValueText(translate('OpenLP.AdvancedTab', 'Disabled'))
self.autoscroll_label.setText(translate('OpenLP.AdvancedTab',
'When changing slides:'))
'When changing slides:'))
self.autoscroll_combo_box.setItemText(0, translate('OpenLP.AdvancedTab', 'Do not auto-scroll'))
self.autoscroll_combo_box.setItemText(1, translate('OpenLP.AdvancedTab', 'Auto-scroll the previous slide into view'))
self.autoscroll_combo_box.setItemText(2, translate('OpenLP.AdvancedTab', 'Auto-scroll the previous slide to top'))
self.autoscroll_combo_box.setItemText(3, translate('OpenLP.AdvancedTab', 'Auto-scroll the previous slide to middle'))
self.autoscroll_combo_box.setItemText(4, translate('OpenLP.AdvancedTab', 'Auto-scroll the current slide into view'))
self.autoscroll_combo_box.setItemText(5, translate('OpenLP.AdvancedTab', 'Auto-scroll the current slide to top'))
self.autoscroll_combo_box.setItemText(6, translate('OpenLP.AdvancedTab', 'Auto-scroll the current slide to middle'))
self.autoscroll_combo_box.setItemText(7, translate('OpenLP.AdvancedTab', 'Auto-scroll the current slide to bottom'))
self.autoscroll_combo_box.setItemText(8, translate('OpenLP.AdvancedTab', 'Auto-scroll the next slide into view'))
self.autoscroll_combo_box.setItemText(9, translate('OpenLP.AdvancedTab', 'Auto-scroll the next slide to top'))
self.autoscroll_combo_box.setItemText(10, translate('OpenLP.AdvancedTab', 'Auto-scroll the next slide to middle'))
self.autoscroll_combo_box.setItemText(11, translate('OpenLP.AdvancedTab', 'Auto-scroll the next slide to bottom'))
self.autoscroll_combo_box.setItemText(1, translate('OpenLP.AdvancedTab',
'Auto-scroll the previous slide into view'))
self.autoscroll_combo_box.setItemText(2, translate('OpenLP.AdvancedTab',
'Auto-scroll the previous slide to top'))
self.autoscroll_combo_box.setItemText(3, translate('OpenLP.AdvancedTab',
'Auto-scroll the previous slide to middle'))
self.autoscroll_combo_box.setItemText(4, translate('OpenLP.AdvancedTab',
'Auto-scroll the current slide into view'))
self.autoscroll_combo_box.setItemText(5, translate('OpenLP.AdvancedTab',
'Auto-scroll the current slide to top'))
self.autoscroll_combo_box.setItemText(6, translate('OpenLP.AdvancedTab',
'Auto-scroll the current slide to middle'))
self.autoscroll_combo_box.setItemText(7, translate('OpenLP.AdvancedTab',
'Auto-scroll the current slide to bottom'))
self.autoscroll_combo_box.setItemText(8, translate('OpenLP.AdvancedTab',
'Auto-scroll the next slide into view'))
self.autoscroll_combo_box.setItemText(9, translate('OpenLP.AdvancedTab',
'Auto-scroll the next slide to top'))
self.autoscroll_combo_box.setItemText(10, translate('OpenLP.AdvancedTab',
'Auto-scroll the next slide to middle'))
self.autoscroll_combo_box.setItemText(11, translate('OpenLP.AdvancedTab',
'Auto-scroll the next slide to bottom'))
self.enable_auto_close_check_box.setText(translate('OpenLP.AdvancedTab',
'Enable application exit confirmation'))
self.service_name_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Default Service Name'))

View File

@ -295,9 +295,9 @@ class TestListPreviewWidget(TestCase):
list_preview_widget.change_slide(0)
self.mocked_Settings_obj.value.return_value = 1
list_preview_widget.change_slide(0)
self.mocked_Settings_obj.value.return_value = {'test':1}
self.mocked_Settings_obj.value.return_value = {'test': 1}
list_preview_widget.change_slide(0)
self.mocked_Settings_obj.value.return_value = {'dist':1, 'test':1}
self.mocked_Settings_obj.value.return_value = {'dist': 1, 'test': 1}
list_preview_widget.change_slide(0)
# THEN: no further functions should be called
@ -305,7 +305,7 @@ class TestListPreviewWidget(TestCase):
self.assertEquals(mocked_item.call_count, 0, 'Should not be called')
self.assertEquals(mocked_scrollToItem.call_count, 0, 'Should not be called')
self.assertEquals(mocked_selectRow.call_count, 0, 'Should not be called')
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.selectRow')
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.scrollToItem')
@patch(u'openlp.core.ui.listpreviewwidget.ListPreviewWidget.item')
@ -316,7 +316,7 @@ class TestListPreviewWidget(TestCase):
"""
# GIVEN: A setting for autoscrolling and a ListPreviewWidget.
# Mock Settings().value('advanced/autoscrolling')
self.mocked_Settings_obj.value.return_value = {'dist':-1, 'pos':1}
self.mocked_Settings_obj.value.return_value = {'dist': -1, 'pos': 1}
# Mocked returns
mocked_slide_count.return_value = 1
mocked_item.return_value = None
@ -325,7 +325,7 @@ class TestListPreviewWidget(TestCase):
# WHEN: change_slide() is called
list_preview_widget.change_slide(0)
self.mocked_Settings_obj.value.return_value = {'dist':1, 'pos':1}
self.mocked_Settings_obj.value.return_value = {'dist': 1, 'pos': 1}
list_preview_widget.change_slide(0)
# THEN: no further functions should be called
@ -345,7 +345,7 @@ class TestListPreviewWidget(TestCase):
"""
# GIVEN: A setting for autoscrolling and a ListPreviewWidget.
# Mock Settings().value('advanced/autoscrolling')
self.mocked_Settings_obj.value.return_value = {'dist':-1, 'pos':1}
self.mocked_Settings_obj.value.return_value = {'dist': -1, 'pos': 1}
# Mocked returns
mocked_slide_count.return_value = 3
mocked_item.return_value = None
@ -354,9 +354,9 @@ class TestListPreviewWidget(TestCase):
# WHEN: change_slide() is called
list_preview_widget.change_slide(1)
self.mocked_Settings_obj.value.return_value = {'dist':0, 'pos':1}
self.mocked_Settings_obj.value.return_value = {'dist': 0, 'pos': 1}
list_preview_widget.change_slide(1)
self.mocked_Settings_obj.value.return_value = {'dist':1, 'pos':1}
self.mocked_Settings_obj.value.return_value = {'dist': 1, 'pos': 1}
list_preview_widget.change_slide(1)
# THEN: no further functions should be called