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 settings_dialog(self, windowRef): window = windowRef( ) # NB: window is the internal plugins dialog and not the wallet window if not window or not isinstance(window_parent(window), ElectrumWindow): return wallet = window_parent(window).wallet d = WindowModalDialog(window.top_level_window(), _("Label Settings")) d.ok_button = OkButton(d) dlgRef = Weak.ref(d) if wallet in self.wallets: class MySigs(QObject): ok_button_disable_sig = pyqtSignal(bool) d.sigs = MySigs(d) d.sigs.ok_button_disable_sig.connect( d.ok_button.setDisabled ) # disable ok button while the TaskThread runs .. hbox = QHBoxLayout() hbox.addWidget(QLabel(_("LabelSync options:"))) upload = ThreadedButton( "Force upload", partial(Weak(self.do_force_upload), wallet, dlgRef), partial(Weak(self.done_processing), dlgRef), partial(Weak(self.error_processing), dlgRef)) download = ThreadedButton( "Force download", partial(Weak(self.do_force_download), wallet, dlgRef), partial(Weak(self.done_processing), dlgRef), partial(Weak(self.error_processing), dlgRef)) d.thread_buts = (upload, download) d.finished.connect(partial(Weak(self.on_dlg_finished), dlgRef)) vbox = QVBoxLayout() vbox.addWidget(upload) vbox.addWidget(download) hbox.addLayout(vbox) vbox = QVBoxLayout(d) vbox.addLayout(hbox) else: vbox = QVBoxLayout(d) if wallet.network: # has network, so the fact that the wallet isn't in the list means it's incompatible l = QLabel('<b>' + _("LabelSync not supported for this wallet type") + '</b>') l.setAlignment(Qt.AlignCenter) vbox.addWidget(l) l = QLabel(_("(Only deterministic wallets are supported)")) l.setAlignment(Qt.AlignCenter) vbox.addWidget(l) else: # Does not have network, so we won't speak of incompatibility, but instead remind user offline mode means OFFLINE! ;) l = QLabel( _("You are using Electron Cash in offline mode; restart Electron Cash if you want to get connected" )) l.setWordWrap(True) vbox.addWidget(l) vbox.addSpacing(20) vbox.addLayout(Buttons(d.ok_button)) return bool(d.exec_())
def settings_dialog(self, window): d = WindowModalDialog(window, _("CashShuffle settings")) d.setMinimumSize(500, 200) vbox = QVBoxLayout(d) vbox.addWidget(QLabel(_('CashShuffle server'))) grid = QGridLayout() vbox.addLayout(grid) grid.addWidget(QLabel('server'), 0, 0) grid.addWidget(QLabel('use SSL'), 1, 0) server_e = QLineEdit() server_ssl_e = QCheckBox() server_e.setText(self.server) server_ssl_e.setChecked(self.config.get('coinshufflessl',False)) server_ssl_e.stateChanged.connect(lambda: self.config.set_key('coinshufflessl', server_ssl_e.isChecked())) grid.addWidget(server_e, 0, 1) grid.addWidget(server_ssl_e, 1, 1) vbox.addStretch() vbox.addLayout(Buttons(CloseButton(d), OkButton(d))) if not d.exec_(): return server = str(server_e.text()) # server_ssl = server_ssl_e.isChecked() self.config.set_key('coinshuffleserver', server)
def settings_dialog(self, window): # Return a settings dialog. d = WindowModalDialog(window, _("Email settings")) vbox = QtWidgets.QVBoxLayout(d) d.setMinimumSize(500, 200) vbox.addStretch() vbox.addLayout(Buttons(CloseButton(d), OkButton(d))) d.show()
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 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=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 settings_dialog(self, window): wallet = window.parent().wallet d = WindowModalDialog(window, _("Label Settings")) hbox = QHBoxLayout() hbox.addWidget(QLabel("Label sync options:")) upload = ThreadedButton("Force upload", partial(self.push_thread, wallet), partial(self.done_processing, d)) download = ThreadedButton("Force download", partial(self.pull_thread, wallet, True), partial(self.done_processing, d)) vbox = QVBoxLayout() vbox.addWidget(upload) vbox.addWidget(download) hbox.addLayout(vbox) vbox = QVBoxLayout(d) vbox.addLayout(hbox) vbox.addSpacing(20) vbox.addLayout(Buttons(OkButton(d))) return bool(d.exec_())
def settings_dialog(self, windowRef): window = windowRef() if not window: return d = WindowModalDialog(window.top_level_window(), _("Email settings")) d.setMinimumSize(500, 200) vbox = QVBoxLayout(d) vbox.addWidget(QLabel(_('Server hosting your email account'))) grid = QGridLayout() vbox.addLayout(grid) grid.addWidget(QLabel('Server (IMAP)'), 0, 0) server_e = QLineEdit() server_e.setText(self.imap_server) grid.addWidget(server_e, 0, 1) grid.addWidget(QLabel('Username'), 1, 0) username_e = QLineEdit() username_e.setText(self.username) grid.addWidget(username_e, 1, 1) grid.addWidget(QLabel('Password'), 2, 0) password_e = QLineEdit() password_e.setText(self.password) grid.addWidget(password_e, 2, 1) vbox.addStretch() vbox.addLayout(Buttons(CloseButton(d), OkButton(d))) if not d.exec_(): return server = str(server_e.text()) self.config.set_key('email_server', server) username = str(username_e.text()) self.config.set_key('email_username', username) password = str(password_e.text()) self.config.set_key('email_password', password) window.show_message( _('Please restart the plugin to activate the new settings'))
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())
def settings_dialog(self, window): d = WindowModalDialog(window, _("Email settings")) d.setMinimumSize(500, 200) vbox = QVBoxLayout(d) vbox.addWidget(QLabel(_('Server hosting your email acount'))) grid = QGridLayout() vbox.addLayout(grid) grid.addWidget(QLabel('Server (IMAP)'), 0, 0) server_e = QLineEdit() server_e.setText(self.imap_server) grid.addWidget(server_e, 0, 1) grid.addWidget(QLabel('Username'), 1, 0) username_e = QLineEdit() username_e.setText(self.username) grid.addWidget(username_e, 1, 1) grid.addWidget(QLabel('Password'), 2, 0) password_e = QLineEdit() password_e.setText(self.password) grid.addWidget(password_e, 2, 1) vbox.addStretch() vbox.addLayout(Buttons(CloseButton(d), OkButton(d))) if not d.exec_(): return server = str(server_e.text()) self.config.set_key('email_server', server) username = str(username_e.text()) self.config.set_key('email_username', username) password = str(password_e.text()) self.config.set_key('email_password', password)
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')) OK_button = OkButton(d, _('Enter Passphrase')) OnDevice_button = QtWidgets.QPushButton(_('Enter Passphrase on Device')) new_pw = PasswordLineEdit() conf_pw = PasswordLineEdit() vbox = QtWidgets.QVBoxLayout() label = QtWidgets.QLabel(msg + "\n") label.setWordWrap(True) grid = QtWidgets.QGridLayout() grid.setSpacing(8) grid.setColumnMinimumWidth(0, 150) grid.setColumnMinimumWidth(1, 100) grid.setColumnStretch(1,1) vbox.addWidget(label) grid.addWidget(QtWidgets.QLabel(_('Passphrase:')), 0, 0) grid.addWidget(new_pw, 0, 1) if confirm: grid.addWidget(QtWidgets.QLabel(_('Confirm Passphrase:')), 1, 0) grid.addWidget(conf_pw, 1, 1) vbox.addLayout(grid) def enable_OK(): if not confirm: ok = True else: ok = new_pw.text() == conf_pw.text() OK_button.setEnabled(ok) new_pw.textChanged.connect(enable_OK) conf_pw.textChanged.connect(enable_OK) vbox.addWidget(OK_button) if self.passphrase_on_device: vbox.addWidget(OnDevice_button) d.setLayout(vbox) self.passphrase = None def ok_clicked(): self.passphrase = new_pw.text() def on_device_clicked(): self.passphrase = PASSPHRASE_ON_DEVICE OK_button.clicked.connect(ok_clicked) OnDevice_button.clicked.connect(on_device_clicked) OnDevice_button.clicked.connect(d.accept) d.exec_() self.done.set()