diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py
index 768312bd1b..89754a0245 100644
--- a/src/calibre/gui2/__init__.py
+++ b/src/calibre/gui2/__init__.py
@@ -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
diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py
index 31598cd3e5..4199a044f9 100644
--- a/src/calibre/gui2/library/views.py
+++ b/src/calibre/gui2/library/views.py
@@ -680,23 +680,33 @@ class BooksView(QTableView): # {{{
view.column_header_context_menu = self.create_context_menu(col, name, view)
has_context_menu = hasattr(view, 'column_header_context_menu')
if self.is_library_view and has_context_menu:
- view.column_header_context_menu.addSeparator()
- if not hasattr(view.column_header_context_menu, 'bl_split_action'):
- view.column_header_context_menu.bl_split_action = view.column_header_context_menu.addAction(
- QIcon.ic('split.png'), 'xxx', partial(self.column_header_context_handler, action='split', column='title'))
- ac = view.column_header_context_menu.bl_split_action
+ m = view.column_header_context_menu
+ m.addSeparator()
+ if not hasattr(m, 'bl_split_action'):
+ m.bl_split_action = m.addAction(QIcon.ic('split.png'), 'xxx',
+ partial(self.column_header_context_handler, action='split', column='title'))
+ ac = m.bl_split_action
if self.pin_view.isVisible():
ac.setText(_('Un-split the book list'))
else:
ac.setText(_('Split the book list'))
+ # QIcon.ic('drm-locked.png'),
+ if not hasattr(m, 'column_mouse_move_action'):
+ m.column_mouse_move_action = m.addAction('xxx')
+
+ def set_action_attributes(icon, text, slot):
+ m.column_mouse_move_action.setText(text)
+ m.column_mouse_move_action.setIcon(icon)
+ m.column_mouse_move_action.triggered.connect(slot)
+
if view.column_header.sectionsMovable():
- view.column_header_context_menu.addAction(
- QIcon.ic('drm-locked.png'), _("Don't allow moving columns with the mouse"),
- partial(self.column_header_context_handler, action='lock'))
+ set_action_attributes(QIcon.ic('drm-locked.png'),
+ _("Don't allow moving columns with the mouse"),
+ partial(self.column_header_context_handler, action='lock'))
else:
- view.column_header_context_menu.addAction(
- QIcon.ic('drm-unlocked.png'), _("Allow moving columns with the mouse"),
- partial(self.column_header_context_handler, action='unlock'))
+ set_action_attributes(QIcon.ic('drm-unlocked.png'),
+ _("Allow moving columns with the mouse"),
+ partial(self.column_header_context_handler, action='unlock'))
if has_context_menu:
view.column_header_context_menu.popup(view.column_header.mapToGlobal(pos))
# }}}
@@ -746,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
diff --git a/src/calibre/gui2/preferences/search.py b/src/calibre/gui2/preferences/search.py
index 2899861a2a..961c7cc1a6 100644
--- a/src/calibre/gui2/preferences/search.py
+++ b/src/calibre/gui2/preferences/search.py
@@ -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)
diff --git a/src/calibre/gui2/preferences/search.ui b/src/calibre/gui2/preferences/search.ui
index a646297174..e2f6bd99db 100644
--- a/src/calibre/gui2/preferences/search.ui
+++ b/src/calibre/gui2/preferences/search.ui
@@ -160,6 +160,20 @@
+ -
+
+
+ Use keyboard searching in the book list
+
+
+ <p>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.</p>
+
+
+