mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
Dialog(s) for changing restore height
This commit is contained in:
parent
170ddf1f6f
commit
199aedf60a
2 changed files with 38 additions and 48 deletions
|
@ -23,3 +23,7 @@ function formatDate( date, params ) {
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
|
||||||
return new Date( date ).toLocaleString( 'en-US', options );
|
return new Date( date ).toLocaleString( 'en-US', options );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNumeric(n) {
|
||||||
|
return !isNaN(parseFloat(n)) && isFinite(n);
|
||||||
|
}
|
|
@ -679,59 +679,45 @@ Rectangle {
|
||||||
property var style: "<style type='text/css'>a {cursor:pointer;text-decoration: none; color: #FF6C3C}</style>"
|
property var style: "<style type='text/css'>a {cursor:pointer;text-decoration: none; color: #FF6C3C}</style>"
|
||||||
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: {
|
||||||
restoreHeightRow.visible = true;
|
inputDialog.labelText = qsTr("Set a new restore height:") + translationManager.emptyString;
|
||||||
}
|
inputDialog.inputText = currentWallet ? currentWallet.walletCreationHeight : "0";
|
||||||
}
|
inputDialog.onAcceptedCallback = function() {
|
||||||
|
var _restoreHeight = inputDialog.inputText;
|
||||||
|
if(Utils.isNumeric(_restoreHeight)){
|
||||||
|
_restoreHeight = parseInt(_restoreHeight);
|
||||||
|
if(_restoreHeight >= 0) {
|
||||||
|
currentWallet.walletCreationHeight = restoreHeightEdit.text
|
||||||
|
// Restore height is saved in .keys file. Set password to trigger rewrite.
|
||||||
|
currentWallet.setPassword(appWindow.walletPassword)
|
||||||
|
|
||||||
RowLayout {
|
// Show confirmation dialog
|
||||||
id: restoreHeightRow
|
confirmationDialog.title = qsTr("Rescan wallet cache") + translationManager.emptyString;
|
||||||
visible: false
|
confirmationDialog.text = qsTr("Are you sure you want to rebuild the wallet cache?\n"
|
||||||
Layout.preferredWidth: parent.width
|
+ "The following information will be deleted\n"
|
||||||
|
+ "- Recipient addresses\n"
|
||||||
|
+ "- Tx keys\n"
|
||||||
|
+ "- Tx descriptions\n\n"
|
||||||
|
+ "The old wallet cache file will be renamed and can be restored later.\n"
|
||||||
|
);
|
||||||
|
confirmationDialog.icon = StandardIcon.Question
|
||||||
|
confirmationDialog.cancelText = qsTr("Cancel")
|
||||||
|
confirmationDialog.onAcceptedCallback = function() {
|
||||||
|
walletManager.closeWallet();
|
||||||
|
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
||||||
|
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
||||||
|
persistentSettings.nettype);
|
||||||
|
}
|
||||||
|
|
||||||
LineEdit {
|
confirmationDialog.onRejectedCallback = null;
|
||||||
id: restoreHeightEdit
|
confirmationDialog.open()
|
||||||
Layout.preferredWidth: 80
|
return;
|
||||||
Layout.fillWidth: true
|
}
|
||||||
text: currentWallet ? currentWallet.walletCreationHeight : "0"
|
|
||||||
validator: IntValidator {
|
|
||||||
bottom:0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StandardButton {
|
|
||||||
id: restoreHeightSave
|
|
||||||
small: true
|
|
||||||
Layout.fillWidth: false
|
|
||||||
Layout.leftMargin: 30
|
|
||||||
text: qsTr("Save") + translationManager.emptyString
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
currentWallet.walletCreationHeight = restoreHeightEdit.text
|
|
||||||
// Restore height is saved in .keys file. Set password to trigger rewrite.
|
|
||||||
currentWallet.setPassword(appWindow.walletPassword)
|
|
||||||
restoreHeightRow.visible = false
|
|
||||||
|
|
||||||
// Show confirmation dialog
|
|
||||||
confirmationDialog.title = qsTr("Rescan wallet cache") + translationManager.emptyString;
|
|
||||||
confirmationDialog.text = qsTr("Are you sure you want to rebuild the wallet cache?\n"
|
|
||||||
+ "The following information will be deleted\n"
|
|
||||||
+ "- Recipient addresses\n"
|
|
||||||
+ "- Tx keys\n"
|
|
||||||
+ "- Tx descriptions\n\n"
|
|
||||||
+ "The old wallet cache file will be renamed and can be restored later.\n"
|
|
||||||
);
|
|
||||||
confirmationDialog.icon = StandardIcon.Question
|
|
||||||
confirmationDialog.cancelText = qsTr("Cancel")
|
|
||||||
confirmationDialog.onAcceptedCallback = function() {
|
|
||||||
walletManager.closeWallet();
|
|
||||||
walletManager.clearWalletCache(persistentSettings.wallet_path);
|
|
||||||
walletManager.openWalletAsync(persistentSettings.wallet_path, appWindow.walletPassword,
|
|
||||||
persistentSettings.nettype);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmationDialog.onRejectedCallback = null;
|
appWindow.showStatusMessage(qsTr("Invalid restore height specified. Must be a number."),3);
|
||||||
confirmationDialog.open()
|
|
||||||
}
|
}
|
||||||
|
inputDialog.onRejectedCallback = null;
|
||||||
|
inputDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue