示例#1
0
文件: qt.py 项目: PiRK/ElectrumABC
 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()
示例#2
0
文件: qt.py 项目: PiRK/ElectrumABC
 def word_dialog(self, msg):
     dialog = WindowModalDialog(self.top_level_window(), "")
     hbox = QtWidgets.QHBoxLayout(dialog)
     hbox.addWidget(QtWidgets.QLabel(msg))
     text = QtWidgets.QLineEdit()
     text.setMaximumWidth(100)
     text.returnPressed.connect(dialog.accept)
     hbox.addWidget(text)
     hbox.addStretch(1)
     dialog.exec_()  # Firmware cannot handle cancellation
     self.word = text.text()
     self.done.set()
示例#3
0
 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()
示例#4
0
    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)
示例#6
0
    def settings_dialog(self, window):
        if not self.is_available():
            window.show_error(err_reason)
            return
        d = WindowModalDialog(window, _("Audio Modem Settings"))

        layout = QtWidgets.QGridLayout(d)
        layout.addWidget(QtWidgets.QLabel(_('Bit rate [kbps]: ')), 0, 0)

        bitrates = list(sorted(amodem.config.bitrates.keys()))

        def _index_changed(index):
            bitrate = bitrates[index]
            self.modem_config = amodem.config.bitrates[bitrate]

        combo = QtWidgets.QComboBox()
        combo.addItems([str(x) for x in bitrates])
        combo.currentIndexChanged.connect(_index_changed)
        layout.addWidget(combo, 0, 1)

        ok_button = QtWidgets.QPushButton(_("OK"))
        ok_button.clicked.connect(d.accept)
        layout.addWidget(ok_button, 1, 1)

        return bool(d.exec_())
示例#7
0
    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
示例#8
0
    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)
示例#9
0
 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_())
示例#10
0
    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'))
示例#11
0
    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!"))
示例#12
0
    def settings_dialog(self, window):
        d = WindowModalDialog(window, _("Audio Modem Settings"))

        layout = QGridLayout(d)
        layout.addWidget(QLabel(_('Bit rate [kbps]: ')), 0, 0)

        bitrates = list(sorted(amodem.config.bitrates.keys()))

        def _index_changed(index):
            bitrate = bitrates[index]
            self.modem_config = amodem.config.bitrates[bitrate]

        combo = QComboBox()
        combo.addItems(map(str, bitrates))
        combo.currentIndexChanged.connect(_index_changed)
        layout.addWidget(combo, 0, 1)

        ok_button = QPushButton(_("OK"))
        ok_button.clicked.connect(d.accept)
        layout.addWidget(ok_button, 1, 1)

        return bool(d.exec_())
示例#13
0
	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))
示例#14
0
    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)
示例#15
0
    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()