diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 7cfc26512..641ae4e66 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -258,6 +258,42 @@ Pane { text: qsTr('Lightning') } + Label { + Layout.fillWidth: true + text: Config.shortDescFor('LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS') + wrapMode: Text.Wrap + } + + Label { + Layout.fillWidth: true + text: qsTr('%1% of payment').arg(maxfeeslider._fees[maxfeeslider.value]/10000) + wrapMode: Text.Wrap + } + + Slider { + id: maxfeeslider + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.leftMargin: constants.paddingXLarge + Layout.rightMargin: constants.paddingXLarge + + property var _fees: [500, 1000, 3000, 5000, 10000, 20000, 30000, 50000] + + snapMode: Slider.SnapOnRelease + stepSize: 1 + from: 0 + to: _fees.length - 1 + + onValueChanged: { + if (activeFocus) + Config.lightningPaymentFeeMaxMillionths = _fees[value] + } + + Component.onCompleted: { + value = _fees.indexOf(Config.lightningPaymentFeeMaxMillionths) + } + } + RowLayout { Layout.columnSpan: 2 Layout.fillWidth: true diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py index 534e3cdf0..2330637f3 100644 --- a/electrum/gui/qml/qeconfig.py +++ b/electrum/gui/qml/qeconfig.py @@ -23,6 +23,16 @@ class QEConfig(AuthMixin, QObject): super().__init__(parent) self.config = config + @pyqtSlot(str, result=str) + def shortDescFor(self, key) -> str: + cv = getattr(self.config.cv, key) + return cv.get_short_desc() if cv else '' + + @pyqtSlot(str, result=str) + def longDescFor(self, key) -> str: + cv = getattr(self.config.cv, key) + return cv.get_long_desc() if cv else '' + languageChanged = pyqtSignal() @pyqtProperty(str, notify=languageChanged) def language(self): @@ -255,6 +265,17 @@ class QEConfig(AuthMixin, QObject): self.config.WALLET_COIN_CHOOSER_OUTPUT_ROUNDING = outputValueRounding self.outputValueRoundingChanged.emit() + lightningPaymentFeeMaxMillionthsChanged = pyqtSignal() + @pyqtProperty(int, notify=lightningPaymentFeeMaxMillionthsChanged) + def lightningPaymentFeeMaxMillionths(self): + return self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS + + @lightningPaymentFeeMaxMillionths.setter + def lightningPaymentFeeMaxMillionths(self, lightningPaymentFeeMaxMillionths): + if lightningPaymentFeeMaxMillionths != self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS: + self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS = lightningPaymentFeeMaxMillionths + self.lightningPaymentFeeMaxMillionthsChanged.emit() + @pyqtSlot('qint64', result=str) @pyqtSlot(QEAmount, result=str) def formatSatsForEditing(self, satoshis):