Merge pull request #1492 from ctrlcctrlv/uncopyable-seed
Make seed uncopyable
This commit is contained in:
commit
b1ab49a282
|
@ -416,7 +416,7 @@ class InstallWizard(QDialog):
|
|||
return True
|
||||
|
||||
def show_seed(self, seed, sid):
|
||||
vbox = seed_dialog.show_seed_box_msg(seed, sid)
|
||||
vbox = seed_dialog.show_seed_box_msg(seed, sid, paranoid=True)
|
||||
vbox.addLayout(Buttons(CancelButton(self), OkButton(self, _("Next"))))
|
||||
self.set_layout(vbox)
|
||||
return self.exec_()
|
||||
|
|
|
@ -8,10 +8,26 @@ from util import ButtonsTextEdit
|
|||
|
||||
class ShowQRTextEdit(ButtonsTextEdit):
|
||||
|
||||
def __init__(self, text=None):
|
||||
def __init__(self, text=None, paranoid=False):
|
||||
ButtonsTextEdit.__init__(self, text)
|
||||
self.setReadOnly(1)
|
||||
self.addButton(":icons/qrcode.png", self.qr_show, _("Show as QR code"))
|
||||
self.paranoid = paranoid
|
||||
|
||||
if paranoid:
|
||||
# Paranoid flag forces the user to write down what's in the box,
|
||||
# like Mycelium does. This is useful since many users just copy
|
||||
# and paste their code, then when disaster strikes they don't have
|
||||
# it written down anywhere.
|
||||
self.setAcceptDrops(False) # No dragging and dropping
|
||||
# Use custom context menu to remove copy/paste from menu
|
||||
self.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||
self.qaction = QAction(_("Show as QR code"), self)
|
||||
self.qaction.triggered.connect(self.qr_show)
|
||||
self.addAction(self.qaction)
|
||||
# No text selection allowed.
|
||||
self.setTextInteractionFlags(Qt.NoTextInteraction)
|
||||
|
||||
run_hook('show_text_edit', self)
|
||||
|
||||
def qr_show(self):
|
||||
|
@ -23,6 +39,7 @@ class ShowQRTextEdit(ButtonsTextEdit):
|
|||
QRDialog(s).exec_()
|
||||
|
||||
def contextMenuEvent(self, e):
|
||||
if self.paranoid: return
|
||||
m = self.createStandardContextMenu()
|
||||
m.addAction(_("Show as QR code"), self.qr_show)
|
||||
m.exec_(e.globalPos())
|
||||
|
|
|
@ -47,9 +47,9 @@ def icon_filename(sid):
|
|||
return ":icons/seed.png"
|
||||
|
||||
|
||||
def show_seed_box_msg(seedphrase, sid=None):
|
||||
def show_seed_box_msg(seedphrase, sid=None, paranoid=False):
|
||||
msg = _("Your wallet generation seed is") + ":"
|
||||
vbox = show_seed_box(msg, seedphrase, sid)
|
||||
vbox = show_seed_box(msg, seedphrase, sid, paranoid=paranoid)
|
||||
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/>" \
|
||||
|
@ -60,11 +60,11 @@ def show_seed_box_msg(seedphrase, sid=None):
|
|||
vbox.addStretch(1)
|
||||
return vbox
|
||||
|
||||
def show_seed_box(msg, seed, sid):
|
||||
vbox, seed_e = enter_seed_box(msg, None, sid=sid, text=seed)
|
||||
def show_seed_box(msg, seed, sid, paranoid=False):
|
||||
vbox, seed_e = enter_seed_box(msg, None, sid=sid, text=seed, paranoid=paranoid)
|
||||
return vbox
|
||||
|
||||
def enter_seed_box(msg, window, sid=None, text=None):
|
||||
def enter_seed_box(msg, window, sid=None, text=None, paranoid=False):
|
||||
vbox = QVBoxLayout()
|
||||
logo = QLabel()
|
||||
logo.setPixmap(QPixmap(icon_filename(sid)).scaledToWidth(56))
|
||||
|
@ -75,7 +75,7 @@ def enter_seed_box(msg, window, sid=None, text=None):
|
|||
seed_e = ScanQRTextEdit()
|
||||
seed_e.setTabChangesFocus(True)
|
||||
else:
|
||||
seed_e = ShowQRTextEdit(text=text)
|
||||
seed_e = ShowQRTextEdit(text=text, paranoid=paranoid)
|
||||
seed_e.setMaximumHeight(130)
|
||||
vbox.addWidget(label)
|
||||
grid = QGridLayout()
|
||||
|
|
Loading…
Reference in New Issue