Fix #1923094 [[Enhancement - Viewer] Open path folder](https://bugs.launchpad.net/calibre/+bug/1923094)

This commit is contained in:
Kovid Goyal 2021-04-09 14:18:25 +05:30
parent f772957cd7
commit eb7f51de50
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 18 additions and 1 deletions

View File

@ -274,6 +274,7 @@ class ViewerBridge(Bridge):
speak_simple_text = from_js(object) speak_simple_text = from_js(object)
tts = from_js(object, object) tts = from_js(object, object)
edit_book = from_js(object, object, object) edit_book = from_js(object, object, object)
show_book_folder = from_js()
create_view = to_js() create_view = to_js()
start_book_load = to_js() start_book_load = to_js()
@ -535,6 +536,7 @@ class WebView(RestartingWebEngineView):
self.bridge.close_prep_finished.connect(self.close_prep_finished) self.bridge.close_prep_finished.connect(self.close_prep_finished)
self.bridge.highlights_changed.connect(self.highlights_changed) self.bridge.highlights_changed.connect(self.highlights_changed)
self.bridge.edit_book.connect(self.edit_book) self.bridge.edit_book.connect(self.edit_book)
self.bridge.show_book_folder.connect(self.show_book_folder)
self.bridge.open_url.connect(safe_open_url) self.bridge.open_url.connect(safe_open_url)
self.bridge.speak_simple_text.connect(self.tts.speak_simple_text) self.bridge.speak_simple_text.connect(self.tts.speak_simple_text)
self.bridge.tts.connect(self.tts.action) self.bridge.tts.connect(self.tts.action)
@ -736,3 +738,7 @@ class WebView(RestartingWebEngineView):
def tts_settings_changed(self, ui_settings): def tts_settings_changed(self, ui_settings):
self.execute_when_ready('tts_event', 'configured', ui_settings) self.execute_when_ready('tts_event', 'configured', ui_settings)
def show_book_folder(self):
path = os.path.dirname(os.path.abspath(set_book_path.pathtoebook))
safe_open_url(QUrl.fromLocalFile(path))

View File

@ -787,7 +787,16 @@ class Overlay:
if pathtoebook: if pathtoebook:
container.lastChild.appendChild(E.div( container.lastChild.appendChild(E.div(
style='margin-top: 1ex; padding-top: 1ex; border-top: solid 1px', style='margin-top: 1ex; padding-top: 1ex; border-top: solid 1px',
_('Path: {}').format(pathtoebook))) _('Path:'), ' ',
E.a(
href='javascript: void(0)',
class_='blue-link', title=_('Click to open the folder the book is in'),
onclick=def():
ui_operations.show_book_folder()
,
pathtoebook)
)
)
book = self.view.book book = self.view.book
key = book.key or v'[null, 0]' key = book.key or v'[null, 0]'

View File

@ -421,6 +421,8 @@ if window is window.top:
to_python.tts(action, data or v'{}') to_python.tts(action, data or v'{}')
ui_operations.edit_book = def (spine_name, frac, selected_text): ui_operations.edit_book = def (spine_name, frac, selected_text):
to_python.edit_book(spine_name, frac, selected_text or '') to_python.edit_book(spine_name, frac, selected_text or '')
ui_operations.show_book_folder = def():
to_python.show_book_folder()
document.body.appendChild(E.div(id='view')) document.body.appendChild(E.div(id='view'))
window.onerror = onerror window.onerror = onerror