Browse Source

qml: refactor all custom QRScan component wrappers to ScanDialog

(except SendDialog, which has a Paste button and slightly different behavior)
master
Sander van Grieken 3 years ago
parent
commit
6848b8f375
  1. 34
      electrum/gui/qml/components/ImportAddressesKeysDialog.qml
  2. 30
      electrum/gui/qml/components/ImportChannelBackupDialog.qml
  3. 14
      electrum/gui/qml/components/OpenChannelDialog.qml
  4. 5
      electrum/gui/qml/components/SendDialog.qml
  5. 41
      electrum/gui/qml/components/wizard/WCHaveMasterKey.qml
  6. 36
      electrum/gui/qml/components/wizard/WCImport.qml

34
electrum/gui/qml/components/ImportAddressesKeysDialog.qml

@ -80,15 +80,20 @@ ElDialog {
icon.width: constants.iconSizeMedium
scale: 1.2
onClicked: {
var scan = qrscan.createObject(root.contentItem) // can't use dialog as parent?
scan.onFound.connect(function() {
if (verify(scan.scanData)) {
var dialog = app.scanDialog.createObject(app, {
hint: Daemon.currentWallet.isWatchOnly
? qsTr('Scan another address')
: qsTr('Scan another private key')
})
dialog.onFound.connect(function() {
if (verify(dialog.scanData)) {
if (import_ta.text != '')
import_ta.text = import_ta.text + ',\n'
import_ta.text = import_ta.text + scan.scanData
import_ta.text = import_ta.text + dialog.scanData
}
scan.destroy()
dialog.close()
})
dialog.open()
}
}
}
@ -109,25 +114,6 @@ ElDialog {
}
}
Component {
id: qrscan
QRScan {
width: parent.width
height: parent.height
ToolButton {
icon.source: '../../icons/closebutton.png'
icon.height: constants.iconSizeMedium
icon.width: constants.iconSizeMedium
anchors.right: parent.right
anchors.top: parent.top
onClicked: {
parent.destroy()
}
}
}
}
Bitcoin {
id: bitcoin
}

30
electrum/gui/qml/components/ImportChannelBackupDialog.qml

@ -59,11 +59,14 @@ ElDialog {
icon.width: constants.iconSizeMedium
scale: 1.2
onClicked: {
var scan = qrscan.createObject(root.contentItem)
scan.onFound.connect(function() {
channelbackup_ta.text = scan.scanData
scan.destroy()
var dialog = app.scanDialog.createObject(app, {
hint: qsTr('Scan a channel backup')
})
dialog.onFound.connect(function() {
channelbackup_ta.text = dialog.scanData
dialog.close()
})
dialog.open()
}
}
}
@ -92,23 +95,4 @@ ElDialog {
}
}
Component {
id: qrscan
QRScan {
width: root.contentItem.width
height: root.contentItem.height
ToolButton {
icon.source: '../../icons/closebutton.png'
icon.height: constants.iconSizeMedium
icon.width: constants.iconSizeMedium
anchors.right: parent.right
anchors.top: parent.top
onClicked: {
parent.destroy()
}
}
}
}
}

14
electrum/gui/qml/components/OpenChannelDialog.qml

@ -107,14 +107,17 @@ ElDialog {
icon.width: constants.iconSizeMedium
scale: 1.2
onClicked: {
var page = app.stack.push(Qt.resolvedUrl('Scan.qml'))
page.onFound.connect(function() {
if (channelopener.validate_connect_str(page.scanData)) {
channelopener.connectStr = page.scanData
var dialog = app.scanDialog.createObject(app, {
hint: qsTr('Scan a channel connect string')
})
dialog.onFound.connect(function() {
if (channelopener.validate_connect_str(dialog.scanData)) {
channelopener.connectStr = dialog.scanData
node.text = channelopener.connectStr
}
app.stack.pop()
dialog.close()
})
dialog.open()
}
}
}
@ -260,4 +263,5 @@ ElDialog {
root.close()
}
}
}

5
electrum/gui/qml/components/SendDialog.qml

@ -15,7 +15,7 @@ ElDialog {
signal txFound(data: string)
signal channelBackupFound(data: string)
header: Item {}
header: null
padding: 0
topPadding: 0
@ -39,9 +39,10 @@ ElDialog {
QRScan {
id: qrscan
Layout.preferredWidth: parent.width
Layout.fillWidth: true
Layout.fillHeight: true
hint: qsTr('Scan an Invoice, an Address, an LNURL-pay, a PSBT or a Channel backup')
onFound: dialog.dispatch(scanData)
}

41
electrum/gui/qml/components/wizard/WCHaveMasterKey.qml

@ -79,9 +79,10 @@ WizardComponent {
icon.source: '../../../icons/share.png'
icon.color: 'transparent'
onClicked: {
var dialog = app.genericShareDialog.createObject(app,
{ title: qsTr('Master public key'), text: multisigMasterPubkey }
)
var dialog = app.genericShareDialog.createObject(app, {
title: qsTr('Master public key'),
text: multisigMasterPubkey
})
dialog.open()
}
}
@ -141,14 +142,19 @@ WizardComponent {
icon.width: constants.iconSizeMedium
scale: 1.2
onClicked: {
var scan = qrscan.createObject(root)
scan.onFound.connect(function() {
if (verifyMasterKey(scan.scanData))
masterkey_ta.text = scan.scanData
var dialog = app.scanDialog.createObject(app, {
hint: cosigner
? qsTr('Scan a cosigner master public key')
: qsTr('Scan a master key')
})
dialog.onFound.connect(function() {
if (verifyMasterKey(dialog.scanData))
masterkey_ta.text = dialog.scanData
else
masterkey_ta.text = ''
scan.destroy()
dialog.close()
})
dialog.open()
}
}
}
@ -166,25 +172,6 @@ WizardComponent {
}
}
Component {
id: qrscan
QRScan {
width: root.width
height: root.height
ToolButton {
icon.source: '../../../icons/closebutton.png'
icon.height: constants.iconSizeMedium
icon.width: constants.iconSizeMedium
anchors.right: parent.right
anchors.top: parent.top
onClicked: {
parent.destroy()
}
}
}
}
Bitcoin {
id: bitcoin
onValidationMessageChanged: validationtext.text = validationMessage

36
electrum/gui/qml/components/wizard/WCImport.qml

@ -62,40 +62,28 @@ WizardComponent {
icon.width: constants.iconSizeMedium
scale: 1.2
onClicked: {
var scan = qrscan.createObject(root)
scan.onFound.connect(function() {
if (verify(scan.scanData)) {
var dialog = app.scanDialog.createObject(app, {
hint: bitcoin.isAddressList(import_ta.text)
? qsTr('Scan another address')
: bitcoin.isPrivateKeyList(import_ta.text)
? qsTr('Scan another private key')
: qsTr('Scan a private key or an address')
})
dialog.onFound.connect(function() {
if (verify(dialog.scanData)) {
if (import_ta.text != '')
import_ta.text = import_ta.text + ',\n'
import_ta.text = import_ta.text + scan.scanData
import_ta.text = import_ta.text + dialog.scanData
}
scan.destroy()
dialog.close()
})
dialog.open()
}
}
}
}
}
Component {
id: qrscan
QRScan {
width: root.width
height: root.height
ToolButton {
icon.source: '../../../icons/closebutton.png'
icon.height: constants.iconSizeMedium
icon.width: constants.iconSizeMedium
anchors.right: parent.right
anchors.top: parent.top
onClicked: {
parent.destroy()
}
}
}
}
Bitcoin {
id: bitcoin
}

Loading…
Cancel
Save