diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml index 6d632cbe..d05dd596 100644 --- a/wizard/WizardCreateWallet.qml +++ b/wizard/WizardCreateWallet.qml @@ -54,7 +54,8 @@ Item { settingsObject['account_name'] = uiItem.accountNameText settingsObject['words'] = uiItem.wordsTexttext settingsObject['wallet_path'] = uiItem.walletPath - return true; + var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText); + return !wizard.walletExists(walletFullPath); } function checkNextButton() { @@ -86,9 +87,6 @@ Item { settingsObject.wallet_filename = wallet_filename } - - - WizardManageWalletUI { id: uiItem titleText: qsTr("A new wallet has been created for you") + translationManager.emptyString diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index b52ea92d..446d7720 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -28,6 +28,7 @@ import QtQuick 2.2 import Qt.labs.settings 1.0 +import QtQuick.Dialogs 1.2 import "../components" @@ -130,21 +131,31 @@ Rectangle { 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 function applySettings() { console.log("Here we apply the settings"); // here we need to actually move wallet to the new location console.log(settings.wallet_full_path); - - // 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; + var new_wallet_filename = createWalletPath(settings.wallet_path,settings.account_name) console.log("saving in wizard: "+ new_wallet_filename) // 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 } + MessageDialog { + id: walletExistsErrorDialog + title: "Error" + text: qsTr("A wallet with same name already exists. Please change wallet name") + translationManager.emptyString + onAccepted: { + } + } Rectangle { id: nextButton diff --git a/wizard/WizardRecoveryWallet.qml b/wizard/WizardRecoveryWallet.qml index 837f9f86..70bf3d78 100644 --- a/wizard/WizardRecoveryWallet.qml +++ b/wizard/WizardRecoveryWallet.qml @@ -55,6 +55,10 @@ Item { settingsObject['words'] = Utils.lineBreaksToSpaces(uiItem.wordsTextItem.memoText) settingsObject['wallet_path'] = uiItem.walletPath settingsObject['restore_height'] = parseInt(uiItem.restoreHeight) + var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText); + if(wizard.walletExists(walletFullPath)){ + return false + } return recoveryWallet(settingsObject) }