Only show the Sort button on the search bar if the Sort By action has not been added to the search bar by the user. Fixes #2138770 [[Enhancement] Sort By - List view](https://bugs.launchpad.net/calibre/+bug/2138770)

This commit is contained in:
Kovid Goyal 2026-01-21 09:36:04 +05:30
parent 3e69c33552
commit 6c63a1fa3e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 10 additions and 1 deletions

View File

@ -650,6 +650,7 @@ class SearchToolBar(QHBoxLayout):
QHBoxLayout.__init__(self)
self.search_tool_bar_widgets = []
self.gui = gui
self.has_sort_by_button = False
self.donate_button = None
def init_bar(self, actions):
@ -661,6 +662,7 @@ class SearchToolBar(QHBoxLayout):
self.search_tool_bar_widgets = []
self.search_tool_bar_actions = []
self.has_sort_by_button = False
for what in gprefs['action-layout-searchbar']:
if what is None:
frame = QFrame()
@ -672,6 +674,8 @@ class SearchToolBar(QHBoxLayout):
self.search_tool_bar_widgets.append(frame)
self.search_tool_bar_actions.append(None)
elif what in self.gui.iactions:
if what == 'Sort By':
self.has_sort_by_button = True
act = self.gui.iactions[what]
qact = act.qaction
tb = RightClickButton()

View File

@ -298,7 +298,7 @@ class AlternateViewsButtons(LayoutButton): # {{{
if btn.isChecked():
btn.update_state(False)
self.gui.library_view.alternate_views.show_view(self.view_name if show else None)
self.gui.sort_button.setVisible(show)
self.gui.show_sort_button_for_alternate_view(show)
self.gui.group_by_button.setVisible(self.needs_group_by and show)
AlternateViewsButtons.ignore_toggles = False
# }}}

View File

@ -399,4 +399,9 @@ class MainWindowMixin: # {{{
smw.setText(_('<h2>Shutting down</h2><div>') + message)
# Force processing the events needed to show the message
QCoreApplication.processEvents()
def show_sort_button_for_alternate_view(self, show: bool = True) -> None:
if self.bars_manager.search_tool_bar.has_sort_by_button:
show = False
self.sort_button.setVisible(show)
# }}}