diff options
| author | xiphon <xiphon@protonmail.com> | 2019-11-13 08:02:19 +0000 |
|---|---|---|
| committer | xiphon <xiphon@protonmail.com> | 2019-11-13 08:10:49 +0000 |
| commit | e9cdaf4dbe1f0ec125390f3ce328c9d09adc4237 (patch) | |
| tree | 97c166c865d568134315d39e5b2b9264e4805c6b | |
| parent | 7f7a39292c57f9b51090005d8a8e39297d988e0b (diff) | |
| download | monzero-gui-e9cdaf4dbe1f0ec125390f3ce328c9d09adc4237.tar.gz monzero-gui-e9cdaf4dbe1f0ec125390f3ce328c9d09adc4237.tar.xz monzero-gui-e9cdaf4dbe1f0ec125390f3ce328c9d09adc4237.zip | |
Transfer: convert and display entered amount in fiat currency
| -rw-r--r-- | LeftPanel.qml | 2 | ||||
| -rw-r--r-- | components/LineEdit.qml | 2 | ||||
| -rw-r--r-- | main.qml | 27 | ||||
| -rw-r--r-- | pages/Transfer.qml | 4 |
4 files changed, 28 insertions, 7 deletions
diff --git a/LeftPanel.qml b/LeftPanel.qml index a9f01cfa..308e1954 100644 --- a/LeftPanel.qml +++ b/LeftPanel.qml @@ -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" } diff --git a/components/LineEdit.qml b/components/LineEdit.qml index 68e981fa..554140d9 100644 --- a/components/LineEdit.qml +++ b/components/LineEdit.qml @@ -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: { @@ -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; } diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 3e93339c..bea913db 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -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") |
