Browse Source

qt: introduce PasswordLineEdit(QLineEdit)

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
c798e5d9a1
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/gui/qt/confirm_tx_dialog.py
  2. 5
      electrum/gui/qt/installwizard.py
  3. 6
      electrum/gui/qt/network_dialog.py
  4. 15
      electrum/gui/qt/password_dialog.py
  5. 6
      electrum/gui/qt/util.py
  6. 6
      electrum/plugins/hw_wallet/qt.py
  7. 8
      electrum/plugins/ledger/auth2fa.py
  8. 8
      electrum/plugins/trezor/qt.py

6
electrum/gui/qt/confirm_tx_dialog.py

@ -34,7 +34,8 @@ from electrum.transaction import Transaction, PartialTransaction
from electrum.simple_config import FEERATE_WARNING_HIGH_FEE
from electrum.wallet import InternalAddressCorruption
from .util import WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton, BlockingWaitingDialog
from .util import (WindowModalDialog, ColorScheme, HelpLabel, Buttons, CancelButton,
BlockingWaitingDialog, PasswordLineEdit)
from .fee_slider import FeeSlider
@ -144,8 +145,7 @@ class ConfirmTxDialog(TxEditor, WindowModalDialog):
grid.addWidget(self.message_label, 6, 0, 1, -1)
self.pw_label = QLabel(_('Password'))
self.pw_label.setVisible(self.password_required)
self.pw = QLineEdit()
self.pw.setEchoMode(2)
self.pw = PasswordLineEdit()
self.pw.setVisible(self.password_required)
grid.addWidget(self.pw_label, 8, 0)
grid.addWidget(self.pw, 8, 1, 1, -1)

5
electrum/gui/qt/installwizard.py

@ -25,7 +25,7 @@ from electrum.i18n import _
from .seed_dialog import SeedLayout, KeysLayout
from .network_dialog import NetworkChoiceLayout
from .util import (MessageBoxMixin, Buttons, icon_path, ChoicesLayout, WWLabel,
InfoButton, char_width_in_lineedit)
InfoButton, char_width_in_lineedit, PasswordLineEdit)
from .password_dialog import PasswordLayout, PasswordLayoutForHW, PW_NEW
from electrum.plugin import run_hook, Plugins
@ -196,9 +196,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
msg_label = WWLabel('')
vbox.addWidget(msg_label)
hbox2 = QHBoxLayout()
pw_e = QLineEdit('', self)
pw_e = PasswordLineEdit('', self)
pw_e.setFixedWidth(17 * char_width_in_lineedit())
pw_e.setEchoMode(2)
pw_label = QLabel(_('Password') + ':')
hbox2.addWidget(pw_label)
hbox2.addWidget(pw_e)

6
electrum/gui/qt/network_dialog.py

@ -40,7 +40,8 @@ from electrum.interface import serialize_server, deserialize_server
from electrum.network import Network
from electrum.logging import get_logger
from .util import Buttons, CloseButton, HelpButton, read_QIcon, char_width_in_lineedit
from .util import (Buttons, CloseButton, HelpButton, read_QIcon, char_width_in_lineedit,
PasswordLineEdit)
_logger = get_logger(__name__)
@ -267,9 +268,8 @@ class NetworkChoiceLayout(object):
self.proxy_port.setFixedWidth(fixed_width_port)
self.proxy_user = QLineEdit()
self.proxy_user.setPlaceholderText(_("Proxy user"))
self.proxy_password = QLineEdit()
self.proxy_password = PasswordLineEdit()
self.proxy_password.setPlaceholderText(_("Password"))
self.proxy_password.setEchoMode(QLineEdit.Password)
self.proxy_password.setFixedWidth(fixed_width_port)
self.proxy_mode.currentIndexChanged.connect(self.set_proxy)

15
electrum/gui/qt/password_dialog.py

@ -33,7 +33,8 @@ from PyQt5.QtWidgets import QLineEdit, QLabel, QGridLayout, QVBoxLayout, QCheckB
from electrum.i18n import _
from electrum.plugin import run_hook
from .util import icon_path, WindowModalDialog, OkButton, CancelButton, Buttons
from .util import (icon_path, WindowModalDialog, OkButton, CancelButton, Buttons,
PasswordLineEdit)
def check_password_strength(password):
@ -63,12 +64,9 @@ class PasswordLayout(object):
def __init__(self, msg, kind, OK_button, wallet=None, force_disable_encrypt_cb=False):
self.wallet = wallet
self.pw = QLineEdit()
self.pw.setEchoMode(2)
self.new_pw = QLineEdit()
self.new_pw.setEchoMode(2)
self.conf_pw = QLineEdit()
self.conf_pw.setEchoMode(2)
self.pw = PasswordLineEdit()
self.new_pw = PasswordLineEdit()
self.conf_pw = PasswordLineEdit()
self.kind = kind
self.OK_button = OK_button
@ -290,8 +288,7 @@ class PasswordDialog(WindowModalDialog):
def __init__(self, parent=None, msg=None):
msg = msg or _('Please enter your password')
WindowModalDialog.__init__(self, parent, _("Enter Password"))
self.pw = pw = QLineEdit()
pw.setEchoMode(2)
self.pw = pw = PasswordLineEdit()
vbox = QVBoxLayout()
vbox.addWidget(QLabel(msg))
grid = QGridLayout()

6
electrum/gui/qt/util.py

@ -748,6 +748,12 @@ class ButtonsTextEdit(QPlainTextEdit, ButtonsWidget):
return o
class PasswordLineEdit(QLineEdit):
def __init__(self, *args, **kwargs):
QLineEdit.__init__(self, *args, **kwargs)
self.setEchoMode(QLineEdit.Password)
class TaskThread(QThread):
'''Thread that runs background tasks. Callbacks are guaranteed
to happen in the context of its parent.'''

6
electrum/plugins/hw_wallet/qt.py

@ -33,7 +33,8 @@ from PyQt5.QtWidgets import QVBoxLayout, QLineEdit, QHBoxLayout, QLabel
from electrum.gui.qt.password_dialog import PasswordLayout, PW_PASSPHRASE
from electrum.gui.qt.util import (read_QIcon, WWLabel, OkButton, WindowModalDialog,
Buttons, CancelButton, TaskThread, char_width_in_lineedit)
Buttons, CancelButton, TaskThread, char_width_in_lineedit,
PasswordLineEdit)
from electrum.gui.qt.main_window import StatusBarButton, ElectrumWindow
from electrum.gui.qt.installwizard import InstallWizard
@ -142,8 +143,7 @@ class QtHandlerBase(HardwareHandlerBase, QObject, Logger):
d.setLayout(vbox)
passphrase = playout.new_password() if d.exec_() else None
else:
pw = QLineEdit()
pw.setEchoMode(2)
pw = PasswordLineEdit()
pw.setMinimumWidth(200)
vbox = QVBoxLayout()
vbox.addWidget(WWLabel(msg))

8
electrum/plugins/ledger/auth2fa.py

@ -5,6 +5,8 @@ from PyQt5.QtWidgets import (QDialog, QLineEdit, QTextEdit, QVBoxLayout, QLabel,
from btchip.btchip import BTChipException
from electrum.gui.qt.util import PasswordLineEdit
from electrum.i18n import _
from electrum import constants, bitcoin
from electrum.logging import get_logger
@ -79,8 +81,7 @@ class LedgerAuthDialog(QDialog):
self.pinbox = QWidget()
pinlayout = QHBoxLayout()
self.pinbox.setLayout(pinlayout)
self.pintxt = QLineEdit()
self.pintxt.setEchoMode(2)
self.pintxt = PasswordLineEdit()
self.pintxt.setMaxLength(4)
self.pintxt.returnPressed.connect(return_pin)
pinlayout.addWidget(QLabel(_("Enter PIN:")))
@ -121,8 +122,7 @@ class LedgerAuthDialog(QDialog):
pin_changed('')
cardpin = QHBoxLayout()
cardpin.addWidget(QLabel(_("Enter PIN:")))
self.cardtxt = QLineEdit()
self.cardtxt.setEchoMode(2)
self.cardtxt = PasswordLineEdit()
self.cardtxt.setMaxLength(len(self.idxs))
self.cardtxt.textChanged.connect(pin_changed)
self.cardtxt.returnPressed.connect(return_pin)

8
electrum/plugins/trezor/qt.py

@ -8,7 +8,7 @@ from PyQt5.QtWidgets import (QVBoxLayout, QLabel, QGridLayout, QPushButton,
QMessageBox, QFileDialog, QSlider, QTabWidget)
from electrum.gui.qt.util import (WindowModalDialog, WWLabel, Buttons, CancelButton,
OkButton, CloseButton)
OkButton, CloseButton, PasswordLineEdit)
from electrum.i18n import _
from electrum.plugin import hook
from electrum.util import bh2u
@ -172,10 +172,8 @@ class QtHandler(QtHandlerBase):
OK_button = OkButton(d, _('Enter Passphrase'))
OnDevice_button = QPushButton(_('Enter Passphrase on Device'))
new_pw = QLineEdit()
new_pw.setEchoMode(2)
conf_pw = QLineEdit()
conf_pw.setEchoMode(2)
new_pw = PasswordLineEdit()
conf_pw = PasswordLineEdit()
vbox = QVBoxLayout()
label = QLabel(msg + "\n")

Loading…
Cancel
Save