diff --git a/autotests/propertyinfotest.cpp b/autotests/propertyinfotest.cpp --- a/autotests/propertyinfotest.cpp +++ b/autotests/propertyinfotest.cpp @@ -142,6 +142,8 @@ { Property::FrameRate, true, 23, QStringLiteral("23 fps")}, { Property::FrameRate, true, 23.976, QStringLiteral("23.98 fps")}, { Property::AspectRatio, true, 1.77778, QStringLiteral("1.78:1")}, + { Property::PhotoFocalLength, true, 2.0, QStringLiteral("2 mm")}, + { Property::PhotoFocalLength, true, 2.4, QStringLiteral("2.4 mm")}, }; for (auto row : rows) { diff --git a/src/formatstrings.cpp b/src/formatstrings.cpp --- a/src/formatstrings.cpp +++ b/src/formatstrings.cpp @@ -153,6 +153,11 @@ return form.formatValue(value.toDouble(), KFormat::Unit::Meter, 1, KFormat::UnitPrefix::AutoAdjust, KFormat::MetricBinaryDialect); } +QString FormatStrings::formatAsMilliMeter(const QVariant& value) +{ + return i18nc("Focal length given in mm", "%1 mm", QLocale().toString(value.toDouble(), 'g', 3)); +} + QString FormatStrings::formatAsFrameRate(const QVariant& value) { return i18nc("Symbol of frames per second, with space", "%1 fps", QLocale().toString(round(value.toDouble() * 100) / 100)); diff --git a/src/formatstrings_p.h b/src/formatstrings_p.h --- a/src/formatstrings_p.h +++ b/src/formatstrings_p.h @@ -49,6 +49,8 @@ static QString formatAsMeter(const QVariant& value); + static QString formatAsMilliMeter(const QVariant& value); + static QString formatAsFrameRate(const QVariant& value); static QString formatPhotoTime(const QVariant& value); diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -279,14 +279,14 @@ d->name = QStringLiteral("photoFocalLength"); d->displayName = i18nc("@label EXIF", "Photo Focal Length"); d->valueType = QVariant::Double; - d->formatAsString = &FormatStrings::formatDouble; + d->formatAsString = &FormatStrings::formatAsMilliMeter; break; case Property::PhotoFocalLengthIn35mmFilm: d->name = QStringLiteral("photoFocalLengthIn35mmFilm"); d->displayName = i18nc("@label EXIF", "Photo Focal Length 35mm"); d->valueType = QVariant::Double; - d->formatAsString = &FormatStrings::formatDouble; + d->formatAsString = &FormatStrings::formatAsMilliMeter; break; case Property::PhotoGpsLatitude: