mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a menu action in book details to copy the link to a book's data folder if one exists.
This commit is contained in:
parent
125c7bbf26
commit
a17b860df5
@ -5,6 +5,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from contextlib import suppress
|
||||||
from functools import lru_cache, partial
|
from functools import lru_cache, partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon,
|
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon,
|
||||||
@ -474,6 +475,13 @@ def create_copy_links(menu, data=None):
|
|||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
link(_('Link to show book in calibre'), f'calibre://show-book/{library_id}/{book_id}')
|
link(_('Link to show book in calibre'), f'calibre://show-book/{library_id}/{book_id}')
|
||||||
link(_('Link to show book details in a popup window'), f'calibre://book-details/{library_id}/{book_id}')
|
link(_('Link to show book details in a popup window'), f'calibre://book-details/{library_id}/{book_id}')
|
||||||
|
mi = db.new_api.get_proxy_metadata(book_id)
|
||||||
|
data_path = os.path.join(db.backend.library_path, mi.path, 'data')
|
||||||
|
with suppress(OSError):
|
||||||
|
if os.listdir(data_path):
|
||||||
|
if iswindows:
|
||||||
|
data_path = '/' + data_path.replace('\\', '/')
|
||||||
|
link(_("Link to open book's data files folder"), 'file://' + data_path)
|
||||||
if data:
|
if data:
|
||||||
field = data.get('field')
|
field = data.get('field')
|
||||||
if data['type'] == 'author':
|
if data['type'] == 'author':
|
||||||
@ -490,7 +498,6 @@ def create_copy_links(menu, data=None):
|
|||||||
|
|
||||||
if all_links:
|
if all_links:
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
mi = db.new_api.get_proxy_metadata(book_id)
|
|
||||||
all_links.insert(0, '')
|
all_links.insert(0, '')
|
||||||
all_links.insert(0, mi.get('title') + ' - ' + ' & '.join(mi.get('authors')))
|
all_links.insert(0, mi.get('title') + ' - ' + ' & '.join(mi.get('authors')))
|
||||||
link(_('Copy all the above links'), '\n'.join(all_links))
|
link(_('Copy all the above links'), '\n'.join(all_links))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user