Add a trim and accept button

This commit is contained in:
Kovid Goyal 2013-12-04 23:31:42 +05:30
parent 201649a982
commit 5fa92b0f42
2 changed files with 11 additions and 1 deletions

View File

@ -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]

View File

@ -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