From 26e8dde0ea73bbf8a08228bc1ade29fe36a30e63 Mon Sep 17 00:00:00 2001 From: Ian Knight Date: Sat, 16 Apr 2016 16:30:48 +0930 Subject: [PATCH] Implemented feature, cleaned pep8 errors --- openlp/core/common/settings.py | 2 +- openlp/core/ui/advancedtab.py | 42 ++++++++++++------- .../openlp_core_ui/test_listpreviewwidget.py | 16 +++---- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index ad6e812c4..28e087f15 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -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', diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 2724ec489..ac68b7add 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -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')) diff --git a/tests/functional/openlp_core_ui/test_listpreviewwidget.py b/tests/functional/openlp_core_ui/test_listpreviewwidget.py index 4260711fa..dd6f80b0a 100644 --- a/tests/functional/openlp_core_ui/test_listpreviewwidget.py +++ b/tests/functional/openlp_core_ui/test_listpreviewwidget.py @@ -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