qml: 2fa: make 2fa setup qr code clickable

This will make the 2fa app open when the user clicks on the qr code,
much more convenient than manually copy pasting the secret.
This commit is contained in:
f321x
2026-03-24 14:32:46 +01:00
parent 37159e47a2
commit cb023e22e4
2 changed files with 15 additions and 1 deletions
@@ -8,6 +8,8 @@ Item {
property bool enableToggleText: false // if true, clicking the QR code shows the encoded text property bool enableToggleText: false // if true, clicking the QR code shows the encoded text
property bool isTextState: false // internal state, if the above is enabled property bool isTextState: false // internal state, if the above is enabled
signal clicked()
property var _qrprops: QRIP.getDimensions(qrdata) property var _qrprops: QRIP.getDimensions(qrdata)
width: r.width width: r.width
@@ -71,6 +73,8 @@ Item {
onClicked: { onClicked: {
if (enableToggleText) { if (enableToggleText) {
root.isTextState = !root.isTextState root.isTextState = !root.isTextState
} else {
root.clicked()
} }
} }
} }
@@ -40,6 +40,16 @@ WizardComponent {
qrdata: encodeURI('otpauth://totp/Electrum 2FA ' + wizard_data['wallet_name'] qrdata: encodeURI('otpauth://totp/Electrum 2FA ' + wizard_data['wallet_name']
+ '?secret=' + plugin.otpSecret + '&digits=6') + '?secret=' + plugin.otpSecret + '&digits=6')
render: plugin.otpSecret render: plugin.otpSecret
onClicked: {
if (plugin.otpSecret) {
if (AppController.isAndroid()) {
Qt.openUrlExternally(qrdata)
} else {
AppController.textToClipboard(plugin.otpSecret)
toaster.show(this, qsTr('Copied!'))
}
}
}
} }
Item { Item {
@@ -68,7 +78,7 @@ WizardComponent {
Layout.fillWidth: true Layout.fillWidth: true
visible: !otpVerified && plugin.otpSecret visible: !otpVerified && plugin.otpSecret
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: qsTr('Enter or scan into authenticator app. Then authenticate below') text: qsTr('Tap the QR code to open in your authenticator app, or scan it manually. Then authenticate below')
} }
Label { Label {