commit c798e5d9a19f42c86aa09bb48fda465ddc6e774d
parent f11bf1dd4a98a5eed571a38f9456a118d2a768a0
Author: SomberNight <somber.night@protonmail.com>
Date: Tue, 7 Apr 2020 16:48:26 +0200
qt: introduce PasswordLineEdit(QLineEdit)
Diffstat:
8 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/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)
diff --git a/electrum/gui/qt/installwizard.py b/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)
diff --git a/electrum/gui/qt/network_dialog.py b/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)
diff --git a/electrum/gui/qt/password_dialog.py b/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()
diff --git a/electrum/gui/qt/util.py b/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.'''
diff --git a/electrum/plugins/hw_wallet/qt.py b/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))
diff --git a/electrum/plugins/ledger/auth2fa.py b/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)
diff --git a/electrum/plugins/trezor/qt.py b/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")