def passphrase_dialog(self, msg, confirm): # If confirm is true, require the user to enter the passphrase twice parent = self.top_level_window() d = WindowModalDialog(parent, _("Enter Passphrase")) if confirm: OK_button = OkButton(d) playout = PasswordLayout(msg=msg, kind=PW_PASSPHRASE, OK_button=OK_button) vbox = QtWidgets.QVBoxLayout() vbox.addLayout(playout.layout()) vbox.addLayout(Buttons(CancelButton(d), OK_button)) d.setLayout(vbox) passphrase = playout.new_password() if d.exec_() else None else: pw = QtWidgets.QLineEdit() pw.setEchoMode(2) pw.setMinimumWidth(200) vbox = QtWidgets.QVBoxLayout() vbox.addWidget(WWLabel(msg)) vbox.addWidget(pw) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) d.setLayout(vbox) passphrase = pw.text() if d.exec_() else None self.passphrase = passphrase self.done.set()
def pin_dialog(self, msg): # Needed e.g. when resetting a device self.clear_dialog() dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN")) matrix = self.pin_matrix_widget_class() vbox = QVBoxLayout() vbox.addWidget(QLabel(msg)) vbox.addWidget(matrix) vbox.addLayout(Buttons(CancelButton(dialog), OkButton(dialog))) dialog.setLayout(vbox) dialog.exec_() self.response = str(matrix.get_value()) self.done.set()
def __init__(self, parent, wallet): WindowModalDialog.__init__(self, parent) is_encrypted = wallet.has_storage_encryption() OK_button = OkButton(self) self.create_password_layout(wallet, is_encrypted, OK_button) self.setWindowTitle(self.playout.title()) vbox = QtWidgets.QVBoxLayout(self) vbox.addLayout(self.playout.layout()) vbox.addStretch(1) vbox.addLayout(Buttons(CancelButton(self), OK_button)) self.playout.encrypt_cb.setChecked(is_encrypted)
def message_dialog(self, msg, on_cancel): # Called more than once during signing, to confirm output and fee self.clear_dialog() title = _('Please check your {} device').format(self.device) self.dialog = dialog = WindowModalDialog(self.top_level_window(), title) l = QtWidgets.QLabel(msg) vbox = QtWidgets.QVBoxLayout(dialog) vbox.addWidget(l) if on_cancel: dialog.rejected.connect(on_cancel) vbox.addLayout(Buttons(CancelButton(dialog))) dialog.show()
def __init__(self, parent=None, msg=None): msg = msg or _('Please enter your password') WindowModalDialog.__init__(self, parent, _("Enter Password")) self.pw = pw = PasswordLineEdit() vbox = QtWidgets.QVBoxLayout() vbox.addWidget(QtWidgets.QLabel(msg)) grid = QtWidgets.QGridLayout() grid.setSpacing(8) grid.addWidget(QtWidgets.QLabel(_('Password')), 1, 0) grid.addWidget(pw, 1, 1) vbox.addLayout(grid) vbox.addLayout(Buttons(CancelButton(self), OkButton(self))) self.setLayout(vbox) run_hook('password_dialog', pw, grid, 1)
def reset_seed_dialog(self, msg): print_error("In reset_seed_dialog") parent = self.top_level_window() d = WindowModalDialog(parent, _("Enter PIN")) pw = PasswordLineEdit() pw.setMinimumWidth(200) vbox = QtWidgets.QVBoxLayout() vbox.addWidget(WWLabel(msg)) vbox.addWidget(pw) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) d.setLayout(vbox) passphrase = pw.text() if d.exec_() else None return passphrase
def __init__(self, wallet, parent=None, msg=None, title=None, permit_empty=False): msg = msg or _('Please enter a passphrase') title = title or _("Enter Passphrase") super().__init__(parent, title) if parent is None: # Force app-modal if no parent window given self.setWindowModality(Qt.ApplicationModal) OK_button = OkButton(self) self.playout = PasswordLayout( msg, PW_PASSPHRASE, OK_button, wallet, permit_empty=permit_empty, ) self.setWindowTitle(title) vbox = QtWidgets.QVBoxLayout(self) vbox.addLayout(self.playout.layout()) vbox.addStretch(1) vbox.addLayout(Buttons(CancelButton(self), OK_button))
def reset_seed_dialog(self, msg): parent = self.top_level_window() d = WindowModalDialog(parent, _("Enter PIN")) pw = QLineEdit() pw.setEchoMode(2) pw.setMinimumWidth(200) cb_reset_2FA = QCheckBox(_('Also reset 2FA')) vbox = QVBoxLayout() vbox.addWidget(WWLabel(msg)) vbox.addWidget(pw) vbox.addWidget(cb_reset_2FA) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) d.setLayout(vbox) passphrase = pw.text() if d.exec_() else None reset_2FA = cb_reset_2FA.isChecked() return (passphrase, reset_2FA)
def change_card_label_dialog(self, client, msg): print_error("In change_card_label_dialog") while (True): parent = self.top_level_window() d = WindowModalDialog(parent, _("Enter Label")) pw = QtWidgets.QLineEdit() pw.setEchoMode(0) pw.setMinimumWidth(200) vbox = QtWidgets.QVBoxLayout() vbox.addWidget(WWLabel(msg)) vbox.addWidget(pw) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) d.setLayout(vbox) label = pw.text() if d.exec_() else None if label is None or len(label.encode('utf-8')) <= 64: return label else: client.handler.show_error( _("Card label should not be longer than 64 chars!"))
def export_dialog(self, tips: list): d = WindowModalDialog(self.parent, _('Export {c} Tips').format(c=len(tips))) d.setMinimumSize(400, 200) vbox = QVBoxLayout(d) defaultname = os.path.expanduser(read_config(self.wallet, 'export_history_filename', f"~/ChainTipper tips - wallet {self.wallet.basename()}.csv")) select_msg = _('Select file to export your tips to') box, filename_e, csv_button = filename_field(self.config, defaultname, select_msg) vbox.addWidget(box) vbox.addStretch(1) hbox = Buttons(CancelButton(d), OkButton(d, _('Export'))) vbox.addLayout(hbox) #run_hook('export_history_dialog', self, hbox) #self.update() res = d.exec_() d.setParent(None) # for python GC if not res: return filename = filename_e.text() write_config(self.wallet, 'export_history_filename', filename) if not filename: return success = False try: # minimum 10s time for calc. fees, etc success = self.do_export_history(filename) except Exception as reason: traceback.print_exc(file=sys.stderr) export_error_label = _("Error exporting tips") self.parent.show_critical(export_error_label + "\n" + str(reason), title=_("Unable to export tips")) else: if success: self.parent.show_message(_("{l} Tips successfully exported to {filename}").format(l=len(tips), filename=filename)) else: self.parent.show_message(_("Exporting tips to {filename} failed. More detail might be seen in terminal output.").format(filename=filename))
def __init__(self, parent, wallet): WindowModalDialog.__init__(self, parent) is_encrypted = wallet.storage.is_encrypted() if not wallet.has_password(): msg = _('Your wallet is not protected.') msg += ' ' + _('Use this dialog to add a password to your wallet.') else: if not is_encrypted: msg = _( 'Your bitcoins are password protected. However, your wallet file is not encrypted.' ) else: msg = _('Your wallet is password protected and encrypted.') msg += ' ' + _('Use this dialog to change your password.') OK_button = OkButton(self) self.playout = PasswordLayout(wallet, msg, PW_CHANGE, OK_button) self.setWindowTitle(self.playout.title()) vbox = QVBoxLayout(self) vbox.addLayout(self.playout.layout()) vbox.addStretch(1) vbox.addLayout(Buttons(CancelButton(self), OK_button)) self.playout.encrypt_cb.setChecked(is_encrypted or not wallet.has_password())