qml: ReceiveDialog: clicking QR code to show encoded text
closes https://github.com/spesmilo/electrum/issues/8331
This commit is contained in:
@@ -85,6 +85,7 @@ ElDialog {
|
|||||||
QRImage {
|
QRImage {
|
||||||
qrdata: _bolt11
|
qrdata: _bolt11
|
||||||
render: _render_qr
|
render: _render_qr
|
||||||
|
enable_toggle_text: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
@@ -92,6 +93,7 @@ ElDialog {
|
|||||||
QRImage {
|
QRImage {
|
||||||
qrdata: _bip21uri
|
qrdata: _bip21uri
|
||||||
render: _render_qr
|
render: _render_qr
|
||||||
|
enable_toggle_text: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
@@ -99,32 +101,10 @@ ElDialog {
|
|||||||
QRImage {
|
QRImage {
|
||||||
qrdata: _address
|
qrdata: _address
|
||||||
render: _render_qr
|
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 {
|
RowLayout {
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ Item {
|
|||||||
property bool render: true // init to false, then set true if render needs delay
|
property bool render: true // init to false, then set true if render needs delay
|
||||||
property var qrprops: QRIP.getDimensions(qrdata)
|
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
|
width: r.width
|
||||||
height: r.height
|
height: r.height
|
||||||
|
|
||||||
@@ -19,6 +22,7 @@ Item {
|
|||||||
|
|
||||||
Image {
|
Image {
|
||||||
source: qrdata && render ? 'image://qrgen/' + qrdata : ''
|
source: qrdata && render ? 'image://qrgen/' + qrdata : ''
|
||||||
|
visible: !is_in_text_state
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: root.render && qrprops.valid
|
visible: root.render && qrprops.valid
|
||||||
@@ -44,4 +48,27 @@ Item {
|
|||||||
anchors.centerIn: parent
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user