mirror of
https://github.com/wownero/wowlet.git
synced 2026-10-20 16:48:39 +02:00
TickerWidget: Format fiat currency using locale
This commit is contained in:
@@ -581,4 +581,19 @@ QString Utils::formatBytes(quint64 bytes)
|
||||
_data = 0;
|
||||
|
||||
return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]);
|
||||
}
|
||||
|
||||
QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode) {
|
||||
QLocale locale;
|
||||
QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
|
||||
for (const auto& locale_: allLocales) {
|
||||
if (locale_.currencySymbol(QLocale::CurrencyIsoCode) == currencyCode) {
|
||||
locale = locale_;
|
||||
}
|
||||
}
|
||||
|
||||
if (currencyCode == "USD")
|
||||
return locale.toCurrencyString(amount, "$");
|
||||
|
||||
return locale.toCurrencyString(amount);
|
||||
}
|
||||
Reference in New Issue
Block a user