From c9680a40dc8be7bafa5d7e7256cf4866a1bd15cc Mon Sep 17 00:00:00 2001 From: suutari-olli Date: Fri, 29 Apr 2016 01:20:42 +0300 Subject: [PATCH] Added a setting for automatically resetting the Quick search type to "Combined" on startup. This setting is by default enabled. (I Feel like some users may get confused if their search has changed to Text or Reference) --- openlp/plugins/bibles/bibleplugin.py | 3 ++- openlp/plugins/bibles/lib/biblestab.py | 27 +++++++++++++++++++++----- openlp/plugins/bibles/lib/mediaitem.py | 8 ++++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index eb35e298e..509173d7b 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -41,7 +41,8 @@ __default_settings__ = { 'bibles/db password': '', 'bibles/db hostname': '', 'bibles/db database': '', - 'bibles/last search type': BibleSearch.Reference, + 'bibles/last search type': BibleSearch.Combined, + 'bibles/reset to combined quick search': True, 'bibles/verse layout style': LayoutStyle.VersePerSlide, 'bibles/book name language': LanguageSelection.Bible, 'bibles/display brackets': DisplayStyle.NoBrackets, diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 6ca411ec7..0b465e03f 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -131,10 +131,13 @@ class BiblesTab(SettingsTab): self.bible_search_settings_group_box = QtWidgets.QGroupBox(self.right_column) self.bible_search_settings_group_box.setObjectName('bible_search_settings_group_box') self.right_layout.addWidget(self.bible_search_settings_group_box) - self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) - self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout = QtWidgets.QFormLayout(self.bible_search_settings_group_box) self.search_settings_layout.setObjectName('search_settings_layout') + self.reset_to_combined_quick_search_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.reset_to_combined_quick_search_check_box.setObjectName('reset_to_combined_quick_search_check_box') + self.search_settings_layout.addRow(self.reset_to_combined_quick_search_check_box) + self.hide_combined_quick_error_check_box = QtWidgets.QCheckBox(self.bible_search_settings_group_box) + self.hide_combined_quick_error_check_box.setObjectName('hide_combined_quick_error_check_box') self.search_settings_layout.addRow(self.hide_combined_quick_error_check_box) self.left_layout.addStretch() self.right_layout.addStretch() @@ -159,6 +162,8 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.editingFinished.connect(self.on_end_separator_line_edit_finished) Registry().register_function('theme_update_list', self.update_theme_list) self.language_selection_combo_box.activated.connect(self.on_language_selection_combo_box_changed) + self.reset_to_combined_quick_search_check_box.stateChanged.connect \ + (self.on_reset_to_combined_quick_search_check_box_changed) self.hide_combined_quick_error_check_box.stateChanged.connect\ (self.on_hide_combined_quick_error_check_box_changed) @@ -205,9 +210,12 @@ class BiblesTab(SettingsTab): self.language_selection_combo_box.setItemText( LanguageSelection.English, translate('BiblesPlugin.BiblesTab', 'English')) self.bible_search_settings_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Search Settings')) - self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Don\'t show error ' - 'for no results in ' - 'combined quick search')) + self.reset_to_combined_quick_search_check_box.setText(translate('BiblesPlugin.BiblesTab', + 'Reset quick search type to "Combined" ' + 'on startup')) + self.hide_combined_quick_error_check_box.setText(translate('BiblesPlugin.BiblesTab', + 'Don\'t show error for no results in combined ' + 'quick search')) def on_bible_theme_combo_box_changed(self): self.bible_theme = self.bible_theme_combo_box.currentText() @@ -316,6 +324,12 @@ class BiblesTab(SettingsTab): self.end_separator_line_edit.setText(get_reference_separator('sep_e_default')) self.end_separator_line_edit.setPalette(self.get_grey_text_palette(True)) + def on_reset_to_combined_quick_search_check_box_changed(self, check_state): + """ + Event handler for the 'hide_combined_quick_error' check box + """ + self.reset_to_combined_quick_search = (check_state == QtCore.Qt.Checked) + def on_hide_combined_quick_error_check_box_changed(self, check_state): """ Event handler for the 'hide_combined_quick_error' check box @@ -375,6 +389,8 @@ class BiblesTab(SettingsTab): self.end_separator_check_box.setChecked(True) self.language_selection = settings.value('book name language') self.language_selection_combo_box.setCurrentIndex(self.language_selection) + self.reset_to_combined_quick_search = settings.value('reset to combined quick search') + self.reset_to_combined_quick_search_check_box.setChecked(self.reset_to_combined_quick_search) self.hide_combined_quick_error = settings.value('hide combined quick error') self.hide_combined_quick_error_check_box.setChecked(self.hide_combined_quick_error) settings.endGroup() @@ -408,6 +424,7 @@ class BiblesTab(SettingsTab): if self.language_selection != settings.value('book name language'): settings.setValue('book name language', self.language_selection) self.settings_form.register_post_process('bibles_load_list') + settings.setValue('reset to combined quick search', self.reset_to_combined_quick_search) settings.setValue('hide combined quick error', self.hide_combined_quick_error) settings.endGroup() if self.tab_visited: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 39df59b30..cba08d4c9 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -430,8 +430,12 @@ class BibleMediaItem(MediaManagerItem): only updated when we are doing reference or combined search, in text search the completion list is removed. """ log.debug('update_auto_completer') - # Save the current search type to the configuration. - Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) + # Save the current search type to the configuration. If setting for automatically resetting the search type to + # Combined is enabled, use that otherwise use the currently selected search type. + if Settings().value(self.settings_section + '/reset to combined quick search'): + Settings().setValue('%s/last search type' % self.settings_section, BibleSearch.Combined) + else: + Settings().setValue('%s/last search type' % self.settings_section, self.quick_search_edit.current_search_type()) # Save the current bible to the configuration. Settings().setValue(self.settings_section + '/quick bible', self.quickVersionComboBox.currentText()) books = []