mirror of
https://github.com/monero-project/monero-gui
synced 2024-12-18 05:15:54 +01:00
Transfer: convert and display entered amount in fiat currency
This commit is contained in:
parent
7f7a39292c
commit
e9cdaf4dbe
@ -238,7 +238,7 @@ Rectangle {
|
||||
font.pixelSize: 16
|
||||
text: {
|
||||
if (persistentSettings.fiatPriceEnabled && persistentSettings.fiatPriceToggle) {
|
||||
return persistentSettings.fiatPriceCurrency == "xmrusd" ? "USD" : "EUR"
|
||||
return appWindow.fiatApiCurrencySymbol();
|
||||
} else {
|
||||
return "XMR"
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ Item {
|
||||
property alias inlineButtonText: inlineButtonId.text
|
||||
property alias inlineIcon: inlineIcon.visible
|
||||
property bool copyButton: false
|
||||
property alias copyButtonText: copyButtonId.text
|
||||
property alias copyButtonEnabled: copyButtonId.enabled
|
||||
|
||||
property bool borderDisabled: false
|
||||
property string borderColor: {
|
||||
|
27
main.qml
27
main.qml
@ -1241,17 +1241,32 @@ ApplicationWindow {
|
||||
Prices.getJSON(url);
|
||||
}
|
||||
|
||||
function fiatApiUpdateBalance(balance){
|
||||
// update balance card
|
||||
function fiatApiCurrencySymbol() {
|
||||
switch (persistentSettings.fiatPriceCurrency) {
|
||||
case "xmrusd":
|
||||
return "USD";
|
||||
case "xmreur":
|
||||
return "EUR";
|
||||
default:
|
||||
console.error("unsupported currency", persistentSettings.fiatPriceCurrency);
|
||||
return "UNSUPPORTED";
|
||||
}
|
||||
}
|
||||
|
||||
function fiatApiConvertToFiat(amount) {
|
||||
var ticker = persistentSettings.fiatPriceCurrency === "xmrusd" ? appWindow.fiatPriceXMRUSD : appWindow.fiatPriceXMREUR;
|
||||
if(ticker <= 0){
|
||||
console.log(fiatApiError("Could not update balance card; invalid ticker value"));
|
||||
leftPanel.balanceFiatString = "?.??";
|
||||
return;
|
||||
console.log(fiatApiError("Invalid ticker value: " + ticker));
|
||||
return "?.??";
|
||||
}
|
||||
return (amount * ticker).toFixed(2);
|
||||
}
|
||||
|
||||
function fiatApiUpdateBalance(balance){
|
||||
// update balance card
|
||||
var bFiat = "?.??"
|
||||
if (!hideBalanceForced && !persistentSettings.hideBalance) {
|
||||
bFiat = (balance * ticker).toFixed(2);
|
||||
bFiat = fiatApiConvertToFiat(balance);
|
||||
}
|
||||
leftPanel.balanceFiatString = bFiat;
|
||||
}
|
||||
|
@ -168,6 +168,10 @@ Rectangle {
|
||||
labelText: qsTr("<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style>\
|
||||
Amount <font size='2'> ( </font> <a href='#'>Change account</a><font size='2'> )</font>")
|
||||
+ translationManager.emptyString
|
||||
copyButton: persistentSettings.fiatPriceEnabled
|
||||
copyButtonText: fiatApiCurrencySymbol() + " ~" + fiatApiConvertToFiat(amountLine.text)
|
||||
copyButtonEnabled: false
|
||||
|
||||
onLabelLinkActivated: {
|
||||
middlePanel.accountView.selectAndSend = true;
|
||||
appWindow.showPageRequest("Account")
|
||||
|
Loading…
Reference in New Issue
Block a user