InputDialog: pre-populate input text

This commit is contained in:
selsta 2019-12-09 00:44:39 +01:00
parent f03ea0461c
commit b940ad72be
No known key found for this signature in database
GPG key ID: 2EA0A99A8B07AE5E
5 changed files with 8 additions and 14 deletions

View file

@ -45,14 +45,14 @@ Item {
signal accepted() signal accepted()
signal rejected() signal rejected()
function open() { function open(prepopulate) {
inactiveOverlay.visible = true inactiveOverlay.visible = true
leftPanel.enabled = false leftPanel.enabled = false
middlePanel.enabled = false middlePanel.enabled = false
titleBar.state = "essentials" titleBar.state = "essentials"
root.visible = true; root.visible = true;
input.focus = true; input.focus = true;
input.text = ""; input.text = prepopulate ? prepopulate : "";
} }
function close() { function close() {

View file

@ -53,12 +53,11 @@ Rectangle {
function renameSubaddressAccountLabel(_index){ function renameSubaddressAccountLabel(_index){
inputDialog.labelText = qsTr("Set the label of the selected account:") + translationManager.emptyString; inputDialog.labelText = qsTr("Set the label of the selected account:") + translationManager.emptyString;
inputDialog.inputText = appWindow.currentWallet.getSubaddressLabel(_index, 0);
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.subaddressAccount.setLabel(_index, inputDialog.inputText) appWindow.currentWallet.subaddressAccount.setLabel(_index, inputDialog.inputText)
} }
inputDialog.onRejectedCallback = null; inputDialog.onRejectedCallback = null;
inputDialog.open() inputDialog.open(appWindow.currentWallet.getSubaddressLabel(_index, 0))
} }
Clipboard { id: clipboard } Clipboard { id: clipboard }
@ -354,7 +353,6 @@ Rectangle {
text: qsTr("Create new account") + translationManager.emptyString; text: qsTr("Create new account") + translationManager.emptyString;
onClicked: { onClicked: {
inputDialog.labelText = qsTr("Set the label of the new account:") + translationManager.emptyString inputDialog.labelText = qsTr("Set the label of the new account:") + translationManager.emptyString
inputDialog.inputText = qsTr("(Untitled)") + translationManager.emptyString
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.subaddressAccount.addRow(inputDialog.inputText) appWindow.currentWallet.subaddressAccount.addRow(inputDialog.inputText)
appWindow.currentWallet.switchSubaddressAccount(appWindow.currentWallet.numSubaddressAccounts() - 1) appWindow.currentWallet.switchSubaddressAccount(appWindow.currentWallet.numSubaddressAccounts() - 1)

View file

@ -477,7 +477,6 @@ Rectangle {
return; return;
inputDialog.labelText = qsTr("Jump to page (1-%1)").arg(pages) + translationManager.emptyString; inputDialog.labelText = qsTr("Jump to page (1-%1)").arg(pages) + translationManager.emptyString;
inputDialog.inputText = "1";
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
var pageNumber = parseInt(inputDialog.inputText); var pageNumber = parseInt(inputDialog.inputText);
if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= pages) { if (!isNaN(pageNumber) && pageNumber >= 1 && pageNumber <= pages) {
@ -1195,7 +1194,7 @@ Rectangle {
if(res[i].state === 'copyable' && res[i].parent.hasOwnProperty('text')) toClipboard(res[i].parent.text); if(res[i].state === 'copyable' && res[i].parent.hasOwnProperty('text')) toClipboard(res[i].parent.text);
if(res[i].state === 'copyable_address') root.toClipboard(address); if(res[i].state === 'copyable_address') root.toClipboard(address);
if(res[i].state === 'copyable_txkey') root.getTxKey(hash, res[i]); if(res[i].state === 'copyable_txkey') root.getTxKey(hash, res[i]);
if(res[i].state === 'set_tx_note') root.editDescription(hash); if(res[i].state === 'set_tx_note') root.editDescription(hash, tx_note);
if(res[i].state === 'details') root.showTxDetails(hash, paymentId, destinations, subaddrAccount, subaddrIndex, dateTime, displayAmount, isout); if(res[i].state === 'details') root.showTxDetails(hash, paymentId, destinations, subaddrAccount, subaddrIndex, dateTime, displayAmount, isout);
if(res[i].state === 'proof') root.showTxProof(hash, paymentId, destinations, subaddrAccount, subaddrIndex); if(res[i].state === 'proof') root.showTxProof(hash, paymentId, destinations, subaddrAccount, subaddrIndex);
doCollapse = false; doCollapse = false;
@ -1533,7 +1532,7 @@ Rectangle {
root.updateFilter(); root.updateFilter();
} }
function editDescription(_hash){ function editDescription(_hash, _tx_note){
inputDialog.labelText = qsTr("Set description:") + translationManager.emptyString; inputDialog.labelText = qsTr("Set description:") + translationManager.emptyString;
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.setUserNote(_hash, inputDialog.inputText); appWindow.currentWallet.setUserNote(_hash, inputDialog.inputText);
@ -1541,7 +1540,7 @@ Rectangle {
root.update(); root.update();
} }
inputDialog.onRejectedCallback = null; inputDialog.onRejectedCallback = null;
inputDialog.open(); inputDialog.open(_tx_note);
} }
function paginationPrevClicked(){ function paginationPrevClicked(){

View file

@ -53,12 +53,11 @@ Rectangle {
function renameSubaddressLabel(_index){ function renameSubaddressLabel(_index){
inputDialog.labelText = qsTr("Set the label of the selected address:") + translationManager.emptyString; inputDialog.labelText = qsTr("Set the label of the selected address:") + translationManager.emptyString;
inputDialog.inputText = appWindow.currentWallet.getSubaddressLabel(appWindow.currentWallet.currentSubaddressAccount, _index);
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.subaddress.setLabel(appWindow.currentWallet.currentSubaddressAccount, _index, inputDialog.inputText); appWindow.currentWallet.subaddress.setLabel(appWindow.currentWallet.currentSubaddressAccount, _index, inputDialog.inputText);
} }
inputDialog.onRejectedCallback = null; inputDialog.onRejectedCallback = null;
inputDialog.open() inputDialog.open(appWindow.currentWallet.getSubaddressLabel(appWindow.currentWallet.currentSubaddressAccount, _index))
} }
Clipboard { id: clipboard } Clipboard { id: clipboard }
@ -254,7 +253,6 @@ Rectangle {
text: qsTr("Create new address") + translationManager.emptyString; text: qsTr("Create new address") + translationManager.emptyString;
onClicked: { onClicked: {
inputDialog.labelText = qsTr("Set the label of the new address:") + translationManager.emptyString inputDialog.labelText = qsTr("Set the label of the new address:") + translationManager.emptyString
inputDialog.inputText = qsTr("(Untitled)") + translationManager.emptyString
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
appWindow.currentWallet.subaddress.addRow(appWindow.currentWallet.currentSubaddressAccount, inputDialog.inputText) appWindow.currentWallet.subaddress.addRow(appWindow.currentWallet.currentSubaddressAccount, inputDialog.inputText)
current_subaddress_table_index = appWindow.currentWallet.numSubaddresses(appWindow.currentWallet.currentSubaddressAccount) - 1 current_subaddress_table_index = appWindow.currentWallet.numSubaddresses(appWindow.currentWallet.currentSubaddressAccount) - 1

View file

@ -178,7 +178,6 @@ Rectangle {
text: (currentWallet ? currentWallet.walletCreationHeight : "") + style + qsTr(" <a href='#'> (Click to change)</a>") + translationManager.emptyString text: (currentWallet ? currentWallet.walletCreationHeight : "") + style + qsTr(" <a href='#'> (Click to change)</a>") + translationManager.emptyString
onLinkActivated: { onLinkActivated: {
inputDialog.labelText = qsTr("Set a new restore height.\nYou can enter a block height or a date (YYYY-MM-DD):") + translationManager.emptyString; inputDialog.labelText = qsTr("Set a new restore height.\nYou can enter a block height or a date (YYYY-MM-DD):") + translationManager.emptyString;
inputDialog.inputText = currentWallet ? currentWallet.walletCreationHeight : "0";
inputDialog.onAcceptedCallback = function() { inputDialog.onAcceptedCallback = function() {
var _restoreHeight; var _restoreHeight;
if (inputDialog.inputText) { if (inputDialog.inputText) {
@ -224,7 +223,7 @@ Rectangle {
appWindow.showStatusMessage(qsTr("Invalid restore height specified. Must be a number or a date formatted YYYY-MM-DD"),3); appWindow.showStatusMessage(qsTr("Invalid restore height specified. Must be a number or a date formatted YYYY-MM-DD"),3);
} }
inputDialog.onRejectedCallback = null; inputDialog.onRejectedCallback = null;
inputDialog.open() inputDialog.open(currentWallet ? currentWallet.walletCreationHeight : "0")
} }
MouseArea { MouseArea {