aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/settings/SettingsLayout.qml136
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');
}
}