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