mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a trim and accept button
This commit is contained in:
parent
201649a982
commit
5fa92b0f42
@ -59,6 +59,10 @@ class TrimImage(QDialog):
|
|||||||
bb.rejected.connect(self.reject)
|
bb.rejected.connect(self.reject)
|
||||||
l.addWidget(bb)
|
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))
|
self.resize(QSize(900, 600))
|
||||||
geom = gprefs.get('image-trim-dialog-geometry', None)
|
geom = gprefs.get('image-trim-dialog-geometry', None)
|
||||||
if geom is not None:
|
if geom is not None:
|
||||||
@ -87,6 +91,10 @@ class TrimImage(QDialog):
|
|||||||
self.cleanup()
|
self.cleanup()
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
|
||||||
|
def trim_and_accept(self):
|
||||||
|
if self.canvas.trim_image():
|
||||||
|
self.accept()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
fname = sys.argv[-1]
|
fname = sys.argv[-1]
|
||||||
|
@ -194,9 +194,11 @@ class Canvas(QWidget):
|
|||||||
@imageop
|
@imageop
|
||||||
def trim_image(self):
|
def trim_image(self):
|
||||||
if self.selection_state.rect is None:
|
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)
|
'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))
|
self.undo_stack.push(Trim(self))
|
||||||
|
return True
|
||||||
|
|
||||||
# The selection rectangle {{{
|
# The selection rectangle {{{
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user