1
0

simplified dialog for new file name

This commit is contained in:
ThomasV
2014-07-11 19:29:18 +02:00
parent f33cebfb4e
commit c397f84fed
2 changed files with 28 additions and 4 deletions

View File

@@ -75,7 +75,7 @@ PR_ERROR = 4 # could not parse
from electrum import ELECTRUM_VERSION
import re
from util import *
from util import MyTreeWidget, HelpButton, EnterButton, line_dialog, text_dialog, ok_cancel_buttons, close_button
def format_status(x):
@@ -286,12 +286,20 @@ class ElectrumWindow(QMainWindow):
import installwizard
wallet_folder = os.path.dirname(self.wallet.storage.path)
filename = unicode( QFileDialog.getSaveFileName(self, _('Enter a new file name'), wallet_folder) )
i = 1
while True:
filename = "wallet_%d"%i
if filename in os.listdir(wallet_folder):
i += 1
else:
break
filename = line_dialog(self, _('New Wallet'), _('Enter file name') + ':', _('OK'), filename)
if not filename:
return
filename = os.path.join(wallet_folder, filename)
storage = WalletStorage({'wallet_path': filename})
full_path = os.path.join(wallet_folder, filename)
storage = WalletStorage({'wallet_path': full_path})
if storage.file_exists:
QMessageBox.critical(None, "Error", _("File exists"))
return