electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c397f84fed33cd941859837237eb6b82f5acc414
parent f33cebfb4e5218f0fa8eb78c9e28608703d2dc4a
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 11 Jul 2014 19:29:18 +0200

simplified dialog for new file name

Diffstat:
Mgui/qt/main_window.py | 16++++++++++++----
Mgui/qt/util.py | 16++++++++++++++++
2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -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 diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -110,6 +110,22 @@ def ok_cancel_buttons(dialog, ok_label=_("OK") ): hbox, b = ok_cancel_buttons2(dialog, ok_label) return hbox +def line_dialog(parent, title, label, ok_label, default=None): + dialog = QDialog(parent) + dialog.setMinimumWidth(500) + dialog.setWindowTitle(title) + dialog.setModal(1) + l = QVBoxLayout() + dialog.setLayout(l) + l.addWidget(QLabel(label)) + txt = QLineEdit() + if default: + txt.setText(default) + l.addWidget(txt) + l.addLayout(ok_cancel_buttons(dialog, ok_label)) + if dialog.exec_(): + return unicode(txt.text()) + def text_dialog(parent, title, label, ok_label, default=None): from qrtextedit import QRTextEdit dialog = QDialog(parent)