Fix money input field limit without decimal separator.

This commit is contained in:
John Preston 2021-04-19 10:52:14 +04:00
parent 286cb74620
commit c242a61e8c
2 changed files with 17 additions and 9 deletions

View file

@ -96,7 +96,6 @@ struct SimpleFieldState {
if (decimalPosition >= 0) { if (decimalPosition >= 0) {
Assert(decimalPosition >= skip); Assert(decimalPosition >= skip);
decimalPosition -= skip; decimalPosition -= skip;
}
if (decimalPosition > digitsLimit) { if (decimalPosition > digitsLimit) {
state = { state = {
.value = (state.value.mid(0, digitsLimit) .value = (state.value.mid(0, digitsLimit)
@ -108,6 +107,12 @@ struct SimpleFieldState {
: state.position), : state.position),
}; };
} }
} else if (state.value.size() > digitsLimit) {
state = {
.value = state.value.mid(0, digitsLimit),
.position = std::min(state.position, digitsLimit),
};
}
return state; return state;
} }

View file

@ -131,6 +131,9 @@ QString FillAmountAndCurrency(
int64 amount, int64 amount,
const QString &currency, const QString &currency,
bool forceStripDotZero) { bool forceStripDotZero) {
// std::abs doesn't work on that one :/
Expects(amount != std::numeric_limits<int64>::min());
const auto rule = LookupCurrencyRule(currency); const auto rule = LookupCurrencyRule(currency);
const auto prefix = (amount < 0) const auto prefix = (amount < 0)