electrum

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

commit 6178f5a28f16a4dac052313139e0d9c0f9fd1c4e
parent fd66e15d3d67463153ec9b9e343f22dc19217328
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Wed, 13 Jan 2016 22:25:40 +0900

Fix some more regressions and trustedcoin plugin

Diffstat:
Mgui/qt/installwizard.py | 26++++++++++++++------------
Mplugins/trustedcoin/qt.py | 45+++++++++++++++++++++++----------------------
Mplugins/trustedcoin/trustedcoin.py | 4++--
3 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -73,8 +73,8 @@ class InstallWizard(WindowModalDialog, WizardBase): # Set for base base class self.plugins = plugins self.language_for_seed = config.get('language') - self.setMinimumSize(518, 360) - self.setMaximumSize(518, 360) + self.setMinimumSize(530, 370) + self.setMaximumSize(530, 370) self.connect(self, QtCore.SIGNAL('accept'), self.accept) self.title = WWLabel() self.main_widget = QWidget() @@ -109,6 +109,7 @@ class InstallWizard(WindowModalDialog, WizardBase): self.set_icon(':icons/electrum.png') self.show() self.raise_() + self.refresh_gui() # Need for QT on MacOSX. Lame. def finished(self): '''Ensure the dialog is closed.''' @@ -117,19 +118,20 @@ class InstallWizard(WindowModalDialog, WizardBase): def set_icon(self, filename): prior_filename, self.icon_filename = self.icon_filename, filename - self.logo.setPixmap(QPixmap(filename).scaledToWidth(70)) + self.logo.setPixmap(QPixmap(filename).scaledToWidth(60)) return prior_filename - def set_main_layout(self, layout, title=None, raise_on_cancel=True): + def set_main_layout(self, layout, title=None, raise_on_cancel=True, + next_enabled=True): self.title.setText(title or "") self.title.setVisible(bool(title)) - # Get rid of any prior layout + # Get rid of any prior layout by assigning it to a temporary widget prior_layout = self.main_widget.layout() if prior_layout: QWidget().setLayout(prior_layout) self.main_widget.setLayout(layout) self.cancel_button.setEnabled(True) - self.next_button.setEnabled(True) + self.next_button.setEnabled(next_enabled) self.main_widget.setVisible(True) self.please_wait.setVisible(False) result = self.loop.exec_() @@ -165,13 +167,12 @@ class InstallWizard(WindowModalDialog, WizardBase): def request_seed(self, title, is_valid=None): is_valid = is_valid or Wallet.is_any slayout = SeedInputLayout() - self.next_button.setEnabled(False) def sanitized_seed(): return clean_text(slayout.seed_edit()) def set_enabled(): self.next_button.setEnabled(is_valid(sanitized_seed())) slayout.seed_edit().textChanged.connect(set_enabled) - self.set_main_layout(slayout.layout(), title) + self.set_main_layout(slayout.layout(), title, next_enabled=False) return sanitized_seed() def show_seed(self, seed): @@ -211,6 +212,9 @@ class InstallWizard(WindowModalDialog, WizardBase): return self.pw_layout(msg or MSG_ENTER_PASSWORD, PW_NEW) def show_restore(self, wallet, network): + # FIXME: these messages are shown after the install wizard is + # finished and the window closed. On MacOSX they appear parented + # with a re-appeared ghost install wizard window... if network: def task(): wallet.wait_until_synchronized() @@ -282,7 +286,6 @@ class InstallWizard(WindowModalDialog, WizardBase): innerVbox.addLayout(layout.layout()) entries.append(layout.seed_edit()) - self.next_button.setEnabled(False) def get_texts(): return [clean_text(entry) for entry in entries] def set_enabled(): @@ -295,7 +298,7 @@ class InstallWizard(WindowModalDialog, WizardBase): self.next_button.setEnabled(all_valid and not has_dups) for e in entries: e.textChanged.connect(set_enabled) - self.set_main_layout(vbox) + self.set_main_layout(vbox, next_enabled=False) return get_texts() def choose_server(self, network): @@ -321,8 +324,7 @@ class InstallWizard(WindowModalDialog, WizardBase): def query_choice(self, msg, choices): clayout = ChoicesLayout(msg, choices) - self.next_button.setEnabled(bool(choices)) - self.set_main_layout(clayout.layout()) + self.set_main_layout(clayout.layout(), next_enabled=bool(choices)) return clayout.selected_index() def query_multisig(self, action): diff --git a/plugins/trustedcoin/qt.py b/plugins/trustedcoin/qt.py @@ -102,15 +102,15 @@ class Plugin(TrustedCoinPlugin): return WaitingDialog(window, 'Getting billing information...', task, on_finished) - def show_disclaimer(self, wallet, window): - prior_icon = window.set_icon(':icons/trustedcoin.png') - label = QLabel('\n\n'.join(DISCLAIMER)) - label.setWordWrap(True) + def confirm(self, window, msg): vbox = QVBoxLayout() - vbox.addWidget(label) + vbox.addWidget(WWLabel(msg)) window.set_main_layout(vbox) + + def show_disclaimer(self, wallet, window): + window.set_icon(':icons/trustedcoin.png') + self.confirm(window, '\n\n'.join(DISCLAIMER)) self.set_enabled(wallet, True) - window.set_icon(prior_icon) @hook def abort_send(self, window): @@ -216,7 +216,6 @@ class Plugin(TrustedCoinPlugin): def accept_terms_of_use(self, window): vbox = QVBoxLayout() - window.set_layout(vbox) vbox.addWidget(QLabel(_("Terms of Service"))) tos_e = QTextEdit() @@ -226,10 +225,10 @@ class Plugin(TrustedCoinPlugin): vbox.addWidget(QLabel(_("Please enter your e-mail address"))) email_e = QLineEdit() vbox.addWidget(email_e) - vbox.addStretch() - accept_button = OkButton(window, _('Accept')) - accept_button.setEnabled(False) - vbox.addLayout(Buttons(CancelButton(window), accept_button)) + + next_button = window.next_button + prior_button_text = next_button.text() + next_button.setText(_('Accept')) def request_TOS(): tos = server.get_terms_of_service() @@ -239,24 +238,26 @@ class Plugin(TrustedCoinPlugin): def on_result(): tos_e.setText(self.TOS) + def set_enabled(): + next_button.setEnabled(re.match(regexp,email_e.text()) is not None) + window.connect(window, SIGNAL('twofactor:TOS'), on_result) t = Thread(target=request_TOS) t.setDaemon(True) t.start() regexp = r"[^@]+@[^@]+\.[^@]+" - email_e.textChanged.connect(lambda: accept_button.setEnabled(re.match(regexp,email_e.text()) is not None)) + email_e.textChanged.connect(set_enabled) email_e.setFocus(True) - if not window.exec_(): - raise wizard.UserCancelled + window.set_main_layout(vbox, next_enabled=False) + next_button.setText(prior_button_text) return str(email_e.text()) def setup_google_auth(self, window, _id, otp_secret): vbox = QVBoxLayout() - window.set_layout(vbox) if otp_secret is not None: uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret) vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator.")) @@ -270,20 +271,20 @@ class Plugin(TrustedCoinPlugin): msg = _('Google Authenticator code:') hbox = QHBoxLayout() - hbox.addWidget(QLabel(msg)) + hbox.addWidget(WWLabel(msg)) pw = AmountEdit(None, is_int = True) pw.setFocus(True) + pw.setMaximumWidth(50) hbox.addWidget(pw) - hbox.addStretch(1) vbox.addLayout(hbox) - b = OkButton(window, _('Next')) - b.setEnabled(False) - vbox.addLayout(Buttons(CancelButton(window), b)) - pw.textChanged.connect(lambda: b.setEnabled(len(pw.text())==6)) + def set_enabled(): + window.next_button.setEnabled(len(pw.text()) == 6) + pw.textChanged.connect(set_enabled) while True: - if not window.exec_(): + if not window.set_main_layout(vbox, next_enabled=False, + raise_on_cancel=False): return False otp = pw.get_amount() try: diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py @@ -345,7 +345,7 @@ class TrustedCoinPlugin(BasePlugin): _('If you are online, click on "%s" to continue.') % _('Next') ] msg = '\n\n'.join(msg) - window.confirm(msg) + self.confirm(window, msg) @hook def do_clear(self, window): @@ -361,7 +361,7 @@ class TrustedCoinPlugin(BasePlugin): words = seed.split() n = len(words)/2 wallet.add_xprv_from_seed(' '.join(words[0:n]), 'x1/', password) - wallet.add_xpub_from_seed(' '.join(words[n:]), 'x2/', password) + wallet.add_xpub_from_seed(' '.join(words[n:]), 'x2/') restore_third_key(wallet) wallet.create_main_account()