Enhancement: add preference (in Search) to disable QTableView keyboardSearch().

This commit is contained in:
Charles Haley 2023-05-06 12:20:23 +01:00
parent cc7e2d7662
commit bbd11ff153
4 changed files with 20 additions and 0 deletions

View File

@ -398,6 +398,7 @@ def create_defs():
# JSON dumps converts integer keys to strings, so do it explicitly
defs['tb_search_order'] = {'0': 1, '1': 2, '2': 3, '3': 4, '4': 0}
defs['search_tool_bar_shows_text'] = True
defs['allow_keyboard_search_in_library_views'] = True
def migrate_tweak(tweak_name, pref_name):
# If the tweak has been changed then leave the tweak in the file so

View File

@ -756,6 +756,10 @@ class BooksView(QTableView): # {{{
gprefs[pname] = previous
self.sort_by_named_field(field, previous[field])
def keyboardSearch(self, search):
if gprefs.get('allow_keyboard_search_in_library_views', True):
super().keyboardSearch(search)
def sort_by_named_field(self, field, order, reset=True):
if isinstance(order, Qt.SortOrder):
order = order == Qt.SortOrder.AscendingOrder

View File

@ -33,6 +33,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
r('limit_search_columns', prefs)
r('use_primary_find_in_search', prefs)
r('search_tool_bar_shows_text', gprefs)
r('allow_keyboard_search_in_library_views', gprefs)
ossm = self.opt_saved_search_menu_is_hierarchical
ossm.setChecked('search' in db.new_api.pref('categories_using_hierarchy', []))
ossm.stateChanged.connect(self.changed_signal)

View File

@ -160,6 +160,20 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="opt_allow_keyboard_search_in_library_views">
<property name="text">
<string>Use keyboard searching in the book list</string>
</property>
<property name="toolTip">
<string>&lt;p&gt;If enabled then pressing a key in the library view
will search for the next cell in the current column where the
value starts with the letter pressed. If there is no such cell
then nothing happens. If the letter is a shortcut then the
shortcut takes precedence.&lt;/p&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">