mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Remove non-breaking space from currency strings
This commit is contained in:
		
							parent
							
								
									9b4e0e29e4
								
							
						
					
					
						commit
						2e481507e8
					
				
					 2 changed files with 24 additions and 8 deletions
				
			
		| 
						 | 
					@ -566,19 +566,33 @@ QString Utils::formatBytes(quint64 bytes)
 | 
				
			||||||
    return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]);
 | 
					    return QString("%1 %2").arg(QString::number(_data, 'f', 1), sizes[i]);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode) {
 | 
					
 | 
				
			||||||
 | 
					QMap<QString, QLocale> Utils::localeCache = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QLocale Utils::getCurrencyLocale(const QString ¤cyCode) {
 | 
				
			||||||
    QLocale locale;
 | 
					    QLocale locale;
 | 
				
			||||||
    QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
 | 
					    if (localeCache.contains(currencyCode)) {
 | 
				
			||||||
    for (const auto& locale_: allLocales) {
 | 
					        locale = localeCache[currencyCode];
 | 
				
			||||||
        if (locale_.currencySymbol(QLocale::CurrencyIsoCode) == currencyCode) {
 | 
					    } else {
 | 
				
			||||||
            locale = 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_;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        localeCache[currencyCode] = locale;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    return locale;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode) {
 | 
				
			||||||
 | 
					    QLocale locale = getCurrencyLocale(currencyCode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // \xC2\xA0 = UTF-8 non-breaking space, it looks off.
 | 
				
			||||||
    if (currencyCode == "USD")
 | 
					    if (currencyCode == "USD")
 | 
				
			||||||
        return locale.toCurrencyString(amount, "$");
 | 
					        return locale.toCurrencyString(amount, "$").remove("\xC2\xA0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return locale.toCurrencyString(amount);
 | 
					    return locale.toCurrencyString(amount).remove("\xC2\xA0");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int Utils::maxLength(const QVector<QString> &array) {
 | 
					int Utils::maxLength(const QVector<QString> &array) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,8 +95,10 @@ public:
 | 
				
			||||||
    static QFont relativeFont(int delta);
 | 
					    static QFont relativeFont(int delta);
 | 
				
			||||||
    static double roundSignificant(double N, double n);
 | 
					    static double roundSignificant(double N, double n);
 | 
				
			||||||
    static QString formatBytes(quint64 bytes);
 | 
					    static QString formatBytes(quint64 bytes);
 | 
				
			||||||
 | 
					    static QLocale getCurrencyLocale(const QString ¤cyCode);
 | 
				
			||||||
    static QString amountToCurrencyString(double amount, const QString ¤cyCode);
 | 
					    static QString amountToCurrencyString(double amount, const QString ¤cyCode);
 | 
				
			||||||
    static int maxLength(const QVector<QString> &array);
 | 
					    static int maxLength(const QVector<QString> &array);
 | 
				
			||||||
 | 
					    static QMap<QString, QLocale> localeCache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    template<typename QEnum>
 | 
					    template<typename QEnum>
 | 
				
			||||||
    static QString QtEnumToString (const QEnum value)
 | 
					    static QString QtEnumToString (const QEnum value)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue