diff --git a/ui/StatusQ/src/StatusQ/Components/StatusQrCodeCapture.qml b/ui/StatusQ/src/StatusQ/Components/StatusQrCodeCapture.qml index 5999fadac68..a61857cdc5e 100644 --- a/ui/StatusQ/src/StatusQ/Components/StatusQrCodeCapture.qml +++ b/ui/StatusQ/src/StatusQ/Components/StatusQrCodeCapture.qml @@ -55,7 +55,7 @@ Item { forwardVideoSink: videoOutput.videoSink scanning: true - captureRect: contentZoneHighlight + captureRect: captureRectangle onCapturedChanged: (tag) => { d.lastTag = tag @@ -74,7 +74,7 @@ Item { fillMode: VideoOutput.PreserveAspectCrop } Rectangle { - id: captureRect + id: captureRectangle width: root.captureRectWidth height: root.captureRectHeight anchors.centerIn: parent diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 9e0ae2c6f66..e6b084cd715 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -952,6 +952,17 @@ Item { } } onTransferOwnershipRequested: (tokenId, senderAddress) => popupRequestsHandler.sendModalHandler.transferOwnership(tokenId, senderAddress) + onWcUriScanned: uri => { + if (!dAppsServiceLoader.active || !dAppsServiceLoader.item) { + return + } + function pairingHandler() { + dAppsServiceLoader.item.dappsModule.pair(uri) + dAppsServiceLoader.item.pairingValidated.disconnect(pairingHandler) + } + dAppsServiceLoader.item.pairingValidated.connect(pairingHandler) + dAppsServiceLoader.item.validatePairingUri(uri) + } } HandlersManager { diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 96f0106f912..051151efa02 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -24,6 +24,7 @@ import AppLayouts.Wallet.popups.buy import AppLayouts.Wallet.popups import AppLayouts.Communities.stores import AppLayouts.Profile.helpers +import AppLayouts.Wallet.services.dapps import AppLayouts.Wallet.stores as WalletStores import AppLayouts.Chat.stores as ChatStores @@ -75,6 +76,7 @@ QtObject { signal saveDomainToUnfurledWhitelist(string domain) signal ownershipDeclined(string communityId, string communityName) signal transferOwnershipRequested(string tokenId, string senderAddress) + signal wcUriScanned(string uri) property var activePopupComponents: [] @@ -1509,6 +1511,8 @@ QtObject { return } Global.requestOpenLink(tag) + } else if (tagType === QRCodeScannerDialog.TagType.WCUri) { + root.wcUriScanned(tag) } } } diff --git a/ui/imports/shared/popups/QRCodeScannerDialog.qml b/ui/imports/shared/popups/QRCodeScannerDialog.qml index dd5fe9c17c9..cb509624ce4 100644 --- a/ui/imports/shared/popups/QRCodeScannerDialog.qml +++ b/ui/imports/shared/popups/QRCodeScannerDialog.qml @@ -9,6 +9,8 @@ import StatusQ.Components import StatusQ.Controls.Validators import StatusQ.Popups.Dialog +import AppLayouts.Wallet.services.dapps + import utils StatusDialog { @@ -32,13 +34,15 @@ StatusDialog { enum TagType { Link, - Address + Address, + WCUri } QtObject { id: d property string validTag: "" + property int validTagType } contentItem: QRCodeScanner { @@ -49,11 +53,7 @@ StatusDialog { running: !!d.validTag repeat: false onTriggered: { - if (Utils.isURL(d.validTag)) { - root.tagFound(QRCodeScannerDialog.TagType.Link, d.validTag) - } else if (Utils.isValidAddress(d.validTag)) { - root.tagFound(QRCodeScannerDialog.TagType.Address, d.validTag) - } + root.tagFound(d.validTagType, d.validTag) root.close() } } @@ -63,8 +63,20 @@ StatusDialog { name: "isValidQR" errorMessage: qsTr("We cannot read that QR code.") validate: function (tag) { - // We accept URLs and addresses - return Utils.isURL(tag) || Utils.isValidAddress(tag) + // We accept URLs, addresses and WalletConnect URIs + if (Utils.isURL(tag)) { + d.validTagType = QRCodeScannerDialog.TagType.Link + return true + } + if (Utils.isValidAddress(tag)) { + d.validTagType = QRCodeScannerDialog.TagType.Address + return true + } + if (DAppsHelpers.validURI(tag)) { + d.validTagType = QRCodeScannerDialog.TagType.WCUri + return true + } + return false } } ]