diff --git a/src/calibre/gui2/dialogs/trim_image.py b/src/calibre/gui2/dialogs/trim_image.py index de34cf7fac..4c54132945 100644 --- a/src/calibre/gui2/dialogs/trim_image.py +++ b/src/calibre/gui2/dialogs/trim_image.py @@ -59,6 +59,10 @@ class TrimImage(QDialog): bb.rejected.connect(self.reject) l.addWidget(bb) + self.tok = b = bb.addButton(_('Trim and OK'), QDialogButtonBox.ActionRole) + b.clicked.connect(self.trim_and_accept) + b.setIcon(self.trim_action.icon()) + self.resize(QSize(900, 600)) geom = gprefs.get('image-trim-dialog-geometry', None) if geom is not None: @@ -87,6 +91,10 @@ class TrimImage(QDialog): self.cleanup() QDialog.reject(self) + def trim_and_accept(self): + if self.canvas.trim_image(): + self.accept() + if __name__ == '__main__': app = QApplication([]) fname = sys.argv[-1] diff --git a/src/calibre/gui2/tweak_book/editor/canvas.py b/src/calibre/gui2/tweak_book/editor/canvas.py index ec6753615f..fe15731326 100644 --- a/src/calibre/gui2/tweak_book/editor/canvas.py +++ b/src/calibre/gui2/tweak_book/editor/canvas.py @@ -194,9 +194,11 @@ class Canvas(QWidget): @imageop def trim_image(self): if self.selection_state.rect is None: - return error_dialog(self, _('No selection'), _( + error_dialog(self, _('No selection'), _( 'No active selection, first select a region in the image, by dragging with your mouse'), show=True) + return False self.undo_stack.push(Trim(self)) + return True # The selection rectangle {{{ @property