Commit 31ac40af authored by Alban Boissard's avatar Alban Boissard Committed by Nate Graham
Browse files

Make spinboxes in Crop tool behave properly with fixed aspect ratio

When the aspect ratio is fixed in the crop tool, if we change
the value of a spinbox, the other spinbox is set accordingly but
trigger a signal that change the value of the first spinbox.

This commit fixes that wrong behavior.

BUG: 332208


FIXED-IN: 22.08

Signed-off-by: Alban Boissard's avatarAlban Boissard <albanboissard@gmail.com>
parent d2e5b878
Pipeline #175350 passed with stage
in 3 minutes and 19 seconds
......@@ -77,6 +77,8 @@ struct CropWidgetPrivate : public QWidget {
Document::Ptr mDocument;
CropTool *mCropTool = nullptr;
bool mUpdatingFromCropTool;
bool mUpdatingFromWidthSpinBox = false;
bool mUpdatingFromHeightSpinBox = false;
int mCurrentImageComboBoxIndex;
int mCropRatioComboBoxCurrentIndex;
......@@ -492,12 +494,15 @@ void CropWidget::slotWidthChanged()
{
d->leftSpinBox->setMaximum(d->mDocument->width() - d->widthSpinBox->value());
if (d->mUpdatingFromCropTool) {
if (d->mUpdatingFromCropTool || d->mUpdatingFromHeightSpinBox) {
return;
}
if (d->ratioIsConstrained()) {
d->mUpdatingFromWidthSpinBox = true;
int height = int(d->widthSpinBox->value() * d->cropRatio());
d->heightSpinBox->setValue(height);
d->mUpdatingFromWidthSpinBox = false;
}
d->mCropTool->setRect(d->cropRect());
}
......@@ -506,12 +511,15 @@ void CropWidget::slotHeightChanged()
{
d->topSpinBox->setMaximum(d->mDocument->height() - d->heightSpinBox->value());
if (d->mUpdatingFromCropTool) {
if (d->mUpdatingFromCropTool || d->mUpdatingFromWidthSpinBox) {
return;
}
if (d->ratioIsConstrained()) {
d->mUpdatingFromHeightSpinBox = true;
int width = int(d->heightSpinBox->value() / d->cropRatio());
d->widthSpinBox->setValue(width);
d->mUpdatingFromHeightSpinBox = false;
}
d->mCropTool->setRect(d->cropRect());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment