mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-30 09:37:04 +01:00
Add a tweak in Preferences->Tweaks to exclude some images types from being treated a covers when dropped onto the Book Details panel. Fixes #1620198 [{Enhancement] Tweak to control image DnD to Book Details](https://bugs.launchpad.net/calibre/+bug/1620198)
This commit is contained in:
parent
ad30806ba9
commit
a60aeaa1ba
3 changed files with 14 additions and 3 deletions
|
|
@ -565,3 +565,11 @@
|
|||
# numbers.
|
||||
# The value can be between 50 and 99
|
||||
content_server_thumbnail_compression_quality = 75
|
||||
|
||||
#: Image file types to treat as ebooks when dropping onto the Book Details panel
|
||||
# Normally, if you drop any image file in a format known to calibre onto the
|
||||
# Book Details panel, it will be used to set the cover. If you want to store
|
||||
# some image types as ebooks instead, you can set this tweak.
|
||||
# Examples:
|
||||
# cover_drop_exclude = {'tiff', 'webp'}
|
||||
cover_drop_exclude = ()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.gui2.dialogs.progress import ProgressDialog
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.utils.config_base import tweaks
|
||||
from calibre.utils.filenames import ascii_filename
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
|
@ -359,11 +360,12 @@ def files_dropped_on_book(self, event, paths, cid=None, do_confirm=True):
|
|||
cid = db.id(current_idx.row()) if cid is None else cid
|
||||
formats = []
|
||||
from calibre.gui2.dnd import image_extensions
|
||||
image_exts = set(image_extensions()) - set(tweaks['cover_drop_exclude'])
|
||||
for path in paths:
|
||||
ext = os.path.splitext(path)[1].lower()
|
||||
if ext:
|
||||
ext = ext[1:]
|
||||
if ext in image_extensions():
|
||||
if ext in image_exts:
|
||||
pmap = QPixmap()
|
||||
pmap.load(path)
|
||||
if not pmap.isNull():
|
||||
|
|
|
|||
|
|
@ -653,7 +653,8 @@ def dropEvent(self, event):
|
|||
event.setDropAction(Qt.CopyAction)
|
||||
md = event.mimeData()
|
||||
|
||||
x, y = dnd_get_image(md)
|
||||
image_exts = set(image_extensions()) - set(tweaks['cover_drop_exclude'])
|
||||
x, y = dnd_get_image(md, image_exts)
|
||||
if x is not None:
|
||||
# We have an image, set cover
|
||||
event.accept()
|
||||
|
|
@ -668,7 +669,7 @@ def dropEvent(self, event):
|
|||
return
|
||||
|
||||
# Now look for ebook files
|
||||
urls, filenames = dnd_get_files(md, BOOK_EXTENSIONS, allow_all_extensions=True, filter_exts=image_extensions())
|
||||
urls, filenames = dnd_get_files(md, BOOK_EXTENSIONS, allow_all_extensions=True, filter_exts=image_exts)
|
||||
if not urls:
|
||||
# Nothing found
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue