Browse Source

qml: port over 'show_qr to warn if QR code is missing data'

master
Sander van Grieken 3 years ago
parent
commit
df44a5c361
  1. 12
      electrum/gui/qml/components/ExportTxDialog.qml
  2. 3
      electrum/gui/qml/components/TxDetails.qml
  3. 13
      electrum/gui/qml/components/WalletMainView.qml
  4. 12
      electrum/gui/qml/qetxdetails.py
  5. 11
      electrum/gui/qml/qewallet.py

12
electrum/gui/qml/components/ExportTxDialog.qml

@ -12,6 +12,7 @@ ElDialog {
property string text_qr
// if text_qr is undefined text will be used
property string text_help
property string text_warn
title: qsTr('Share Transaction')
@ -55,6 +56,17 @@ ElDialog {
visible: dialog.text_help
text: dialog.text_help
}
InfoTextArea {
Layout.fillWidth: true
Layout.margins: constants.paddingLarge
Layout.topMargin: dialog.text_help
? 0
: constants.paddingLarge
visible: dialog.text_warn
text: dialog.text_warn
iconStyle: InfoTextArea.IconStyle.Warn
}
}
}

3
electrum/gui/qml/components/TxDetails.qml

@ -374,6 +374,7 @@ Pane {
onClicked: {
var msg = ''
if (txdetails.isComplete) {
if (!txdetails.isMined && !txdetails.mempoolDepth) // local
// TODO: iff offline wallet?
// TODO: or also if just temporarily offline?
msg = qsTr('This transaction is complete. Please share it with an online device')
@ -387,7 +388,7 @@ Pane {
}
}
app.stack.getRoot().showExport(txdetails.getSerializedTx(false), txdetails.getSerializedTx(true), msg)
app.stack.getRoot().showExport(txdetails.getSerializedTx(), msg)
}
}

13
electrum/gui/qml/components/WalletMainView.qml

@ -51,14 +51,17 @@ Item {
}
function showExportByTxid(txid, helptext) {
showExport(Daemon.currentWallet.getSerializedTx(txid, false), Daemon.currentWallet.getSerializedTx(txid, true), helptext)
showExport(Daemon.currentWallet.getSerializedTx(txid), helptext)
}
function showExport(data, data_qr, helptext) {
function showExport(data, helptext) {
var dialog = exportTxDialog.createObject(app, {
text: data,
text_qr: data_qr,
text_help: helptext
text: data[0],
text_qr: data[1],
text_help: helptext,
text_warn: data[2]
? ''
: qsTr('Warning: Some data (prev txs / "full utxos") was left out of the QR code as it would not fit. This might cause issues if signing offline. As a workaround, try exporting the tx as file or text instead.')
})
dialog.open()
}

12
electrum/gui/qml/qetxdetails.py

@ -391,11 +391,7 @@ class QETxDetails(QObject, QtEventListener):
self._can_remove = True
self.detailsChanged.emit()
@pyqtSlot(result=str)
@pyqtSlot(bool, result=str)
def getSerializedTx(self, for_qr=False):
tx = self._tx
if for_qr:
return tx.to_qr_data()[0]
else:
return str(tx)
@pyqtSlot(result='QVariantList')
def getSerializedTx(self):
txqr = self._tx.to_qr_data()
return [str(self._tx), txqr[0], txqr[1]]

11
electrum/gui/qml/qewallet.py

@ -728,11 +728,8 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
self.dataChanged.emit()
@pyqtSlot(str, result=str)
@pyqtSlot(str, bool, result=str)
def getSerializedTx(self, txid, for_qr=False):
@pyqtSlot(str, result='QVariantList')
def getSerializedTx(self, txid):
tx = self.wallet.db.get_transaction(txid)
if for_qr:
return tx.to_qr_data()[0]
else:
return str(tx)
txqr = tx.to_qr_data()
return [str(tx), txqr[0], txqr[1]]

Loading…
Cancel
Save