diff --git a/autotests/propertyinfotest.cpp b/autotests/propertyinfotest.cpp --- a/autotests/propertyinfotest.cpp +++ b/autotests/propertyinfotest.cpp @@ -130,8 +130,8 @@ // make VisualStudio compiler happy: QChar(0x00B0) = "°" { Property::PhotoGpsLatitude, true, 25, QStringLiteral("25") + QChar(0x00B0)}, { Property::PhotoGpsLongitude, true, 13.5, QStringLiteral("13.5") + QChar(0x00B0)}, - { Property::PhotoExposureTime, true, 0.0015625, QStringLiteral("0.00156")}, - { Property::PhotoExposureBiasValue, true, 0.3333333, QStringLiteral("0.333")}, + { Property::PhotoExposureTime, true, 0.0015625, QStringLiteral("1/640")}, + { Property::PhotoExposureBiasValue, true, 0.3333333, QStringLiteral("1/3")}, { Property::ReplayGainAlbumGain, true, -9.90, QStringLiteral("-9.9")}, { Property::ReplayGainAlbumPeak, true, 1.512, QStringLiteral("1.51")}, { Property::ReplayGainAlbumGain, true, 10.44, QStringLiteral("10.4")}, diff --git a/src/formatstrings.cpp b/src/formatstrings.cpp --- a/src/formatstrings.cpp +++ b/src/formatstrings.cpp @@ -158,6 +158,17 @@ return i18nc("Symbol of frames per second, with space", "%1 fps", QLocale().toString(round(value.toDouble() * 100) / 100)); } +QString FormatStrings::formatAsDoubleOrRationale(const QVariant& value) +{ + auto val = value.toDouble(); + if (val > 0.5 || qFuzzyIsNull(val)) { + return QLocale().toString(value.toDouble(), 'g', 3); + } else { + auto reciprocal = round(1.0 / val); + return i18nc("Rational number smaller than 1", "1/%1", reciprocal); + } +} + QString FormatStrings::formatAspectRatio(const QVariant& value) { return i18nc("Aspect ratio, normalized to one", "%1:1", 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 @@ -51,6 +51,8 @@ static QString formatAsFrameRate(const QVariant& value); + static QString formatAsDoubleOrRationale(const QVariant& value); + static QString formatAspectRatio(const QVariant& value); }; diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -251,14 +251,14 @@ d->name = QStringLiteral("photoExposureBiasValue"); d->displayName = i18nc("@label EXIF", "Photo Exposure Bias"); d->valueType = QVariant::Double; - d->formatAsString = &FormatStrings::formatDouble; + d->formatAsString = &FormatStrings::formatAsDoubleOrRationale; break; case Property::PhotoExposureTime: d->name = QStringLiteral("photoExposureTime"); d->displayName = i18nc("@label EXIF", "Photo Exposure Time"); d->valueType = QVariant::Double; - d->formatAsString = &FormatStrings::formatDouble; + d->formatAsString = &FormatStrings::formatAsDoubleOrRationale; break; case Property::PhotoFlash: