mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -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'
|
actual_plugin = 'calibre.gui2.actions.show_quickview:ShowQuickviewAction'
|
||||||
description = _('Show a list of related books quickly')
|
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):
|
class ActionTemplateTester(InterfaceActionBase):
|
||||||
name = 'Template Tester'
|
name = 'Template Tester'
|
||||||
actual_plugin = 'calibre.gui2.actions.show_template_tester:ShowTemplateTesterAction'
|
actual_plugin = 'calibre.gui2.actions.show_template_tester:ShowTemplateTesterAction'
|
||||||
@ -979,7 +974,7 @@ plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
|
|||||||
ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionChooseLibrary,
|
ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionChooseLibrary,
|
||||||
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
|
ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore,
|
||||||
ActionPluginUpdater, ActionPickRandom, ActionEditToC, ActionSortBy,
|
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'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
from PyQt5.Qt import QAction
|
||||||
|
|
||||||
from calibre.gui2.actions import InterfaceAction
|
from calibre.gui2.actions import InterfaceAction
|
||||||
from calibre.gui2.dialogs.quickview import Quickview
|
from calibre.gui2.dialogs.quickview import Quickview
|
||||||
from calibre.gui2 import error_dialog
|
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):
|
class ShowQuickviewAction(InterfaceAction):
|
||||||
|
|
||||||
name = 'Show Quickview'
|
name = 'Show Quickview'
|
||||||
@ -39,12 +25,21 @@ class ShowQuickviewAction(InterfaceAction):
|
|||||||
def genesis(self):
|
def genesis(self):
|
||||||
self.qaction.triggered.connect(self.show_quickview)
|
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):
|
def show_quickview(self, *args):
|
||||||
if self.current_instance:
|
if self.current_instance:
|
||||||
if not self.current_instance.is_closed:
|
if not self.current_instance.is_closed:
|
||||||
self.current_instance.reject()
|
self.current_instance.reject()
|
||||||
|
self.current_instance = None
|
||||||
|
return
|
||||||
self.current_instance = None
|
self.current_instance = None
|
||||||
return
|
|
||||||
if self.gui.current_view() is not self.gui.library_view:
|
if self.gui.current_view() is not self.gui.library_view:
|
||||||
error_dialog(self.gui, _('No quickview available'),
|
error_dialog(self.gui, _('No quickview available'),
|
||||||
_('Quickview is not available for books '
|
_('Quickview is not available for books '
|
||||||
|
@ -48,7 +48,6 @@ IN_WIDGET_LOCK = 2
|
|||||||
IN_WIDGET_DOCK = 3
|
IN_WIDGET_DOCK = 3
|
||||||
IN_WIDGET_SEARCH = 4
|
IN_WIDGET_SEARCH = 4
|
||||||
IN_WIDGET_CLOSE = 5
|
IN_WIDGET_CLOSE = 5
|
||||||
IN_WIDGET_LAST = 5
|
|
||||||
|
|
||||||
class BooksKeyPressFilter(QObject):
|
class BooksKeyPressFilter(QObject):
|
||||||
|
|
||||||
@ -62,8 +61,8 @@ class BooksKeyPressFilter(QObject):
|
|||||||
|
|
||||||
class WidgetTabFilter(QObject):
|
class WidgetTabFilter(QObject):
|
||||||
|
|
||||||
def __init__(self, attachToClass, which_widget, tab_signal):
|
def __init__(self, attach_to_Class, which_widget, tab_signal):
|
||||||
QObject.__init__(self, attachToClass)
|
QObject.__init__(self, attach_to_Class)
|
||||||
self.tab_signal = tab_signal
|
self.tab_signal = tab_signal
|
||||||
self.which_widget = which_widget
|
self.which_widget = which_widget
|
||||||
|
|
||||||
@ -140,6 +139,7 @@ class Quickview(QDialog, Ui_Quickview):
|
|||||||
self.books_table.installEventFilter(return_filter)
|
self.books_table.installEventFilter(return_filter)
|
||||||
|
|
||||||
self.close_button = self.buttonBox.button(QDialogButtonBox.Close)
|
self.close_button = self.buttonBox.button(QDialogButtonBox.Close)
|
||||||
|
|
||||||
self.tab_order_widgets = [self.items, self.books_table, self.lock_qv,
|
self.tab_order_widgets = [self.items, self.books_table, self.lock_qv,
|
||||||
self.dock_button, self.search_button, self.close_button]
|
self.dock_button, self.search_button, self.close_button]
|
||||||
for idx,widget in enumerate(self.tab_order_widgets):
|
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.lock_qv.setText(_('Lock Quickview contents'))
|
||||||
self.search_button.setText(_('Search'))
|
self.search_button.setText(_('Search'))
|
||||||
self.gui.quickview_splitter.add_quickview_dialog(self)
|
self.gui.quickview_splitter.add_quickview_dialog(self)
|
||||||
self.set_focus()
|
|
||||||
else:
|
else:
|
||||||
self.lock_qv.setText(_('&Dock'))
|
self.lock_qv.setText(_('&Dock'))
|
||||||
self.close_button.setText(_('&Close'))
|
self.close_button.setText(_('&Close'))
|
||||||
|
self.set_focus()
|
||||||
|
|
||||||
self.books_table.horizontalHeader().sectionResized.connect(self.section_resized)
|
self.books_table.horizontalHeader().sectionResized.connect(self.section_resized)
|
||||||
self.dock_button.clicked.connect(self.show_as_pane_changed)
|
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:
|
if isForward:
|
||||||
inWidget += 1
|
in_widget += 1
|
||||||
if inWidget > IN_WIDGET_LAST:
|
if in_widget >= len(self.tab_order_widgets):
|
||||||
inWidget = 0
|
in_widget = 0
|
||||||
else:
|
else:
|
||||||
inWidget -= 1
|
in_widget -= 1
|
||||||
if inWidget < 0:
|
if in_widget < 0:
|
||||||
inWidget = IN_WIDGET_LAST
|
in_widget = len(self.tab_order_widgets) - 1
|
||||||
self.tab_order_widgets[inWidget].setFocus(Qt.TabFocusReason)
|
self.tab_order_widgets[in_widget].setFocus(Qt.TabFocusReason)
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
QDialog.show(self)
|
QDialog.show(self)
|
||||||
@ -259,8 +259,10 @@ class Quickview(QDialog, Ui_Quickview):
|
|||||||
self.indicate_no_items()
|
self.indicate_no_items()
|
||||||
return
|
return
|
||||||
key = self.current_key
|
key = self.current_key
|
||||||
self.items_label.setText(_('&Item: {0} ({1})').format(
|
label_text = _('&Item: {0} ({1})')
|
||||||
self.db.field_metadata[key]['name'], key))
|
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.blockSignals(True)
|
||||||
self.items.clear()
|
self.items.clear()
|
||||||
@ -311,8 +313,10 @@ class Quickview(QDialog, Ui_Quickview):
|
|||||||
sort_results=False)
|
sort_results=False)
|
||||||
|
|
||||||
self.books_table.setRowCount(len(books))
|
self.books_table.setRowCount(len(books))
|
||||||
self.books_label.setText(_('&Books with selected item "{0}": {1}').
|
label_text = _('&Books with selected item "{0}": {1}')
|
||||||
format(selected_item, len(books)))
|
if self.is_pane:
|
||||||
|
label_text = label_text.replace('&', '')
|
||||||
|
self.books_label.setText(label_text.format(selected_item, len(books)))
|
||||||
|
|
||||||
select_item = None
|
select_item = None
|
||||||
self.books_table.setSortingEnabled(False)
|
self.books_table.setSortingEnabled(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user