diff --git a/autotests/propertyinfotest.cpp b/autotests/propertyinfotest.cpp --- a/autotests/propertyinfotest.cpp +++ b/autotests/propertyinfotest.cpp @@ -130,8 +130,9 @@ // 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 s")}, + { Property::PhotoExposureTime, true, 0.5, QStringLiteral("0.5 s")}, + { Property::PhotoExposureTime, true, 0.15, QStringLiteral("0.15 s")}, { Property::PhotoFNumber, true, 4.0, QStringLiteral("f/4")}, { Property::PhotoFNumber, true, 2.8, QStringLiteral("f/2.8")}, { Property::ReplayGainAlbumGain, true, -9.90, QStringLiteral("-9.9")}, diff --git a/src/formatstrings.cpp b/src/formatstrings.cpp --- a/src/formatstrings.cpp +++ b/src/formatstrings.cpp @@ -158,6 +158,19 @@ return i18nc("Symbol of frames per second, with space", "%1 fps", QLocale().toString(round(value.toDouble() * 100) / 100)); } +QString FormatStrings::formatPhotoTime(const QVariant& value) +{ + auto val = value.toDouble(); + if (val < 0.3 && !qFuzzyIsNull(val)) { + auto reciprocal = 1.0/val; + auto roundedReciprocal = round(reciprocal); + if (abs(reciprocal - roundedReciprocal) < 1e-3) { + return i18nc("Time period given in seconds as rational number, denominator is given", "1/%1 s", roundedReciprocal); + } + } + return i18nc("Time period given in seconds", "%1 s", QLocale().toString(value.toDouble(), 'g', 3)); +} + 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 formatPhotoTime(const QVariant& value); + static QString formatAspectRatio(const QVariant& value); static QString formatAsFNumber(const QVariant& value); diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -258,7 +258,7 @@ d->name = QStringLiteral("photoExposureTime"); d->displayName = i18nc("@label EXIF", "Photo Exposure Time"); d->valueType = QVariant::Double; - d->formatAsString = &FormatStrings::formatDouble; + d->formatAsString = &FormatStrings::formatPhotoTime; break; case Property::PhotoFlash: