diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2019-11-13 09:08:16 -0600 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2019-11-13 09:08:16 -0600 |
| commit | cf0e5a811e1ac3cd98607f70d9d479ba735d9353 (patch) | |
| tree | d5249e41966cbaa82ea7bdec7499fa62016082a2 | |
| parent | ea8f51d16818789da361e0c3141b60b2ed1039d1 (diff) | |
| parent | e9cdaf4dbe1f0ec125390f3ce328c9d09adc4237 (diff) | |
| download | monzero-gui-cf0e5a811e1ac3cd98607f70d9d479ba735d9353.tar.gz monzero-gui-cf0e5a811e1ac3cd98607f70d9d479ba735d9353.tar.xz monzero-gui-cf0e5a811e1ac3cd98607f70d9d479ba735d9353.zip | |
Merge pull request #2440
e9cdaf4 Transfer: convert and display entered amount in fiat currency (xiphon)
| -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 69b35b38..f5f8cb2a 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") |
