mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +00:00
wizard: warn user if wallet exists in path
This commit is contained in:
parent
e09ccd3c9a
commit
d637b5883e
3 changed files with 33 additions and 13 deletions
|
@ -54,7 +54,8 @@ Item {
|
||||||
settingsObject['account_name'] = uiItem.accountNameText
|
settingsObject['account_name'] = uiItem.accountNameText
|
||||||
settingsObject['words'] = uiItem.wordsTexttext
|
settingsObject['words'] = uiItem.wordsTexttext
|
||||||
settingsObject['wallet_path'] = uiItem.walletPath
|
settingsObject['wallet_path'] = uiItem.walletPath
|
||||||
return true;
|
var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText);
|
||||||
|
return !wizard.walletExists(walletFullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkNextButton() {
|
function checkNextButton() {
|
||||||
|
@ -86,9 +87,6 @@ Item {
|
||||||
settingsObject.wallet_filename = wallet_filename
|
settingsObject.wallet_filename = wallet_filename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WizardManageWalletUI {
|
WizardManageWalletUI {
|
||||||
id: uiItem
|
id: uiItem
|
||||||
titleText: qsTr("A new wallet has been created for you") + translationManager.emptyString
|
titleText: qsTr("A new wallet has been created for you") + translationManager.emptyString
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
|
@ -130,21 +131,31 @@ Rectangle {
|
||||||
wizard.openWalletFromFileClicked();
|
wizard.openWalletFromFileClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createWalletPath(folder_path,account_name){
|
||||||
|
|
||||||
|
// Remove trailing slash - (default on windows and mac)
|
||||||
|
if (folder_path.substring(folder_path.length -1) === "/"){
|
||||||
|
folder_path = folder_path.substring(0,folder_path.length -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
return folder_path + "/" + account_name + "/" + account_name
|
||||||
|
}
|
||||||
|
|
||||||
|
function walletExists(path){
|
||||||
|
if(walletManager.walletExists(path)){
|
||||||
|
walletExistsErrorDialog.open();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//! actually writes the wallet
|
//! actually writes the wallet
|
||||||
function applySettings() {
|
function applySettings() {
|
||||||
console.log("Here we apply the settings");
|
console.log("Here we apply the settings");
|
||||||
// here we need to actually move wallet to the new location
|
// here we need to actually move wallet to the new location
|
||||||
console.log(settings.wallet_full_path);
|
console.log(settings.wallet_full_path);
|
||||||
|
|
||||||
|
var new_wallet_filename = createWalletPath(settings.wallet_path,settings.account_name)
|
||||||
// Remove trailing slash - (default on windows and mac)
|
|
||||||
if (settings.wallet_path.substring(settings.wallet_path.length -1) === "/"){
|
|
||||||
settings.wallet_path = settings.wallet_path.substring(0,settings.wallet_path.length -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
var new_wallet_filename = settings.wallet_path + "/"
|
|
||||||
+ settings.account_name + "/"
|
|
||||||
+ settings.account_name;
|
|
||||||
|
|
||||||
console.log("saving in wizard: "+ new_wallet_filename)
|
console.log("saving in wizard: "+ new_wallet_filename)
|
||||||
// moving wallet files to the new destination, if user changed it
|
// moving wallet files to the new destination, if user changed it
|
||||||
|
@ -185,6 +196,13 @@ Rectangle {
|
||||||
settings['auto_donations_amount'] = appWindow.persistentSettings.auto_donations_amount
|
settings['auto_donations_amount'] = appWindow.persistentSettings.auto_donations_amount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageDialog {
|
||||||
|
id: walletExistsErrorDialog
|
||||||
|
title: "Error"
|
||||||
|
text: qsTr("A wallet with same name already exists. Please change wallet name") + translationManager.emptyString
|
||||||
|
onAccepted: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: nextButton
|
id: nextButton
|
||||||
|
|
|
@ -55,6 +55,10 @@ Item {
|
||||||
settingsObject['words'] = Utils.lineBreaksToSpaces(uiItem.wordsTextItem.memoText)
|
settingsObject['words'] = Utils.lineBreaksToSpaces(uiItem.wordsTextItem.memoText)
|
||||||
settingsObject['wallet_path'] = uiItem.walletPath
|
settingsObject['wallet_path'] = uiItem.walletPath
|
||||||
settingsObject['restore_height'] = parseInt(uiItem.restoreHeight)
|
settingsObject['restore_height'] = parseInt(uiItem.restoreHeight)
|
||||||
|
var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText);
|
||||||
|
if(wizard.walletExists(walletFullPath)){
|
||||||
|
return false
|
||||||
|
}
|
||||||
return recoveryWallet(settingsObject)
|
return recoveryWallet(settingsObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue