Fix #2018630 [Menu item duplication glitch](https://bugs.launchpad.net/calibre/+bug/2018630)
This commit is contained in:
Kovid Goyal 2023-05-06 16:51:47 +05:30
commit 9f5244da9e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 41 additions and 11 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

@ -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

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">