Browse Source

qml: add doAccept and doReject functions to ElDialog.

These functions make sure no duplicate accepted/rejected signals are emitted.
master
Sander van Grieken 3 years ago
parent
commit
a0939aad75
  1. 2
      electrum/gui/qml/components/ImportAddressesKeysDialog.qml
  2. 9
      electrum/gui/qml/components/ImportChannelBackupDialog.qml
  3. 6
      electrum/gui/qml/components/MessageDialog.qml
  4. 2
      electrum/gui/qml/components/PasswordDialog.qml
  5. 2
      electrum/gui/qml/components/ReceiveDetailsDialog.qml
  6. 8
      electrum/gui/qml/components/TxDetails.qml
  7. 21
      electrum/gui/qml/components/controls/ElDialog.qml
  8. 4
      electrum/gui/qml/components/wizard/Wizard.qml

2
electrum/gui/qml/components/ImportAddressesKeysDialog.qml

@ -104,7 +104,7 @@ ElDialog {
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr('Import') text: qsTr('Import')
enabled: valid enabled: valid
onClicked: accept() onClicked: doAccept()
} }
} }

9
electrum/gui/qml/components/ImportChannelBackupDialog.qml

@ -23,6 +23,10 @@ ElDialog {
return valid = Daemon.currentWallet.isValidChannelBackup(text) return valid = Daemon.currentWallet.isValidChannelBackup(text)
} }
onAccepted: {
Daemon.currentWallet.importChannelBackup(channelbackup_ta.text)
}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
@ -84,10 +88,7 @@ ElDialog {
Layout.fillWidth: true Layout.fillWidth: true
enabled: valid enabled: valid
text: qsTr('Import') text: qsTr('Import')
onClicked: { onClicked: doAccept()
Daemon.currentWallet.importChannelBackup(channelbackup_ta.text)
root.accept()
}
} }
} }

6
electrum/gui/qml/components/MessageDialog.qml

@ -47,7 +47,7 @@ ElDialog {
text: qsTr('Ok') text: qsTr('Ok')
icon.source: Qt.resolvedUrl('../../icons/confirmed.png') icon.source: Qt.resolvedUrl('../../icons/confirmed.png')
visible: !yesno visible: !yesno
onClicked: accept() onClicked: doAccept()
} }
FlatButton { FlatButton {
@ -57,7 +57,7 @@ ElDialog {
text: qsTr('Yes') text: qsTr('Yes')
icon.source: Qt.resolvedUrl('../../icons/confirmed.png') icon.source: Qt.resolvedUrl('../../icons/confirmed.png')
visible: yesno visible: yesno
onClicked: accept() onClicked: doAccept()
} }
FlatButton { FlatButton {
Layout.fillWidth: true Layout.fillWidth: true
@ -66,7 +66,7 @@ ElDialog {
text: qsTr('No') text: qsTr('No')
icon.source: Qt.resolvedUrl('../../icons/closebutton.png') icon.source: Qt.resolvedUrl('../../icons/closebutton.png')
visible: yesno visible: yesno
onClicked: reject() onClicked: doReject()
} }
} }
} }

2
electrum/gui/qml/components/PasswordDialog.qml

@ -73,7 +73,7 @@ ElDialog {
enabled: confirmPassword ? pw_1.text.length >= 6 && pw_1.text == pw_2.text : true enabled: confirmPassword ? pw_1.text.length >= 6 && pw_1.text == pw_2.text : true
onClicked: { onClicked: {
password = pw_1.text password = pw_1.text
passworddialog.accept() passworddialog.doAccept()
} }
} }
} }

2
electrum/gui/qml/components/ReceiveDetailsDialog.qml

@ -97,7 +97,7 @@ ElDialog {
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr('Create request') text: qsTr('Create request')
icon.source: '../../icons/confirmed.png' icon.source: '../../icons/confirmed.png'
onClicked: accept() onClicked: doAccept()
} }
} }

8
electrum/gui/qml/components/TxDetails.qml

@ -57,10 +57,10 @@ Pane {
Layout.bottomMargin: constants.paddingLarge Layout.bottomMargin: constants.paddingLarge
visible: txdetails.canBump || txdetails.canCpfp || txdetails.canCancel || txdetails.canRemove visible: txdetails.canBump || txdetails.canCpfp || txdetails.canCancel || txdetails.canRemove
text: txdetails.canRemove text: txdetails.canRemove
? qsTr('This transaction is local to your wallet. It has not been published yet.') ? qsTr('This transaction is local to your wallet. It has not been published yet.')
: qsTr('This transaction is still unconfirmed.') + '\n' + (txdetails.canCancel : qsTr('This transaction is still unconfirmed.') + '\n' + (txdetails.canCancel
? qsTr('You can bump its fee to speed up its confirmation, or cancel this transaction') ? qsTr('You can bump its fee to speed up its confirmation, or cancel this transaction')
: qsTr('You can bump its fee to speed up its confirmation')) : qsTr('You can bump its fee to speed up its confirmation'))
} }
RowLayout { RowLayout {

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

@ -9,8 +9,27 @@ Dialog {
property string iconSource property string iconSource
property bool resizeWithKeyboard: true property bool resizeWithKeyboard: true
property bool _result: false
// called to finally close dialog after checks by onClosing handler in main.qml
function doClose() { function doClose() {
close() doReject()
}
// avoid potential multiple signals, only emit once
function doAccept() {
if (_result)
return
_result = true
accept()
}
// avoid potential multiple signals, only emit once
function doReject() {
if (_result)
return
_result = true
reject()
} }
parent: resizeWithKeyboard ? Overlay.overlay.children[0] : Overlay.overlay parent: resizeWithKeyboard ? Overlay.overlay.children[0] : Overlay.overlay

4
electrum/gui/qml/components/wizard/Wizard.qml

@ -131,7 +131,7 @@ ElDialog {
function finish() { function finish() {
currentItem.accept() currentItem.accept()
_setWizardData(pages.contentChildren[currentIndex].wizard_data) _setWizardData(pages.contentChildren[currentIndex].wizard_data)
wizard.accept() wizard.doAccept()
} }
property bool pagevalid: false property bool pagevalid: false
@ -163,7 +163,7 @@ ElDialog {
Layout.preferredWidth: 1 Layout.preferredWidth: 1
visible: pages.currentIndex == 0 visible: pages.currentIndex == 0
text: qsTr("Cancel") text: qsTr("Cancel")
onClicked: wizard.reject() onClicked: wizard.doReject()
} }
FlatButton { FlatButton {
Layout.fillWidth: true Layout.fillWidth: true

Loading…
Cancel
Save