diff options
| author | dsc <xmrdsc@protonmail.com> | 2019-05-01 04:05:16 +0200 |
|---|---|---|
| committer | xmrdsc <xmrdsc@protonmail.com> | 2019-05-06 04:36:23 +0200 |
| commit | d4be7634cbc80cd40c2ff8456bcd962b21b2dcb6 (patch) | |
| tree | 7fe6aa54f2935adc94d829c875b2300db272810c /pages/settings/SettingsLayout.qml | |
| parent | 3c1fe1da8b83738cb76a1a1242514bbe4ba515e6 (diff) | |
| download | monzero-gui-d4be7634cbc80cd40c2ff8456bcd962b21b2dcb6.tar.gz monzero-gui-d4be7634cbc80cd40c2ff8456bcd962b21b2dcb6.tar.xz monzero-gui-d4be7634cbc80cd40c2ff8456bcd962b21b2dcb6.zip | |
Fiat API
Co-Authored-By: selsta <selsta@sent.at>
Co-Authored-By: Gene Peters <gene@telligent-data.com>
Diffstat (limited to 'pages/settings/SettingsLayout.qml')
| -rw-r--r-- | pages/settings/SettingsLayout.qml | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/pages/settings/SettingsLayout.qml b/pages/settings/SettingsLayout.qml index d1945281..f4b3d0b6 100644 --- a/pages/settings/SettingsLayout.qml +++ b/pages/settings/SettingsLayout.qml @@ -157,6 +157,106 @@ Rectangle { } } + //! Manage pricing + RowLayout { + MoneroComponents.CheckBox { + id: enableConvertCurrency + text: qsTr("Enable displaying balance in other currencies") + translationManager.emptyString + checked: persistentSettings.fiatPriceEnabled + onCheckedChanged: { + if (!checked) { + console.log("Disabled price conversion"); + persistentSettings.fiatPriceEnabled = false; + appWindow.fiatTimerStop(); + } + } + } + } + + GridLayout { + visible: enableConvertCurrency.checked + columns: 2 + Layout.fillWidth: true + Layout.leftMargin: 36 + columnSpacing: 32 + + ColumnLayout { + spacing: 10 + Layout.fillWidth: true + + MoneroComponents.Label { + Layout.fillWidth: true + fontSize: 14 + text: qsTr("Price source") + translationManager.emptyString + } + + MoneroComponents.StandardDropdown { + id: fiatPriceProviderDropDown + Layout.fillWidth: true + dataModel: fiatPriceProvidersModel + onChanged: { + var obj = dataModel.get(currentIndex); + persistentSettings.fiatPriceProvider = obj.data; + + if(persistentSettings.fiatPriceEnabled) + appWindow.fiatApiRefresh(); + } + } + } + + ColumnLayout { + spacing: 10 + Layout.fillWidth: true + + MoneroComponents.Label { + Layout.fillWidth: true + fontSize: 14 + text: qsTr("Currency") + translationManager.emptyString + } + + MoneroComponents.StandardDropdown { + id: fiatPriceCurrencyDropdown + Layout.fillWidth: true + dataModel: fiatPriceCurrencyModel + onChanged: { + var obj = dataModel.get(currentIndex); + persistentSettings.fiatPriceCurrency = obj.data; + + if(persistentSettings.fiatPriceEnabled) + appWindow.fiatApiRefresh(); + } + } + } + + z: parent.z + 1 + } + + ColumnLayout { + // Feature needs to be double enabled for security purposes (miss-clicks) + visible: enableConvertCurrency.checked && !persistentSettings.fiatPriceEnabled + spacing: 0 + Layout.topMargin: 5 + Layout.leftMargin: 36 + + MoneroComponents.WarningBox { + text: qsTr("Enabling price conversion exposes your IP address to the selected price source.") + translationManager.emptyString; + } + + MoneroComponents.StandardButton { + Layout.topMargin: 10 + Layout.bottomMargin: 10 + small: true + text: qsTr("Confirm and enable") + translationManager.emptyString + + onClicked: { + console.log("Enabled price conversion"); + persistentSettings.fiatPriceEnabled = true; + appWindow.fiatApiRefresh(); + appWindow.fiatTimerStart(); + } + } + } + MoneroComponents.StandardButton { visible: !persistentSettings.customDecorations Layout.topMargin: 10 @@ -177,7 +277,43 @@ Rectangle { } } + ListModel { + id: fiatPriceProvidersModel + } + + ListModel { + id: fiatPriceCurrencyModel + ListElement { + data: "xmrusd" + column1: "USD" + } + ListElement { + data: "xmreur" + column1: "EUR" + } + } + Component.onCompleted: { + // Dynamically fill fiatPrice dropdown based on `appWindow.fiatPriceAPIs` + var apis = appWindow.fiatPriceAPIs; + fiatPriceProvidersModel.clear(); + + var i = 0; + for (var api in apis){ + if (!apis.hasOwnProperty(api)) + continue; + + fiatPriceProvidersModel.append({"column1": Utils.capitalize(api), "data": api}); + + if(api === persistentSettings.fiatPriceProvider) + fiatPriceProviderDropDown.currentIndex = i; + i += 1; + } + + fiatPriceProviderDropDown.update(); + fiatPriceCurrencyDropdown.currentIndex = persistentSettings.fiatPriceCurrency === "xmrusd" ? 0 : 1; + fiatPriceCurrencyDropdown.update(); + console.log('SettingsLayout loaded'); } } |
