mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Edit metadata : Add the ability to trim covers manually
Edit metadata dialog: Add the ability to trim covers manually, if automatic trimming is not satisfactory. Fixes #1256054 [[Enhancement] Enhanced cover picture trim](https://bugs.launchpad.net/calibre/+bug/1256054)
This commit is contained in:
parent
77887df865
commit
7e49bd7983
@ -926,12 +926,15 @@ class Cover(ImageView): # {{{
|
||||
self.clicked.connect(action)
|
||||
|
||||
self.select_cover_button = CB(_('&Browse'), 'document_open.png', self.select_cover)
|
||||
self.trim_cover_button = b = CB(_('T&rim borders'), 'trim.png', self.trim_cover)
|
||||
self.trim_cover_button = b = CB(_('T&rim borders'), 'trim.png')
|
||||
b.setToolTip(_(
|
||||
'Automatically detect and remove extra space at the cover\'s edges.\n'
|
||||
'Pressing it repeatedly can sometimes remove stubborn borders.'))
|
||||
b.m = m = QMenu()
|
||||
b.setPopupMode(QToolButton.DelayedPopup)
|
||||
b.setPopupMode(QToolButton.InstantPopup)
|
||||
m.addAction(QIcon(I('trim.png')), _('Automatically trim borders'), self.trim_cover)
|
||||
m.addSeparator()
|
||||
m.addAction(_('Trim borders manually'), self.manual_trim_cover)
|
||||
m.addAction(QIcon(I('edit-undo.png')), _('Undo last trim'), self.undo_trim)
|
||||
b.setMenu(m)
|
||||
self.remove_cover_button = CB(_('&Remove'), 'trash.png', self.remove_cover)
|
||||
@ -1005,6 +1008,14 @@ class Cover(ImageView): # {{{
|
||||
self.current_val = im.export('png')
|
||||
self.cdata_before_trim = cdata
|
||||
|
||||
def manual_trim_cover(self):
|
||||
cdata = self.current_val
|
||||
from calibre.gui2.dialogs.trim_image import TrimImage
|
||||
d = TrimImage(cdata, parent=self)
|
||||
if d.exec_() == d.Accepted and d.image_data is not None:
|
||||
self.current_val = d.image_data
|
||||
self.cdata_before_trim = cdata
|
||||
|
||||
def generate_cover(self, *args):
|
||||
from calibre.ebooks import calibre_cover
|
||||
from calibre.ebooks.metadata import fmt_sidx
|
||||
|
Loading…
x
Reference in New Issue
Block a user