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
text: qsTr('Import')
enabled: valid
onClicked: accept()
onClicked: doAccept()
}
}

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

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

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

@ -47,7 +47,7 @@ ElDialog {
text: qsTr('Ok')
icon.source: Qt.resolvedUrl('../../icons/confirmed.png')
visible: !yesno
onClicked: accept()
onClicked: doAccept()
}
FlatButton {
@ -57,7 +57,7 @@ ElDialog {
text: qsTr('Yes')
icon.source: Qt.resolvedUrl('../../icons/confirmed.png')
visible: yesno
onClicked: accept()
onClicked: doAccept()
}
FlatButton {
Layout.fillWidth: true
@ -66,7 +66,7 @@ ElDialog {
text: qsTr('No')
icon.source: Qt.resolvedUrl('../../icons/closebutton.png')
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
onClicked: {
password = pw_1.text
passworddialog.accept()
passworddialog.doAccept()
}
}
}

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

@ -97,7 +97,7 @@ ElDialog {
Layout.fillWidth: true
text: qsTr('Create request')
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
visible: txdetails.canBump || txdetails.canCpfp || txdetails.canCancel || txdetails.canRemove
text: txdetails.canRemove
? qsTr('This transaction is local to your wallet. It has not been published yet.')
: 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'))
? qsTr('This transaction is local to your wallet. It has not been published yet.')
: 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'))
}
RowLayout {

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

@ -9,8 +9,27 @@ Dialog {
property string iconSource
property bool resizeWithKeyboard: true
property bool _result: false
// called to finally close dialog after checks by onClosing handler in main.qml
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

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

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

Loading…
Cancel
Save