From 31523449b338b43f162e084f731a9b4b18df6901 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 9 Feb 2023 12:20:50 +0100 Subject: [PATCH] qml: OTP dialog improvements --- electrum/gui/qml/components/OtpDialog.qml | 29 +++++++++++++---------- electrum/gui/qml/qewallet.py | 4 +++- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/electrum/gui/qml/components/OtpDialog.qml b/electrum/gui/qml/components/OtpDialog.qml index 8b6a6d5f6..41ec51f85 100644 --- a/electrum/gui/qml/components/OtpDialog.qml +++ b/electrum/gui/qml/components/OtpDialog.qml @@ -44,27 +44,30 @@ ElDialog { inputMethodHints: Qt.ImhSensitiveData | Qt.ImhDigitsOnly echoMode: TextInput.Password focus: true + enabled: !_waiting + Keys.onPressed: _otpError = '' onTextChanged: { - if (activeFocus) - _otpError = '' + if (text.length == 6) { + _waiting = true + Daemon.currentWallet.submitOtp(otpEdit.text) + } } } Label { - opacity: _otpError ? 1 : 0 + Layout.topMargin: constants.paddingMedium + Layout.bottomMargin: constants.paddingMedium + Layout.alignment: Qt.AlignHCenter + text: _otpError color: constants.colorError - Layout.alignment: Qt.AlignHCenter - } - Button { - Layout.columnSpan: 2 - Layout.alignment: Qt.AlignHCenter - text: qsTr('Submit') - enabled: !_waiting - onClicked: { - _waiting = true - Daemon.currentWallet.submitOtp(otpEdit.text) + BusyIndicator { + anchors.centerIn: parent + width: constants.iconSizeXLarge + height: constants.iconSizeXLarge + visible: _waiting + running: _waiting } } } diff --git a/electrum/gui/qml/qewallet.py b/electrum/gui/qml/qewallet.py index 7e4961b1f..a86b95ff4 100644 --- a/electrum/gui/qml/qewallet.py +++ b/electrum/gui/qml/qewallet.py @@ -538,7 +538,9 @@ class QEWallet(AuthMixin, QObject, QtEventListener): @pyqtSlot(str) def submitOtp(self, otp): - self._otp_on_submit(otp) + def submit_otp_task(): + self._otp_on_submit(otp) + threading.Thread(target=submit_otp_task).start() def broadcast(self, tx): assert tx.is_complete()