Changeset View
Changeset View
Standalone View
Standalone View
src/formatstrings.cpp
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 169 | if (val < 0.3 && !qFuzzyIsNull(val)) { | |||
---|---|---|---|---|---|
171 | auto roundedReciprocal = round(reciprocal); | 171 | auto roundedReciprocal = round(reciprocal); | ||
172 | if (abs(reciprocal - roundedReciprocal) < 1e-3) { | 172 | if (abs(reciprocal - roundedReciprocal) < 1e-3) { | ||
173 | return i18nc("Time period given in seconds as rational number, denominator is given", "1/%1 s", roundedReciprocal); | 173 | return i18nc("Time period given in seconds as rational number, denominator is given", "1/%1 s", roundedReciprocal); | ||
174 | } | 174 | } | ||
175 | } | 175 | } | ||
176 | return i18nc("Time period given in seconds", "%1 s", QLocale().toString(value.toDouble(), 'g', 3)); | 176 | return i18nc("Time period given in seconds", "%1 s", QLocale().toString(value.toDouble(), 'g', 3)); | ||
177 | } | 177 | } | ||
178 | 178 | | |||
179 | QString FormatStrings::formatPhotoExposureBias(const QVariant& value) | ||||
180 | { | ||||
181 | QLocale locale; | ||||
182 | auto val = value.toDouble(); | ||||
183 | // exposure values are in steps of one third, divide by it | ||||
bruns: You obviously multiply here ... | |||||
astippich: dividing by one third is multiplying by three :) | |||||
184 | auto thirds = val * 3; | ||||
185 | int roundedThirds = static_cast<int>(round(thirds)); | ||||
186 | int remainder = roundedThirds % 3; | ||||
187 | if (remainder != 0 && abs(thirds - roundedThirds) < 1e-3) { | ||||
188 | int wholeNumber = roundedThirds / 3; | ||||
189 | if (wholeNumber > 0) { | ||||
bruns: this is probably not working for e.g. "-1 1/3" | |||||
190 | return i18nc("Exposure compensation given in thirds, with whole number, in exposure value (EV)", "%1 %2/3 EV", locale.toString(wholeNumber), locale.toString(remainder)); | ||||
191 | } else { | ||||
192 | return i18nc("Exposure compensation given in thirds, in exposure value (EV)", "%1/3 EV", locale.toString(remainder)); | ||||
193 | } | ||||
bruns: no need for else here, you return. dito below | |||||
194 | } | ||||
195 | return i18nc("Exposure bias/compensation in exposure value (EV)", "%1 EV", locale.toString(val, 'g', 3)); | ||||
196 | } | ||||
197 | | ||||
179 | QString FormatStrings::formatAspectRatio(const QVariant& value) | 198 | QString FormatStrings::formatAspectRatio(const QVariant& value) | ||
180 | { | 199 | { | ||
181 | return i18nc("Aspect ratio, normalized to one", "%1:1", QLocale().toString(round(value.toDouble() * 100) / 100)); | 200 | return i18nc("Aspect ratio, normalized to one", "%1:1", QLocale().toString(round(value.toDouble() * 100) / 100)); | ||
182 | } | 201 | } | ||
183 | 202 | | |||
184 | QString FormatStrings::formatAsFNumber(const QVariant& value) | 203 | QString FormatStrings::formatAsFNumber(const QVariant& value) | ||
185 | { | 204 | { | ||
186 | return i18nc("F number for photographs", "f/%1", QLocale().toString(value.toDouble(), 'g', 2)); | 205 | return i18nc("F number for photographs", "f/%1", QLocale().toString(value.toDouble(), 'g', 2)); | ||
187 | } | 206 | } |
You obviously multiply here ...