mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02:00
Add quick highlight and adjust selection actions for selection bar
This commit is contained in:
parent
53da449b42
commit
7f275c8dc4
2 changed files with 23 additions and 1 deletions
|
|
@ -517,6 +517,15 @@ def accept(self):
|
|||
)
|
||||
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 a(icon, text, func, needs_highlight):
|
|||
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 @@ def clear_selection(self):
|
|||
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…
Reference in a new issue