diff --git a/lib/crop/cropwidget.cpp b/lib/crop/cropwidget.cpp --- a/lib/crop/cropwidget.cpp +++ b/lib/crop/cropwidget.cpp @@ -144,11 +144,25 @@ return 0; } + /** + * label: if empty then the ratio "x:y" is the label + * else if contains _1 then _1 is replaced with the ratio "x:y" + * else label is taken as is + */ void addRatioToComboBox(const QSizeF& size, const QString& label = QString()) { - QString text = label.isEmpty() - ? QStringLiteral("%1:%2").arg(size.width()).arg(size.height()) - : label; + QString text; + if (label.isEmpty() || label.contains(QStringLiteral("_1"))) { + QString ratio = QStringLiteral("%1:%2").arg(size.width()).arg(size.height()); + if (label.isEmpty()) { + text = ratio; + } else { + text = label; + text.replace(QStringLiteral("_1"), ratio); + } + } else { + text = label; + } ratioComboBox->addItem(text, QVariant(size)); } @@ -179,19 +193,25 @@ << QSizeF(4, 3) << QSizeF(5, 4); - addRatioToComboBox(ratio(mDocument->size()), i18n("Current Image")); + const QSize& documentRatio = ratio(mDocument->size()); + addRatioToComboBox(documentRatio, i18nc("_1 is aspect ratio", "Current Image (_1)")); mCurrentImageComboBoxIndex = ratioComboBox->count() - 1; // We need to refer to this ratio later addRatioToComboBox(QSizeF(1, 1), i18n("Square")); addRatioToComboBox(ratio(QApplication::desktop()->screenGeometry().size()), i18n("This Screen")); addSectionHeaderToComboBox(i18n("Landscape")); - + if (documentRatio.width() < documentRatio.height()) { // only if image is Portrait then add transposed ratio here; MINOR ISSUE: if the image is rotated by 90 degree then the Crop tool has to be selected again to update the combobox accordingly + addRatioToComboBox(documentRatio.transposed(), i18nc("_1 is aspect ratio", "Current Image (_1)")); + } Q_FOREACH(const QSizeF& size, ratioList) { addRatioToComboBox(size); } addRatioToComboBox(QSizeF(sqrt2, 1), i18n("ISO (A4, A3...)")); addRatioToComboBox(QSizeF(11, 8.5), i18n("US Letter")); addSectionHeaderToComboBox(i18n("Portrait")); + if (documentRatio.width() > documentRatio.height()) { // only if image is Landscape then add transposed ratio here + addRatioToComboBox(documentRatio.transposed(), i18nc("_1 is aspect ratio", "Current Image (_1)")); + } Q_FOREACH(QSizeF size, ratioList) { size.transpose(); addRatioToComboBox(size);