From 99951a437caef0057aa7d857df05649a19decad0 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Fri, 6 Jan 2023 14:40:39 +0100 Subject: [PATCH] qml: make trampoline vs gossip routing a switch, and ask confirmation for selecting gossip mode --- electrum/gui/qml/components/Preferences.qml | 45 +++++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 46492ad09..742436398 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -249,19 +249,38 @@ Pane { text: qsTr('Lightning Routing') } - ElComboBox { - id: lnRoutingType - enabled: Daemon.currentWallet && Daemon.currentWallet.isLightning - - valueRole: 'key' - textRole: 'label' - model: ListModel { - ListElement { key: 'gossip'; label: qsTr('Gossip') } - ListElement { key: 'trampoline'; label: qsTr('Trampoline') } + RowLayout { + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.leftMargin: -constants.paddingSmall + spacing: 0 + Switch { + id: useTrampolineRouting + onCheckedChanged: { + if (activeFocus) { + if (!checked) { + var dialog = app.messageDialog.createObject(app, { + text: qsTr('Using plain gossip mode is not recommended. Are you sure?'), + yesno: true + }) + dialog.yesClicked.connect(function() { + Config.useGossip = true + }) + dialog.noClicked.connect(function() { + checked = true // revert + }) + dialog.open() + } else { + Config.useGossip = !checked + } + } + + } } - onCurrentValueChanged: { - if (activeFocus) - Config.useGossip = currentValue == 'gossip' + Label { + Layout.fillWidth: true + text: qsTr('Trampoline routing') + wrapMode: Text.Wrap } } @@ -347,7 +366,7 @@ Pane { rateSources.currentIndex = rateSources.indexOfValue(Daemon.fx.rateSource) fiatEnable.checked = Daemon.fx.enabled spendUnconfirmed.checked = Config.spendUnconfirmed - lnRoutingType.currentIndex = Config.useGossip ? 0 : 1 + useTrampolineRouting.checked = !Config.useGossip useFallbackAddress.checked = Config.useFallbackAddress enableDebugLogs.checked = Config.enableDebugLogs useRecoverableChannels.checked = Config.useRecoverableChannels