Browse Source

qml: add hack to delay rendering of QR until dialog is shown.

unfortunately, using standard QtQuick Image.asynchronous=true leads
to a deadlock at app exit so we can't use it a.t.m.
master
Sander van Grieken 3 years ago
parent
commit
40e8ff6ce2
  1. 12
      electrum/gui/qml/components/GenericShareDialog.qml
  2. 15
      electrum/gui/qml/components/RequestDialog.qml
  3. 21
      electrum/gui/qml/components/controls/QRImage.qml

12
electrum/gui/qml/components/GenericShareDialog.qml

@ -58,6 +58,8 @@ ElDialog {
QRImage { QRImage {
id: qr id: qr
render: dialog.enter ? false : true
qrdata: dialog.text_qr ? dialog.text_qr : dialog.text
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.topMargin: constants.paddingSmall Layout.topMargin: constants.paddingSmall
Layout.bottomMargin: constants.paddingSmall Layout.bottomMargin: constants.paddingSmall
@ -108,7 +110,13 @@ ElDialog {
} }
} }
Component.onCompleted: { Connections {
qr.qrdata = dialog.text_qr ? dialog.text_qr : dialog.text target: dialog.enter
function onRunningChanged() {
console.log('dialog open animation running changed: ' + dialog.enter.running)
if (!dialog.enter.running) {
qr.render = true
}
}
} }
} }

15
electrum/gui/qml/components/RequestDialog.qml

@ -17,6 +17,8 @@ ElDialog {
property string _bip21uri property string _bip21uri
property string _address property string _address
property bool _render_qr: false // delay qr rendering until dialog is shown
parent: Overlay.overlay parent: Overlay.overlay
modal: true modal: true
standardButtons: Dialog.Close standardButtons: Dialog.Close
@ -91,18 +93,21 @@ ElDialog {
id: qri_bolt11 id: qri_bolt11
QRImage { QRImage {
qrdata: _bolt11 qrdata: _bolt11
render: _render_qr
} }
} }
Component { Component {
id: qri_bip21uri id: qri_bip21uri
QRImage { QRImage {
qrdata: _bip21uri qrdata: _bip21uri
render: _render_qr
} }
} }
Component { Component {
id: qri_address id: qri_address
QRImage { QRImage {
qrdata: _address qrdata: _address
render: _render_qr
} }
} }
} }
@ -298,4 +303,14 @@ ElDialog {
wallet: Daemon.currentWallet wallet: Daemon.currentWallet
key: dialog.key key: dialog.key
} }
// hack. delay qr rendering until dialog is shown
Connections {
target: dialog.enter
function onRunningChanged() {
if (!dialog.enter.running) {
dialog._render_qr = true
}
}
}
} }

21
electrum/gui/qml/components/controls/QRImage.qml

@ -1,12 +1,26 @@
import QtQuick 2.6 import QtQuick 2.6
Image { Item {
id: root
property string qrdata property string qrdata
property bool render: true // init to false, then set true if render needs delay
property var qrprops: QRIP.getDimensions(qrdata)
source: qrdata ? 'image://qrgen/' + qrdata : '' width: r.width
height: r.height
Rectangle { Rectangle {
property var qrprops: QRIP.getDimensions(qrdata) id: r
width: qrprops.modules * qrprops.box_size
height: width
color: 'white'
}
Image {
source: qrdata && render ? 'image://qrgen/' + qrdata : ''
Rectangle {
visible: root.render
color: 'white' color: 'white'
x: (parent.width - width) / 2 x: (parent.width - width) / 2
y: (parent.height - height) / 2 y: (parent.height - height) / 2
@ -23,3 +37,4 @@ Image {
} }
} }
} }
}

Loading…
Cancel
Save