mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add quick highlight and adjust selection actions for selection bar
This commit is contained in:
parent
53da449b42
commit
7f275c8dc4
@ -517,6 +517,15 @@ class CreateAnnotation: # {{{
|
||||
)
|
||||
self.hide()
|
||||
|
||||
def quick_create(self):
|
||||
s = self.current_highlight_style
|
||||
style = ''
|
||||
for k in Object.keys(self.current_highlight_style):
|
||||
style += f'{k}: {s[k]}; '
|
||||
self.send_message(
|
||||
'apply-highlight', style=style, uuid=short_uuid()
|
||||
)
|
||||
|
||||
def on_keydown(self, ev):
|
||||
ev.stopPropagation(), ev.preventDefault()
|
||||
if ev.key is 'Enter':
|
||||
|
@ -19,7 +19,9 @@ def all_actions():
|
||||
all_actions.ans = {
|
||||
'copy': a('copy', _('Copy to clipboard'), 'copy_to_clipboard'),
|
||||
'lookup': a('library', _('Lookup/search selected word'), 'lookup'),
|
||||
'highlight': a('highlight', _('Highlight selection'), 'create_highlight'),
|
||||
'quick_highlight': a('highlight', _('Quick highlight in current style'), 'quick_highlight'),
|
||||
'highlight': a('highlight', _('Highlight selection in notes mode'), 'create_highlight'),
|
||||
'selection': a('arrows-h', _('Highlight adjusting selection'), 'adjust_selection'),
|
||||
'search_net': a('search', _('Search for selection on the net'), 'internet_search'),
|
||||
'remove_highlight': a('eraser', _('Remove this highlight'), 'remove_highlight', True),
|
||||
'clear': a('close', _('Clear selection'), 'clear_selection'),
|
||||
@ -119,6 +121,17 @@ class SelectionBar:
|
||||
def create_highlight(self):
|
||||
self.view.initiate_create_annotation(True)
|
||||
|
||||
def adjust_selection(self):
|
||||
self.view.initiate_create_annotation(False)
|
||||
|
||||
def quick_highlight(self):
|
||||
cs = self.view.currently_showing.selection
|
||||
if cs.text:
|
||||
if cs.annot_id:
|
||||
self.view.initiate_create_annotation(True)
|
||||
else:
|
||||
self.view.create_annotation.quick_create()
|
||||
|
||||
def remove_highlight(self):
|
||||
annot_id = self.view.currently_showing.selection.annot_id
|
||||
if annot_id:
|
||||
|
Loading…
x
Reference in New Issue
Block a user