mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Remove calibre-level action for quickview focus. Small improvements in focus handling and item selection.
This commit is contained in:
parent
61749bd646
commit
365ca8db9d
@ -834,11 +834,6 @@ class ActionQuickview(InterfaceActionBase):
|
||||
actual_plugin = 'calibre.gui2.actions.show_quickview:ShowQuickviewAction'
|
||||
description = _('Show a list of related books quickly')
|
||||
|
||||
class ActionQuickviewFocusTo(InterfaceActionBase):
|
||||
name = 'Focus To Quickview'
|
||||
actual_plugin = 'calibre.gui2.actions.show_quickview:FocusToQuickviewAction'
|
||||
description = _('Move the focus to the Quickview pane/window')
|
||||
|
||||
class ActionTemplateTester(InterfaceActionBase):
|
||||
name = 'Template Tester'
|
||||
actual_plugin = 'calibre.gui2.actions.show_template_tester:ShowTemplateTesterAction'
|
||||
@ -979,7 +974,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
|
||||
ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionChooseLibrary,
|
||||
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
|
||||
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
|
||||
ActionMarkBooks, ActionEmbed, ActionTemplateTester, ActionQuickviewFocusTo]
|
||||
ActionMarkBooks, ActionEmbed, ActionTemplateTester]
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -7,26 +7,12 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
from PyQt5.Qt import QAction
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.dialogs.quickview import Quickview
|
||||
from calibre.gui2 import error_dialog
|
||||
|
||||
class FocusToQuickviewAction(InterfaceAction):
|
||||
|
||||
name = 'Focus To Quickview'
|
||||
action_spec = (_('Focus To Quickview'), 'search.png', None, ('Shift+Q'))
|
||||
dont_add_to = frozenset(['context-menu-device'])
|
||||
action_type = 'current'
|
||||
|
||||
def genesis(self):
|
||||
self.qaction.triggered.connect(self.focus_quickview)
|
||||
|
||||
def focus_quickview(self, *args):
|
||||
from calibre.customize.ui import find_plugin
|
||||
qv = find_plugin('Show Quickview')
|
||||
if qv:
|
||||
qv.actual_plugin_.focus_quickview()
|
||||
|
||||
class ShowQuickviewAction(InterfaceAction):
|
||||
|
||||
name = 'Show Quickview'
|
||||
@ -39,12 +25,21 @@ class ShowQuickviewAction(InterfaceAction):
|
||||
def genesis(self):
|
||||
self.qaction.triggered.connect(self.show_quickview)
|
||||
|
||||
self.focus_action = QAction(self.gui)
|
||||
self.gui.addAction(self.focus_action)
|
||||
self.gui.keyboard.register_shortcut('Focus To Quickview', _('Focus To Quickview'),
|
||||
description=_('Move the focus to the Quickview pane/window'),
|
||||
default_keys=('Shift+Q',), action=self.focus_action,
|
||||
group=self.action_spec[0])
|
||||
self.focus_action.triggered.connect(self.focus_quickview)
|
||||
|
||||
def show_quickview(self, *args):
|
||||
if self.current_instance:
|
||||
if not self.current_instance.is_closed:
|
||||
self.current_instance.reject()
|
||||
self.current_instance = None
|
||||
return
|
||||
self.current_instance = None
|
||||
return
|
||||
if self.gui.current_view() is not self.gui.library_view:
|
||||
error_dialog(self.gui, _('No quickview available'),
|
||||
_('Quickview is not available for books '
|
||||
|
@ -48,7 +48,6 @@ IN_WIDGET_LOCK = 2
|
||||
IN_WIDGET_DOCK = 3
|
||||
IN_WIDGET_SEARCH = 4
|
||||
IN_WIDGET_CLOSE = 5
|
||||
IN_WIDGET_LAST = 5
|
||||
|
||||
class BooksKeyPressFilter(QObject):
|
||||
|
||||
@ -62,8 +61,8 @@ class BooksKeyPressFilter(QObject):
|
||||
|
||||
class WidgetTabFilter(QObject):
|
||||
|
||||
def __init__(self, attachToClass, which_widget, tab_signal):
|
||||
QObject.__init__(self, attachToClass)
|
||||
def __init__(self, attach_to_Class, which_widget, tab_signal):
|
||||
QObject.__init__(self, attach_to_Class)
|
||||
self.tab_signal = tab_signal
|
||||
self.which_widget = which_widget
|
||||
|
||||
@ -140,6 +139,7 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
self.books_table.installEventFilter(return_filter)
|
||||
|
||||
self.close_button = self.buttonBox.button(QDialogButtonBox.Close)
|
||||
|
||||
self.tab_order_widgets = [self.items, self.books_table, self.lock_qv,
|
||||
self.dock_button, self.search_button, self.close_button]
|
||||
for idx,widget in enumerate(self.tab_order_widgets):
|
||||
@ -182,24 +182,24 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
self.lock_qv.setText(_('Lock Quickview contents'))
|
||||
self.search_button.setText(_('Search'))
|
||||
self.gui.quickview_splitter.add_quickview_dialog(self)
|
||||
self.set_focus()
|
||||
else:
|
||||
self.lock_qv.setText(_('&Dock'))
|
||||
self.close_button.setText(_('&Close'))
|
||||
self.set_focus()
|
||||
|
||||
self.books_table.horizontalHeader().sectionResized.connect(self.section_resized)
|
||||
self.dock_button.clicked.connect(self.show_as_pane_changed)
|
||||
|
||||
def tab_pressed(self, inWidget, isForward):
|
||||
def tab_pressed(self, in_widget, isForward):
|
||||
if isForward:
|
||||
inWidget += 1
|
||||
if inWidget > IN_WIDGET_LAST:
|
||||
inWidget = 0
|
||||
in_widget += 1
|
||||
if in_widget >= len(self.tab_order_widgets):
|
||||
in_widget = 0
|
||||
else:
|
||||
inWidget -= 1
|
||||
if inWidget < 0:
|
||||
inWidget = IN_WIDGET_LAST
|
||||
self.tab_order_widgets[inWidget].setFocus(Qt.TabFocusReason)
|
||||
in_widget -= 1
|
||||
if in_widget < 0:
|
||||
in_widget = len(self.tab_order_widgets) - 1
|
||||
self.tab_order_widgets[in_widget].setFocus(Qt.TabFocusReason)
|
||||
|
||||
def show(self):
|
||||
QDialog.show(self)
|
||||
@ -259,8 +259,10 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
self.indicate_no_items()
|
||||
return
|
||||
key = self.current_key
|
||||
self.items_label.setText(_('&Item: {0} ({1})').format(
|
||||
self.db.field_metadata[key]['name'], key))
|
||||
label_text = _('&Item: {0} ({1})')
|
||||
if self.is_pane:
|
||||
label_text = label_text.replace('&', '')
|
||||
self.items_label.setText(label_text.format(self.db.field_metadata[key]['name'], key))
|
||||
|
||||
self.items.blockSignals(True)
|
||||
self.items.clear()
|
||||
@ -311,8 +313,10 @@ class Quickview(QDialog, Ui_Quickview):
|
||||
sort_results=False)
|
||||
|
||||
self.books_table.setRowCount(len(books))
|
||||
self.books_label.setText(_('&Books with selected item "{0}": {1}').
|
||||
format(selected_item, len(books)))
|
||||
label_text = _('&Books with selected item "{0}": {1}')
|
||||
if self.is_pane:
|
||||
label_text = label_text.replace('&', '')
|
||||
self.books_label.setText(label_text.format(selected_item, len(books)))
|
||||
|
||||
select_item = None
|
||||
self.books_table.setSortingEnabled(False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user