mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a highlight button to the selection bar
This commit is contained in:
parent
1c38d64b1a
commit
106c84e8b7
@ -683,6 +683,8 @@ class CreateAnnotation:
|
|||||||
self.place_handles(msg.extents)
|
self.place_handles(msg.extents)
|
||||||
self.in_flow_mode = msg.in_flow_mode
|
self.in_flow_mode = msg.in_flow_mode
|
||||||
self.send_message('set-highlight-style', style=self.current_highlight_style)
|
self.send_message('set-highlight-style', style=self.current_highlight_style)
|
||||||
|
if msg.start_in_notes_edit:
|
||||||
|
self.add_notes()
|
||||||
elif msg.type is 'position-handles':
|
elif msg.type is 'position-handles':
|
||||||
if self.state is WAITING_FOR_CLICK:
|
if self.state is WAITING_FOR_CLICK:
|
||||||
self.place_handles(msg.extents)
|
self.place_handles(msg.extents)
|
||||||
@ -746,7 +748,7 @@ class CreateAnnotation:
|
|||||||
self.place_single_handle(self.right_handle, extents.end)
|
self.place_single_handle(self.right_handle, extents.end)
|
||||||
|
|
||||||
|
|
||||||
class ViewAnnotation:
|
class ViewAnnotation: # {{{
|
||||||
|
|
||||||
container_id = 'view-annotation-overlay'
|
container_id = 'view-annotation-overlay'
|
||||||
|
|
||||||
@ -833,3 +835,4 @@ class ViewAnnotation:
|
|||||||
if self.showing_uuid:
|
if self.showing_uuid:
|
||||||
self.view.create_annotation.edit_highlight(self.showing_uuid)
|
self.view.create_annotation.edit_highlight(self.showing_uuid)
|
||||||
self.hide()
|
self.hide()
|
||||||
|
# }}}
|
||||||
|
@ -704,9 +704,9 @@ class IframeBoss:
|
|||||||
end_reference_mode()
|
end_reference_mode()
|
||||||
|
|
||||||
def create_annotation(self, data):
|
def create_annotation(self, data):
|
||||||
self.initiate_creation_of_annotation()
|
self.initiate_creation_of_annotation(None, data.start_in_notes_edit)
|
||||||
|
|
||||||
def initiate_creation_of_annotation(self, existing):
|
def initiate_creation_of_annotation(self, existing, start_in_notes_edit):
|
||||||
self.auto_scroll_action('stop')
|
self.auto_scroll_action('stop')
|
||||||
in_flow_mode = current_layout_mode() is 'flow'
|
in_flow_mode = current_layout_mode() is 'flow'
|
||||||
self.send_message(
|
self.send_message(
|
||||||
@ -715,6 +715,7 @@ class IframeBoss:
|
|||||||
in_flow_mode=in_flow_mode,
|
in_flow_mode=in_flow_mode,
|
||||||
extents=selection_extents(in_flow_mode),
|
extents=selection_extents(in_flow_mode),
|
||||||
existing=existing or None,
|
existing=existing or None,
|
||||||
|
start_in_notes_edit=v'!!start_in_notes_edit',
|
||||||
)
|
)
|
||||||
|
|
||||||
def annotations_msg_received(self, data):
|
def annotations_msg_received(self, data):
|
||||||
|
@ -33,6 +33,7 @@ class SelectionBar:
|
|||||||
bar.appendChild(cb('copy', _('Copy to clipboard'), self.copy_to_clipboard))
|
bar.appendChild(cb('copy', _('Copy to clipboard'), self.copy_to_clipboard))
|
||||||
if ui_operations.toggle_lookup:
|
if ui_operations.toggle_lookup:
|
||||||
bar.appendChild(cb('library', _('Lookup/search selected word'), self.lookup))
|
bar.appendChild(cb('library', _('Lookup/search selected word'), self.lookup))
|
||||||
|
bar.appendChild(cb('highlight', _('Highlight selection'), self.create_highlight))
|
||||||
bar.appendChild(cb('close', _('Clear the selection'), self.clear_selection))
|
bar.appendChild(cb('close', _('Clear the selection'), self.clear_selection))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -63,6 +64,9 @@ class SelectionBar:
|
|||||||
def clear_selection(self):
|
def clear_selection(self):
|
||||||
self.view.on_handle_shortcut({'name': 'clear_selection'})
|
self.view.on_handle_shortcut({'name': 'clear_selection'})
|
||||||
|
|
||||||
|
def create_highlight(self):
|
||||||
|
self.view.initiate_create_annotation(True)
|
||||||
|
|
||||||
def update_position(self):
|
def update_position(self):
|
||||||
cs = self.view.currently_showing
|
cs = self.view.currently_showing
|
||||||
if not cs.has_selection:
|
if not cs.has_selection:
|
||||||
|
@ -1235,14 +1235,14 @@ class View:
|
|||||||
else:
|
else:
|
||||||
self.show_name(sr.file_name, initial_position={'type':'search_result', 'search_result':sr, 'replace_history':True})
|
self.show_name(sr.file_name, initial_position={'type':'search_result', 'search_result':sr, 'replace_history':True})
|
||||||
|
|
||||||
def initiate_create_annotation(self):
|
def initiate_create_annotation(self, start_in_notes_edit):
|
||||||
self.iframe_wrapper.send_message('create_annotation')
|
self.iframe_wrapper.send_message('create_annotation', start_in_notes_edit=v'!!start_in_notes_edit')
|
||||||
|
|
||||||
def highlight_action(self, uuid, which):
|
def highlight_action(self, uuid, which):
|
||||||
if self.create_annotation.is_visible:
|
if self.create_annotation.is_visible:
|
||||||
return
|
return
|
||||||
if which is 'create':
|
if which is 'create':
|
||||||
self.iframe_wrapper.send_message('create_annotation')
|
self.initiate_create_annotation(False)
|
||||||
return
|
return
|
||||||
spine = self.book.manifest.spine
|
spine = self.book.manifest.spine
|
||||||
spine_index = self.annotations_manager.spine_index_for_highlight(uuid, spine)
|
spine_index = self.annotations_manager.spine_index_for_highlight(uuid, spine)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user