Commit d3f4793e authored by Henrik Fehlauer's avatar Henrik Fehlauer

Adapt code to new crop terminology too

Summary:
D11578 changes UI strings from "Restrict to image ratio" to
"Preserve aspect ratio". Here we adapt the naming of functions and
config variables too, to lessen developer confusion.

Test Plan: Compile, grep for "restrict"

Reviewers: #gwenview, ngraham, huoni

Reviewed By: huoni

Differential Revision: https://phabricator.kde.org/D11589
parent 9558f487
......@@ -427,7 +427,7 @@ void CropTool::toolActivated()
{
imageView()->setCursor(Qt::CrossCursor);
d->mCropWidget->setAdvancedSettingsEnabled(GwenviewConfig::cropAdvancedSettingsEnabled());
d->mCropWidget->setRestrictToImageRatio(GwenviewConfig::cropRestrictToImageRatio());
d->mCropWidget->setPreserveAspectRatio(GwenviewConfig::cropPreserveAspectRatio());
const int index = GwenviewConfig::cropRatioIndex();
if (index >= 0) {
// Preset ratio
......@@ -442,7 +442,7 @@ void CropTool::toolActivated()
void CropTool::toolDeactivated()
{
GwenviewConfig::setCropAdvancedSettingsEnabled(d->mCropWidget->advancedSettingsEnabled());
GwenviewConfig::setCropRestrictToImageRatio(d->mCropWidget->restrictToImageRatio());
GwenviewConfig::setCropPreserveAspectRatio(d->mCropWidget->preserveAspectRatio());
GwenviewConfig::setCropRatioIndex(d->mCropWidget->cropRatioIndex());
const QSizeF ratio = d->mCropWidget->cropRatio();
GwenviewConfig::setCropRatioWidth(ratio.width());
......
......@@ -137,7 +137,7 @@ struct CropWidgetPrivate : public Ui_CropWidget
return size.height() / size.width();
}
if (q->restrictToImageRatio()) {
if (q->preserveAspectRatio()) {
QSizeF size = ratio(mDocument->size());
return size.height() / size.width();
}
......@@ -267,7 +267,7 @@ CropWidget::CropWidget(QWidget* parent, RasterImageView* imageView, CropTool* cr
d->advancedWidget->setVisible(false);
d->advancedWidget->layout()->setMargin(0);
connect(d->restrictToImageRatioCheckBox, &QCheckBox::toggled, this, &CropWidget::applyRatioConstraint);
connect(d->preserveAspectRatioCheckBox, &QCheckBox::toggled, this, &CropWidget::applyRatioConstraint);
d->initRatioComboBox();
......@@ -309,14 +309,14 @@ bool CropWidget::advancedSettingsEnabled() const
return d->advancedCheckBox->isChecked();
}
void CropWidget::setRestrictToImageRatio(bool restrict)
void CropWidget::setPreserveAspectRatio(bool preserve)
{
d->restrictToImageRatioCheckBox->setChecked(restrict);
d->preserveAspectRatioCheckBox->setChecked(preserve);
}
bool CropWidget::restrictToImageRatio() const
bool CropWidget::preserveAspectRatio() const
{
return d->restrictToImageRatioCheckBox->isChecked();
return d->preserveAspectRatioCheckBox->isChecked();
}
void CropWidget::setCropRatio(QSizeF size)
......@@ -405,7 +405,7 @@ void CropWidget::applyRatioConstraint()
void CropWidget::slotAdvancedCheckBoxToggled(bool checked)
{
d->advancedWidget->setVisible(checked);
d->restrictToImageRatioCheckBox->setVisible(!checked);
d->preserveAspectRatioCheckBox->setVisible(!checked);
applyRatioConstraint();
}
......@@ -439,7 +439,7 @@ void CropWidget::updateCropRatio()
d->ratioComboBox->setItemData(d->mCurrentImageComboBoxIndex, QVariant(ratio(d->mDocument->size())));
// Always re-apply the constraint, even though we only need to when the user has "Current Image"
// selected or the "Restrict to current image" checked, since there's no harm
// selected or the "Preserve aspect ratio" checked, since there's no harm
applyRatioConstraint();
// If the ratio is unrestricted, calling applyRatioConstraint doesn't update the rect, so we call
// this manually to make sure the rect is adjusted to fit within the image
......
......@@ -47,8 +47,8 @@ public:
void setAdvancedSettingsEnabled(bool enable);
bool advancedSettingsEnabled() const;
void setRestrictToImageRatio(bool restrict);
bool restrictToImageRatio() const;
void setPreserveAspectRatio(bool preserve);
bool preserveAspectRatio() const;
void setCropRatio(QSizeF size);
int cropRatioIndex() const;
void setCropRatioIndex(int index);
......
......@@ -161,7 +161,7 @@
</spacer>
</item>
<item>
<widget class="QCheckBox" name="restrictToImageRatioCheckBox">
<widget class="QCheckBox" name="preserveAspectRatioCheckBox">
<property name="text">
<string>Preserve aspect ratio</string>
</property>
......
......@@ -300,7 +300,7 @@
<entry name="CropAdvancedSettingsEnabled" type="Bool">
<default>false</default>
</entry>
<entry name="CropRestrictToImageRatio" type="Bool">
<entry name="CropPreserveAspectRatio" type="Bool">
<label>Restrict crop to image ratio when Advanced Settings disabled</label>
<default>false</default>
</entry>
......
Markdown is supported
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