Commit Graph

4 Commits

Author SHA1 Message Date
Beat Hangartner 36bfc6f969 Return qet.imageCrop() as {x, y, width, height}
The crop rectangle came back as the string "x,y,width,height", which a
script had to split and parse. elementGeometry() returns a map; the
crop now does the same, and an empty map for no such image.

Suggested in the review of #1310.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 10:55:02 +02:00
Beat Hangartner 1b0ab6d26a Compute a picture's displayed pixmap from its source
The displayed pixmap and imageSource (original, crop rectangle,
transparent colours) were two undo values that had to change together,
although the pixmap follows from the source. An action that updated
one and not the other would bring back the bug fixed in #1310.

setImageSource() now recomputes the displayed pixmap, and crop, colour
key, mirror and replace push one undo step on imageSource alone. A
plain QUndoCommand holds the property change, so two identical actions
in a row stay two steps. Loading a project still shows the saved pixmap
as before.

tst_imagecropundo also checks the size of the saved picture after undo
and after redo.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-07 06:25:14 +02:00
Beat Hangartner 0513344b92 Address review: drop dummy undo children, applyCrop() returns bool
- replaceImage(), mirror() and setTransparentColor() no longer add a
  dummy QUndoCommand child: the imageSource child already keeps
  QPropertyUndoCommand::mergeWith() from merging two of them.
- The explanation of the position and pivot maths moves from crop() to
  applyCrop(), where that code now lives; the stale older doc block of
  crop() goes.
- applyCrop() returns false when nothing was cropped, and
  qet.cropImage() passes that on. tst_imagecropundo checks it for the
  current crop, an empty rectangle and one outside the picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 13:01:30 +02:00
Beat Hangartner 05b71e07a0 Add qet.cropImage() and qet.imageCrop() to the script API
Crop a picture as the crop tool does, in one undo step, and read its
crop rectangle back. tst_imagecropundo uses them on the real binary:
a crop that was undone is not saved, and redoing it saves it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 22:41:58 +02:00