def ignore_this_version(self): self.setText("") self.config.set_key("last_seen_version", self.latest_version, True) QMessageBox.information( self, _("Preference saved"), _("Notifications about this update will not be shown again.")) self.dialog.done(0)
def build_tray_menu(self): m = QMenu() m.addAction(_("Show/Hide"), self.show_or_hide) m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Light-Capricoin"), self.close) self.tray.setContextMenu(m)
def before_send(self): ''' Change URL to address before making a send. IMPORTANT: return False to continue execution of the send return True to stop execution of the send ''' if self.win.payto_e.is_multiline( ): # only supports single line entries atm return False if self.win.payto_e.is_pr: return payto_e = str(self.win.payto_e.toPlainText()) regex = re.compile(r'^([^\s]+) <([A-Za-z0-9]+)>' ) # only do that for converted addresses try: (url, address) = regex.search(payto_e).groups() except AttributeError: return False if not self.validated: msgBox = QMessageBox() msgBox.setText( _('WARNING: the address ' + address + ' could not be validated via an additional security check, DNSSEC, and thus may not be correct.' )) msgBox.setInformativeText(_('Do you wish to continue?')) msgBox.setStandardButtons(QMessageBox.Cancel | QMessageBox.Ok) msgBox.setDefaultButton(QMessageBox.Cancel) reply = msgBox.exec_() if reply != QMessageBox.Ok: return True return False
def qr_input(self): from light_capricoin import qrscanner, get_config try: data = qrscanner.scan_qr(get_config()) except BaseException, e: QMessageBox.warning(self, _('Error'), _(e), _('OK')) return ""
def mouseReleaseEvent(self, event): dialog = QDialog(self) dialog.setWindowTitle(_('Light update')) dialog.setModal(1) main_layout = QGridLayout() main_layout.addWidget( QLabel( _("A new version of Light is available:") + " " + self.latest_version), 0, 0, 1, 3) ignore_version = QPushButton(_("Ignore this version")) ignore_version.clicked.connect(self.ignore_this_version) ignore_all_versions = QPushButton(_("Ignore all versions")) ignore_all_versions.clicked.connect(self.ignore_all_version) open_website = QPushButton(_("Goto download page")) open_website.clicked.connect(self.open_website) main_layout.addWidget(ignore_version, 1, 0) main_layout.addWidget(ignore_all_versions, 1, 1) main_layout.addWidget(open_website, 1, 2) dialog.setLayout(main_layout) self.dialog = dialog if not dialog.exec_(): return
def __init__(self, address, parent): self.address = address self.parent = parent self.config = parent.config self.wallet = parent.wallet self.app = parent.app self.saved = True QDialog.__init__(self) self.setMinimumWidth(700) self.setWindowTitle(_("Address")) self.setModal(1) vbox = QVBoxLayout() self.setLayout(vbox) vbox.addWidget(QLabel(_("Address:"))) self.addr_e = ButtonsLineEdit(self.address) self.addr_e.addCopyButton(self.app) self.addr_e.addButton(":icons/qrcode.png", self.show_qr, _("Show QR Code")) self.addr_e.setReadOnly(True) vbox.addWidget(self.addr_e) vbox.addWidget(QLabel(_("History"))) self.hw = HistoryWidget(self.parent) vbox.addWidget(self.hw) vbox.addStretch(1) vbox.addLayout(Buttons(CloseButton(self))) self.format_amount = self.parent.format_amount h = self.wallet.get_history([self.address]) self.hw.update(h)
def __init__(self, transaction_id, parent): super(TransactionWindow, self).__init__() self.tx_id = str(transaction_id) self.parent = parent self.setModal(True) self.resize(200, 100) self.setWindowTitle(_("Transaction successfully sent")) self.layout = QGridLayout(self) history_label = "%s\n%s" % ( _("Your transaction has been sent."), _("Please enter a label for this transaction for future reference." )) self.layout.addWidget(QLabel(history_label)) self.label_edit = QLineEdit() self.label_edit.setPlaceholderText(_("Transaction label")) self.label_edit.setObjectName("label_input") self.label_edit.setAttribute(Qt.WA_MacShowFocusRect, 0) self.label_edit.setFocusPolicy(Qt.ClickFocus) self.layout.addWidget(self.label_edit) self.save_button = QPushButton(_("Save")) self.layout.addWidget(self.save_button) self.save_button.clicked.connect(self.set_label) self.exec_()
def ignore_all_version(self): self.setText("") self.config.set_key("last_seen_version", "9.9.9", True) QMessageBox.information( self, _("Preference saved"), _("No more notifications about version updates will be shown.")) self.dialog.done(0)
def load_wallet(self, wallet): if self.btchip_is_connected(): if not self.wallet.check_proper_device(): QMessageBox.information(self.window, _('Error'), _("This wallet does not match your BTChip device"), _('OK')) self.wallet.force_watching_only = True else: QMessageBox.information(self.window, _('Error'), _("BTChip device not detected.\nContinuing in watching-only mode."), _('OK')) self.wallet.force_watching_only = True
def give_error(self, message, clear_client = False): if not self.signing: QMessageBox.warning(QDialog(), _('Warning'), _(message), _('OK')) else: self.signing = False if clear_client and self.client is not None: self.client.bad = True self.device_checked = False raise Exception(message)
def close(self): if not self.saved: if QMessageBox.question( self, _('Message'), _('This transaction is not saved. Close anyway?'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.No: return self.done(0)
def verify_seed(self, seed, sid, func=None): r = self.enter_seed_dialog(MSG_VERIFY_SEED, sid, func) if not r: return if prepare_seed(r) != prepare_seed(seed): QMessageBox.warning(None, _('Error'), _('Incorrect seed'), _('OK')) return False else: return True
def __init__(self, parent=None): MyTreeWidget.__init__( self, parent, self.create_menu, ['', _('Date'), _('Description'), _('Amount'), _('Balance')], 2) self.config = self.parent.config self.setSortingEnabled(False)
def export_history_dialog(self, d, hbox): self.wallet = d.wallet history = self.wallet.get_history() if len(history) > 0: b = QPushButton(_("Preview plot")) hbox.addWidget(b) b.clicked.connect(lambda: self.do_plot(self.wallet, history)) else: b = QPushButton(_("No history to plot")) hbox.addWidget(b)
def save(self): name = 'signed_%s.txn' % ( self.tx.hash()[0:8]) if self.tx.is_complete() else 'unsigned.txn' fileName = self.parent.getSaveFileName( _("Select where to save your signed transaction"), name, "*.txn") if fileName: with open(fileName, "w+") as f: f.write(json.dumps(self.tx.as_dict(), indent=4) + '\n') self.show_message(_("Transaction saved successfully")) self.saved = True
def ok_cancel_buttons(dialog): row_layout = QHBoxLayout() row_layout.addStretch(1) ok_button = QPushButton(_("OK")) row_layout.addWidget(ok_button) ok_button.clicked.connect(dialog.accept) cancel_button = QPushButton(_("Cancel")) row_layout.addWidget(cancel_button) cancel_button.clicked.connect(dialog.reject) return row_layout
def __init__(self, parent, seed, imported_keys): QDialog.__init__(self, parent) self.setModal(1) self.setMinimumWidth(400) self.setWindowTitle('Light' + ' - ' + _('Seed')) vbox = show_seed_box_msg(seed) if imported_keys: vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>")) vbox.addLayout(Buttons(CloseButton(self))) self.setLayout(vbox)
def installwizard_restore(self, wizard, storage): if storage.get('wallet_type') != 'btchip': return wallet = BTChipWallet(storage) try: wallet.create_main_account(None) except BaseException as e: QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def append(self, address, amount, date): if address is None: address = _("Unknown") if amount is None: amount = _("Unknown") if date is None: date = _("Unknown") item = QTreeWidgetItem([amount, address, date]) if amount.find('-') != -1: item.setForeground(0, QBrush(QColor("#BC1E1E"))) self.insertTopLevelItem(0, item)
def __init__(self, owner=None): self.owner = owner self.editing = False QTreeWidget.__init__(self, owner) self.setColumnCount(3) self.setHeaderLabels([_("Address"), _("Label"), _("Used")]) self.setIndentation(0) self.hide_used = True self.setColumnHidden(2, True)
def add_io(self, vbox): if self.tx.locktime > 0: vbox.addWidget(QLabel("LockTime: %d\n" % self.tx.locktime)) vbox.addWidget(QLabel(_("Inputs"))) ext = QTextCharFormat() own = QTextCharFormat() own.setBackground(QBrush(QColor("lightgreen"))) own.setToolTip(_("Own address")) i_text = QTextEdit() i_text.setFont(QFont(MONOSPACE_FONT)) i_text.setReadOnly(True) i_text.setMaximumHeight(100) cursor = i_text.textCursor() for x in self.tx.inputs: if x.get('is_coinbase'): cursor.insertText('coinbase') else: prevout_hash = x.get('prevout_hash') prevout_n = x.get('prevout_n') cursor.insertText( prevout_hash[0:8] + '...' + prevout_hash[-8:] + ":%d" % prevout_n, ext) cursor.insertText('\t') addr = x.get('address') if addr == "(pubkey)": _addr = self.wallet.find_pay_to_pubkey_address( prevout_hash, prevout_n) if _addr: addr = _addr if addr is None: addr = _('unknown') cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) cursor.insertBlock() vbox.addWidget(i_text) vbox.addWidget(QLabel(_("Outputs"))) o_text = QTextEdit() o_text.setFont(QFont(MONOSPACE_FONT)) o_text.setReadOnly(True) o_text.setMaximumHeight(100) cursor = o_text.textCursor() for addr, v in self.tx.get_outputs(): cursor.insertText(addr, own if self.wallet.is_mine(addr) else ext) if v is not None: cursor.insertText('\t', ext) cursor.insertText(self.parent.format_amount(v), ext) cursor.insertBlock() vbox.addWidget(o_text)
def close(self): self.d.accept() if self.error: QMessageBox.warning(self.parent, _('Error'), self.error, _('OK')) else: if self.on_success: if type(self.result) is not tuple: self.result = (self.result,) self.on_success(*self.result) if self.on_complete: self.on_complete()
def show_seed_box_msg(seedphrase, sid=None): msg = _("Your wallet generation seed is") + ":" vbox = show_seed_box(msg, seedphrase, sid) save_msg = _("Please save these %d words on paper (order is important).")%len(seedphrase.split()) + " " msg2 = save_msg + " " \ + _("This seed will allow you to recover your wallet in case of computer failure.") + "<br/>" \ + "<b>"+_("WARNING")+":</b> " + _("Never disclose your seed. Never type it on a website.") + "</b><p>" label2 = QLabel(msg2) label2.setWordWrap(True) vbox.addWidget(label2) vbox.addStretch(1) return vbox
def run_wizard(self, storage, action): import installwizard if storage.file_exists and action != 'new': msg = _("The file '%s' contains an incompletely created wallet.")%storage.path + '\n'\ + _("Do you want to complete its creation now?") if not util.question(msg): if util.question( _("Do you want to delete '%s'?") % storage.path): os.remove(storage.path) QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK')) return return wizard = installwizard.InstallWizard(self.config, self.network, storage) wizard.show() if action == 'new': action, wallet_type = wizard.restore_or_create() else: wallet_type = None try: wallet = wizard.run(action, wallet_type) except BaseException as e: traceback.print_exc(file=sys.stdout) QMessageBox.information(None, _('Error'), str(e), _('OK')) return return wallet
def on_change_hist(checked): if checked: self.config.set_key('history_rates', 'checked') self.request_history_rates() else: self.config.set_key('history_rates', 'unchecked') self.win.history_list.setHeaderLabels([ '', _('Date'), _('Description'), _('Amount'), _('Balance') ]) self.win.history_list.setColumnCount(5)
def setup(self, address): label = QLabel(_("Copied your Capricoin address to the clipboard!")) address_display = QLineEdit(address) address_display.setReadOnly(True) resize_line_edit_width(address_display, address) main_layout = QVBoxLayout(self) main_layout.addWidget(label) main_layout.addWidget(address_display) self.setMouseTracking(True) self.setWindowTitle("Light - " + _("Receive Capricoin payment")) self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint | Qt.MSWindowsFixedSizeDialogHint) self.layout().setSizeConstraint(QLayout.SetFixedSize)
def __init__(self, data, parent=None, title="", show_text=False): QDialog.__init__(self, parent) d = self d.setWindowTitle(title) vbox = QVBoxLayout() qrw = QRCodeWidget(data) vbox.addWidget(qrw, 1) if show_text: text = QTextEdit() text.setText(data) text.setReadOnly(True) vbox.addWidget(text) hbox = QHBoxLayout() hbox.addStretch(1) config = light_capricoin.get_config() if config: filename = os.path.join(config.path, "qrcode.bmp") def print_qr(): bmp.save_qrcode(qrw.qr, filename) QMessageBox.information( None, _('Message'), _("QR code saved to file") + " " + filename, _('OK')) def copy_to_clipboard(): bmp.save_qrcode(qrw.qr, filename) QApplication.clipboard().setImage(QImage(filename)) QMessageBox.information(None, _('Message'), _("QR code saved to clipboard"), _('OK')) b = QPushButton(_("Copy")) hbox.addWidget(b) b.clicked.connect(copy_to_clipboard) b = QPushButton(_("Save")) hbox.addWidget(b) b.clicked.connect(print_qr) b = QPushButton(_("Close")) hbox.addWidget(b) b.clicked.connect(d.accept) b.setDefault(True) vbox.addLayout(hbox) d.setLayout(vbox)
def restore_or_create(self): vbox = QVBoxLayout() main_label = QLabel(_("Light could not find an existing wallet.")) vbox.addWidget(main_label) grid = QGridLayout() grid.setSpacing(5) gb1 = QGroupBox(_("What do you want to do?")) vbox.addWidget(gb1) b1 = QRadioButton(gb1) b1.setText(_("Create new wallet")) b1.setChecked(True) b2 = QRadioButton(gb1) b2.setText(_("Restore a wallet or import keys")) group1 = QButtonGroup() group1.addButton(b1) group1.addButton(b2) vbox.addWidget(b1) vbox.addWidget(b2) gb2 = QGroupBox(_("Wallet type:")) vbox.addWidget(gb2) group2 = QButtonGroup() self.wallet_types = [ ('standard', _("Standard wallet")), ('twofactor', _("Wallet with two-factor authentication")), ('multisig', _("Multi-signature wallet")), #('hardware', _("Hardware wallet")), ] for i, (wtype, name) in enumerate(self.wallet_types): if not filter(lambda x: x[0] == wtype, light.wallet.wallet_types): continue button = QRadioButton(gb2) button.setText(name) vbox.addWidget(button) group2.addButton(button) group2.setId(button, i) if i == 0: button.setChecked(True) vbox.addStretch(1) self.set_layout(vbox) vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _('Next')))) self.show() self.raise_() if not self.exec_(): return None, None action = 'create' if b1.isChecked() else 'restore' wallet_type = self.wallet_types[group2.checkedId()][0] return action, wallet_type
def __init__(self, win): QWidget.__init__(self) self.win = win self.setWindowTitle('Light - '+_('Payment Request')) self.setMinimumSize(800, 250) self.address = '' self.label = '' self.amount = 0 self.setFocusPolicy(QtCore.Qt.NoFocus) main_box = QHBoxLayout() self.qrw = QRCodeWidget() main_box.addWidget(self.qrw, 1) vbox = QVBoxLayout() main_box.addLayout(vbox) self.address_label = QLabel("") #self.address_label.setFont(QFont(MONOSPACE_FONT)) vbox.addWidget(self.address_label) self.label_label = QLabel("") vbox.addWidget(self.label_label) self.amount_label = QLabel("") vbox.addWidget(self.amount_label) vbox.addStretch(1) self.setLayout(main_box)
def password_dialog(self, pw, grid, pos): vkb_button = QPushButton(_("+")) vkb_button.setFixedWidth(20) vkb_button.clicked.connect(lambda: self.toggle_vkb(grid, pw)) grid.addWidget(vkb_button, pos, 2) self.kb_pos = 2 self.vkb = None