mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
f810bb7974
@ -2,6 +2,8 @@
|
||||
# License: GPLv3 Copyright: 2022, Charles Haley
|
||||
#
|
||||
|
||||
from qt.core import QToolButton
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
|
||||
@ -11,6 +13,7 @@ class BooklistContextMenuAction(InterfaceAction):
|
||||
action_spec = (_('Book list header menu'), 'context_menu.png',
|
||||
_('Show the book list header context menu'), None)
|
||||
action_type = 'current'
|
||||
popup_type = QToolButton.ToolButtonPopupMode.InstantPopup
|
||||
action_add_menu = False
|
||||
dont_add_to = frozenset(['context-menu-device', 'menubar-device'])
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
# License: GPLv3 Copyright: 2022, Charles Haley
|
||||
#
|
||||
|
||||
from qt.core import QMenu, QToolButton
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
|
||||
@ -9,20 +11,30 @@ class ManageCategoriesAction(InterfaceAction):
|
||||
|
||||
name = 'Manage categories'
|
||||
action_spec = (_('Manage categories'), 'tags.png',
|
||||
_('Manage categories: authors, tags, series, etc.'), ())
|
||||
_('Manage categories: authors, tags, series, etc.'), None)
|
||||
action_type = 'current'
|
||||
popup_type = QToolButton.ToolButtonPopupMode.InstantPopup
|
||||
action_add_menu = True
|
||||
dont_add_to = frozenset(['context-menu-device', 'menubar-device'])
|
||||
|
||||
def genesis(self):
|
||||
self.menu = m = self.qaction.menu()
|
||||
self.qaction.triggered.connect(self.show_menu)
|
||||
m.aboutToShow.connect(self.about_to_show_menu)
|
||||
|
||||
# We want to show the menu when a toolbar button is clicked. Apparently
|
||||
# the only way to do that is to scan the toolbar(s) for the action button
|
||||
# then exec the associated menu. The search is done here to take adding and
|
||||
# removing the action from toolbars into account.
|
||||
# Create a "hidden" menu that can have a shortcut.
|
||||
self.hidden_menu = QMenu()
|
||||
self.shortcut_action = self.create_menu_action(
|
||||
menu=self.hidden_menu,
|
||||
unique_name=_('Manage categories'),
|
||||
text=_('Manage categories: authors, tags, series, etc.'),
|
||||
icon='tags.png',
|
||||
triggered=self.show_menu)
|
||||
|
||||
|
||||
# We want to show the menu when a shortcut is used. Apparently the only way
|
||||
# to do that is to scan the toolbar(s) for the action button then exec the
|
||||
# associated menu. The search is done here to take adding and removing the
|
||||
# action from toolbars into account.
|
||||
#
|
||||
# If a shortcut is triggered and there isn't a toolbar button visible then
|
||||
# show the menu in the upper left corner of the library view pane. Yes, this
|
||||
|
@ -2,7 +2,7 @@
|
||||
# License: GPLv3 Copyright: 2022, Charles Haley
|
||||
#
|
||||
|
||||
from qt.core import QPoint
|
||||
from qt.core import QPoint, QMenu, QToolButton
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
@ -57,20 +57,29 @@ class SavedSearchesAction(InterfaceAction):
|
||||
|
||||
name = 'Saved searches'
|
||||
action_spec = (_('Saved searches'), 'folder_saved_search.png',
|
||||
_('Show a menu of saved searches'), ())
|
||||
_('Show a menu of saved searches'), None)
|
||||
action_type = 'current'
|
||||
popup_type = QToolButton.ToolButtonPopupMode.InstantPopup
|
||||
action_add_menu = True
|
||||
dont_add_to = frozenset(('context-menu-device', 'menubar-device'))
|
||||
|
||||
def genesis(self):
|
||||
self.menu = m = self.qaction.menu()
|
||||
self.qaction.triggered.connect(self.show_menu)
|
||||
m.aboutToShow.connect(self.about_to_show_menu)
|
||||
|
||||
# We want to show the menu when a toolbar button is clicked. Apparently
|
||||
# the only way to do that is to scan the toolbar(s) for the action button
|
||||
# then exec the associated menu. The search is done here to take adding and
|
||||
# removing the action from toolbars into account.
|
||||
# Create a "hidden" menu that can have a shortcut.
|
||||
self.hidden_menu = QMenu()
|
||||
self.shortcut_action = self.create_menu_action(
|
||||
menu=self.hidden_menu,
|
||||
unique_name=_('Saved searches'),
|
||||
text=_('Show a menu of saved searches'),
|
||||
icon='folder_saved_search.png',
|
||||
triggered=self.show_menu)
|
||||
|
||||
# We want to show the menu when a shortcut is used. Apparently the only way
|
||||
# to do that is to scan the toolbar(s) for the action button then exec the
|
||||
# associated menu. The search is done here to take adding and removing the
|
||||
# action from toolbars into account.
|
||||
#
|
||||
# If a shortcut is triggered and there isn't a toolbar button visible then
|
||||
# show the menu in the upper left corner of the library view pane. Yes, this
|
||||
|
@ -15,7 +15,7 @@ from calibre.constants import ismacos
|
||||
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
||||
from calibre.gui2.throbber import ThrobbingButton
|
||||
from polyglot.builtins import itervalues
|
||||
|
||||
from calibre.gui2.widgets2 import RightClickButton
|
||||
|
||||
class RevealBar(QWidget): # {{{
|
||||
|
||||
@ -679,7 +679,7 @@ class BarsManager(QObject):
|
||||
for ac in self.search_tool_bar_actions:
|
||||
self.search_tool_bar.removeWidget(ac)
|
||||
|
||||
self.search_tool_bar.setContentsMargins(0, 0, 0, 0)
|
||||
self.search_tool_bar.setContentsMargins(0, 0, 10, 0)
|
||||
self.search_tool_bar.setSpacing(0)
|
||||
|
||||
self.search_tool_bar_actions = []
|
||||
@ -693,8 +693,10 @@ class BarsManager(QObject):
|
||||
self.search_tool_bar.addWidget(frame)
|
||||
self.search_tool_bar_actions.append(frame)
|
||||
elif what in self.parent().iactions:
|
||||
qact = self.parent().iactions[what].qaction
|
||||
tb = QToolButton()
|
||||
act = self.parent().iactions[what]
|
||||
qact = act.qaction
|
||||
tb = RightClickButton()
|
||||
tb.menu = qact.menu
|
||||
tb.setContentsMargins(0, 0, 0, 0)
|
||||
tb.setDefaultAction(qact)
|
||||
if not gprefs['search_tool_bar_shows_text']:
|
||||
@ -702,7 +704,7 @@ class BarsManager(QObject):
|
||||
else:
|
||||
tb.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
tb.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
tb.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
tb.setPopupMode(act.popup_type)
|
||||
tb.setAutoRaise(True)
|
||||
self.search_tool_bar.addWidget(tb)
|
||||
self.search_tool_bar_actions.append(tb)
|
||||
|
@ -238,6 +238,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
def refresh_gui(self, gui):
|
||||
gui.refresh_search_bar_widgets()
|
||||
self.gui.bars_manager.update_bars()
|
||||
gui.current_db.new_api.clear_caches()
|
||||
set_use_primary_find_in_search(prefs['use_primary_find_in_search'])
|
||||
gui.set_highlight_only_button_icon()
|
||||
|
@ -641,7 +641,6 @@ class SearchRestrictionMixin:
|
||||
self._apply_search_restriction('', '')
|
||||
|
||||
def _apply_search_restriction(self, restriction, name):
|
||||
self.saved_search.clear()
|
||||
# The order below is important. Set the restriction, force a '' search
|
||||
# to apply it, reset the tag browser to take it into account, then set
|
||||
# the book count.
|
||||
|
Loading…
x
Reference in New Issue
Block a user