2023-07-17 10:49:06 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Material
|
2022-09-29 18:05:06 +02:00
|
|
|
|
|
|
|
|
import org.electrum 1.0
|
|
|
|
|
|
|
|
|
|
import "controls"
|
|
|
|
|
|
|
|
|
|
ElDialog {
|
|
|
|
|
id: dialog
|
|
|
|
|
|
2022-09-30 15:40:05 +02:00
|
|
|
title: qsTr('Trustedcoin')
|
2024-10-23 11:45:42 +02:00
|
|
|
iconSource: Qt.resolvedUrl('../../../plugins/trustedcoin/trustedcoin-status.png')
|
2022-09-29 18:05:06 +02:00
|
|
|
|
|
|
|
|
property string otpauth
|
|
|
|
|
|
2022-09-30 15:40:05 +02:00
|
|
|
property bool _waiting: false
|
|
|
|
|
property string _otpError
|
2022-09-29 18:05:06 +02:00
|
|
|
|
2022-09-30 15:40:05 +02:00
|
|
|
focus: true
|
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
width: parent.width
|
2022-09-29 18:05:06 +02:00
|
|
|
|
|
|
|
|
Label {
|
2022-09-30 15:40:05 +02:00
|
|
|
text: qsTr('Enter Authenticator code')
|
|
|
|
|
font.pixelSize: constants.fontSizeLarge
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2022-09-29 18:05:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextField {
|
|
|
|
|
id: otpEdit
|
2022-09-30 15:40:05 +02:00
|
|
|
Layout.preferredWidth: fontMetrics.advanceWidth(passwordCharacter) * 6
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
font.pixelSize: constants.fontSizeXXLarge
|
|
|
|
|
maximumLength: 6
|
|
|
|
|
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhDigitsOnly
|
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
|
focus: true
|
2023-02-09 12:20:50 +01:00
|
|
|
enabled: !_waiting
|
|
|
|
|
Keys.onPressed: _otpError = ''
|
2022-09-30 15:40:05 +02:00
|
|
|
onTextChanged: {
|
2023-02-09 12:20:50 +01:00
|
|
|
if (text.length == 6) {
|
|
|
|
|
_waiting = true
|
|
|
|
|
Daemon.currentWallet.submitOtp(otpEdit.text)
|
|
|
|
|
}
|
2022-09-30 15:40:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Label {
|
2023-02-09 12:20:50 +01:00
|
|
|
Layout.topMargin: constants.paddingMedium
|
|
|
|
|
Layout.bottomMargin: constants.paddingMedium
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2024-06-17 16:30:32 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
|
wrapMode: Text.Wrap
|
2023-02-09 12:20:50 +01:00
|
|
|
|
2022-09-30 15:40:05 +02:00
|
|
|
text: _otpError
|
|
|
|
|
color: constants.colorError
|
2022-09-29 18:05:06 +02:00
|
|
|
|
2023-02-09 12:20:50 +01:00
|
|
|
BusyIndicator {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
width: constants.iconSizeXLarge
|
|
|
|
|
height: constants.iconSizeXLarge
|
|
|
|
|
visible: _waiting
|
|
|
|
|
running: _waiting
|
2022-09-29 18:05:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-30 15:40:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
|
target: Daemon.currentWallet
|
|
|
|
|
function onOtpSuccess() {
|
|
|
|
|
_waiting = false
|
|
|
|
|
otpauth = otpEdit.text
|
|
|
|
|
dialog.accept()
|
|
|
|
|
}
|
|
|
|
|
function onOtpFailed(code, message) {
|
|
|
|
|
_waiting = false
|
|
|
|
|
_otpError = message
|
|
|
|
|
otpEdit.text = ''
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-29 18:05:06 +02:00
|
|
|
|
2022-09-30 15:40:05 +02:00
|
|
|
FontMetrics {
|
|
|
|
|
id: fontMetrics
|
|
|
|
|
font: otpEdit.font
|
2022-09-29 18:05:06 +02:00
|
|
|
}
|
|
|
|
|
}
|