mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server viewer: Allow viewing images in a new window by right clicking them, matches the calibre builtin viewer behavior. Fixes #1903333 [[Enhancement - Content server viewer] Ability to view image](https://bugs.launchpad.net/calibre/+bug/1903333)
This commit is contained in:
parent
b6b1af097b
commit
4bafec703d
@ -370,7 +370,22 @@ class MainOverlay: # {{{
|
|||||||
def(): self.overlay.hide(), ui_operations.quit();, 'remove'),
|
def(): self.overlay.hide(), ui_operations.quit();, 'remove'),
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
pass
|
copy_actions = E.ul()
|
||||||
|
if self.elements.link:
|
||||||
|
copy_actions.appendChild(ac(_('Copy link'), _('Copy the current link'), def():
|
||||||
|
self.overlay.hide(), ui_operations.copy_selection(self.elements.link)
|
||||||
|
, 'link'))
|
||||||
|
if self.elements.img:
|
||||||
|
copy_actions.appendChild(ac(_('View image'), _('View the current image'), def():
|
||||||
|
self.overlay.hide(), ui_operations.view_image(self.elements.img)
|
||||||
|
, 'image'))
|
||||||
|
if window.navigator.clipboard:
|
||||||
|
copy_actions.appendChild(ac(_('Copy image'), _('Copy the current image'), def():
|
||||||
|
self.overlay.hide(), ui_operations.copy_image(self.elements.img)
|
||||||
|
, 'copy'))
|
||||||
|
if copy_actions.childNodes.length:
|
||||||
|
actions_div.appendChild(copy_actions)
|
||||||
|
|
||||||
container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section
|
container.appendChild(set_css(E.div(class_=MAIN_OVERLAY_TS_CLASS, # top section
|
||||||
onclick=def (evt):evt.stopPropagation();,
|
onclick=def (evt):evt.stopPropagation();,
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@ class ReadUI:
|
|||||||
ui_operations.stop_waiting_for_messages_from = self.stop_waiting_for_messages_from.bind(self)
|
ui_operations.stop_waiting_for_messages_from = self.stop_waiting_for_messages_from.bind(self)
|
||||||
ui_operations.update_metadata = self.update_metadata.bind(self)
|
ui_operations.update_metadata = self.update_metadata.bind(self)
|
||||||
ui_operations.close_book = self.close_book.bind(self)
|
ui_operations.close_book = self.close_book.bind(self)
|
||||||
|
ui_operations.copy_image = self.copy_image.bind(self)
|
||||||
|
ui_operations.view_image = self.view_image.bind(self)
|
||||||
ui_operations.open_url = def(url):
|
ui_operations.open_url = def(url):
|
||||||
window.open(url, '_blank')
|
window.open(url, '_blank')
|
||||||
ui_operations.copy_selection = def(text, html):
|
ui_operations.copy_selection = def(text, html):
|
||||||
@ -187,6 +189,26 @@ class ReadUI:
|
|||||||
def close_book(self):
|
def close_book(self):
|
||||||
self.base_url_data = {}
|
self.base_url_data = {}
|
||||||
|
|
||||||
|
def copy_image(self, image_file_name):
|
||||||
|
if not self.view?.book:
|
||||||
|
return
|
||||||
|
ui_operations.get_file(
|
||||||
|
self.view.book, image_file_name, def(blob, name, mimetype):
|
||||||
|
try:
|
||||||
|
window.navigator.clipboard.write([new ClipboardItem({mimetype: blob})]) # noqa
|
||||||
|
except Exception as err:
|
||||||
|
error_dialog(_('Could not copy image'), str(err))
|
||||||
|
)
|
||||||
|
|
||||||
|
def view_image(self, image_file_name):
|
||||||
|
if not self.view?.book:
|
||||||
|
return
|
||||||
|
ui_operations.get_file(
|
||||||
|
self.view.book, image_file_name, def(blob, name, mimetype):
|
||||||
|
url = window.URL.createObjectURL(blob)
|
||||||
|
window.open(url)
|
||||||
|
)
|
||||||
|
|
||||||
def load_book(self, library_id, book_id, fmt, metadata, force_reload):
|
def load_book(self, library_id, book_id, fmt, metadata, force_reload):
|
||||||
self.base_url_data = {'library_id': library_id, 'book_id':book_id, 'fmt':fmt}
|
self.base_url_data = {'library_id': library_id, 'book_id':book_id, 'fmt':fmt}
|
||||||
if not self.db.initialized:
|
if not self.db.initialized:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user