diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index d7c6553bb..8839aba2a 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -85,6 +85,7 @@ ElDialog { QRImage { qrdata: _bolt11 render: _render_qr + enable_toggle_text: true } } Component { @@ -92,6 +93,7 @@ ElDialog { QRImage { qrdata: _bip21uri render: _render_qr + enable_toggle_text: true } } Component { @@ -99,32 +101,10 @@ ElDialog { QRImage { qrdata: _address render: _render_qr + enable_toggle_text: true } } } - - MouseArea { - anchors.fill: parent - onClicked: { - if (rootLayout.state == 'bolt11') { - if (_bip21uri != '') - rootLayout.state = 'bip21uri' - else if (_address != '') - rootLayout.state = 'address' - } else if (rootLayout.state == 'bip21uri') { - if (_address != '') - rootLayout.state = 'address' - else if (_bolt11 != '') - rootLayout.state = 'bolt11' - } else if (rootLayout.state == 'address') { - if (_bolt11 != '') - rootLayout.state = 'bolt11' - else if (_bip21uri != '') - rootLayout.state = 'bip21uri' - } - Config.preferredRequestType = rootLayout.state - } - } } RowLayout { diff --git a/electrum/gui/qml/components/controls/QRImage.qml b/electrum/gui/qml/components/controls/QRImage.qml index 875b116b3..f5baa72f1 100644 --- a/electrum/gui/qml/components/controls/QRImage.qml +++ b/electrum/gui/qml/components/controls/QRImage.qml @@ -7,6 +7,9 @@ Item { property bool render: true // init to false, then set true if render needs delay property var qrprops: QRIP.getDimensions(qrdata) + property bool enable_toggle_text: false // if true, clicking the QR code shows the encoded text + property bool is_in_text_state: false // internal state, if the above is enabled + width: r.width height: r.height @@ -19,6 +22,7 @@ Item { Image { source: qrdata && render ? 'image://qrgen/' + qrdata : '' + visible: !is_in_text_state Rectangle { visible: root.render && qrprops.valid @@ -44,4 +48,27 @@ Item { anchors.centerIn: parent } } + + Label { + visible: is_in_text_state + text: qrdata + wrapMode: Text.WrapAnywhere + elide: Text.ElideRight + anchors.centerIn: parent + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + color: 'black' + width: r.width + height: r.height + } + + MouseArea { + anchors.fill: parent + onClicked: { + if (enable_toggle_text) { + root.is_in_text_state = !root.is_in_text_state + } + } + } + }