Browse Source

Merge pull request #7385 from BamaHodl/master

Friendlier minimum sizing for small screens for air-gapped signing
patch-4
ghost43 4 years ago
committed by GitHub
parent
commit
f49db86ea8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      electrum/gui/qt/amountedit.py
  2. 15
      electrum/gui/qt/main_window.py
  3. 3
      electrum/gui/qt/transaction_dialog.py

23
electrum/gui/qt/amountedit.py

@ -3,9 +3,9 @@
from decimal import Decimal from decimal import Decimal
from typing import Union from typing import Union
from PyQt5.QtCore import pyqtSignal, Qt from PyQt5.QtCore import pyqtSignal, Qt, QSize
from PyQt5.QtGui import QPalette, QPainter from PyQt5.QtGui import QPalette, QPainter
from PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame) from PyQt5.QtWidgets import (QLineEdit, QStyle, QStyleOptionFrame, QSizePolicy)
from .util import char_width_in_lineedit, ColorScheme from .util import char_width_in_lineedit, ColorScheme
@ -21,13 +21,26 @@ class FreezableLineEdit(QLineEdit):
self.setFrame(not b) self.setFrame(not b)
self.frozen.emit() self.frozen.emit()
class AmountEdit(FreezableLineEdit):
class SizedFreezableLineEdit(FreezableLineEdit):
def __init__(self, *, width: int, parent=None):
super().__init__(parent)
self._width = width
self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
def sizeHint(self) -> QSize:
sh = super().sizeHint()
return QSize(self._width, sh.height())
class AmountEdit(SizedFreezableLineEdit):
shortcut = pyqtSignal() shortcut = pyqtSignal()
def __init__(self, base_unit, is_int=False, parent=None): def __init__(self, base_unit, is_int=False, parent=None):
QLineEdit.__init__(self, parent)
# This seems sufficient for hundred-BTC amounts with 8 decimals # This seems sufficient for hundred-BTC amounts with 8 decimals
self.setFixedWidth(16 * char_width_in_lineedit()) width = 16 * char_width_in_lineedit()
super().__init__(width=width, parent=parent)
self.base_unit = base_unit self.base_unit = base_unit
self.textChanged.connect(self.numbify) self.textChanged.connect(self.numbify)
self.is_int = is_int self.is_int = is_int

15
electrum/gui/qt/main_window.py

@ -82,7 +82,7 @@ from electrum.lnutil import ln_dummy_address, extract_nodeid, ConnStringFormatEr
from electrum.lnaddr import lndecode, LnDecodeException from electrum.lnaddr import lndecode, LnDecodeException
from .exception_window import Exception_Hook from .exception_window import Exception_Hook
from .amountedit import AmountEdit, BTCAmountEdit, FreezableLineEdit, FeerateEdit from .amountedit import AmountEdit, BTCAmountEdit, FreezableLineEdit, FeerateEdit, SizedFreezableLineEdit
from .qrcodewidget import QRCodeWidget, QRDialog from .qrcodewidget import QRCodeWidget, QRDialog
from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit from .qrtextedit import ShowQRTextEdit, ScanQRTextEdit
from .transaction_dialog import show_transaction from .transaction_dialog import show_transaction
@ -241,7 +241,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) tabs.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
central_widget = QWidget() central_widget = QScrollArea()
vbox = QVBoxLayout(central_widget) vbox = QVBoxLayout(central_widget)
vbox.setContentsMargins(0, 0, 0, 0) vbox.setContentsMargins(0, 0, 0, 0)
vbox.addWidget(tabs) vbox.addWidget(tabs)
@ -249,6 +249,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
self.setCentralWidget(central_widget) self.setCentralWidget(central_widget)
self.setMinimumWidth(640)
self.setMinimumHeight(400)
if self.config.get("is_maximized"): if self.config.get("is_maximized"):
self.showMaximized() self.showMaximized()
@ -1062,7 +1064,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
grid.setSpacing(8) grid.setSpacing(8)
grid.setColumnStretch(3, 1) grid.setColumnStretch(3, 1)
self.receive_message_e = QLineEdit() self.receive_message_e = SizedFreezableLineEdit(width=700)
grid.addWidget(QLabel(_('Description')), 0, 0) grid.addWidget(QLabel(_('Description')), 0, 0)
grid.addWidget(self.receive_message_e, 0, 1, 1, 4) grid.addWidget(self.receive_message_e, 0, 1, 1, 4)
self.receive_message_e.textChanged.connect(self.update_receive_qr) self.receive_message_e.textChanged.connect(self.update_receive_qr)
@ -1091,7 +1093,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
i = 0 i = 0
self.expires_combo.addItems(evl_values) self.expires_combo.addItems(evl_values)
self.expires_combo.setCurrentIndex(i) self.expires_combo.setCurrentIndex(i)
self.expires_combo.setFixedWidth(self.receive_amount_e.width())
def on_expiry(i): def on_expiry(i):
self.config.set_key('request_expiry', evl_keys[i]) self.config.set_key('request_expiry', evl_keys[i])
self.expires_combo.currentIndexChanged.connect(on_expiry) self.expires_combo.currentIndexChanged.connect(on_expiry)
@ -1124,13 +1125,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
buttons.addWidget(self.clear_invoice_button) buttons.addWidget(self.clear_invoice_button)
buttons.addWidget(self.create_invoice_button) buttons.addWidget(self.create_invoice_button)
if self.wallet.has_lightning(): if self.wallet.has_lightning():
self.create_invoice_button.setText(_('New Address'))
self.create_lightning_invoice_button = QPushButton(_('Lightning')) self.create_lightning_invoice_button = QPushButton(_('Lightning'))
self.create_lightning_invoice_button.setToolTip('Create lightning request') self.create_lightning_invoice_button.setToolTip('Create lightning request')
self.create_lightning_invoice_button.setIcon(read_QIcon("lightning.png")) self.create_lightning_invoice_button.setIcon(read_QIcon("lightning.png"))
self.create_lightning_invoice_button.clicked.connect(lambda: self.create_invoice(True)) self.create_lightning_invoice_button.clicked.connect(lambda: self.create_invoice(True))
buttons.addWidget(self.create_lightning_invoice_button) buttons.addWidget(self.create_lightning_invoice_button)
grid.addLayout(buttons, 4, 3, 1, 2) grid.addLayout(buttons, 4, 0, 1, -1)
self.receive_payreq_e = ButtonsTextEdit() self.receive_payreq_e = ButtonsTextEdit()
self.receive_payreq_e.setFont(QFont(MONOSPACE_FONT)) self.receive_payreq_e.setFont(QFont(MONOSPACE_FONT))
@ -1370,8 +1370,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
+ _('The description is not sent to the recipient of the funds. It is stored in your wallet file, and displayed in the \'History\' tab.') + _('The description is not sent to the recipient of the funds. It is stored in your wallet file, and displayed in the \'History\' tab.')
description_label = HelpLabel(_('Description'), msg) description_label = HelpLabel(_('Description'), msg)
grid.addWidget(description_label, 2, 0) grid.addWidget(description_label, 2, 0)
self.message_e = FreezableLineEdit() self.message_e = SizedFreezableLineEdit(width=700)
self.message_e.setMinimumWidth(700)
grid.addWidget(self.message_e, 2, 1, 1, -1) grid.addWidget(self.message_e, 2, 1, 1, -1)
msg = _('Amount to be sent.') + '\n\n' \ msg = _('Amount to be sent.') + '\n\n' \

3
electrum/gui/qt/transaction_dialog.py

@ -110,7 +110,8 @@ class BaseTxDialog(QDialog, MessageBoxMixin):
self.prompt_if_unsaved = prompt_if_unsaved self.prompt_if_unsaved = prompt_if_unsaved
self.saved = False self.saved = False
self.desc = desc self.desc = desc
self.setMinimumWidth(1200) self.setMinimumWidth(640)
self.resize(1200,600)
self.set_title() self.set_title()
self.psbt_only_widgets = [] # type: List[QWidget] self.psbt_only_widgets = [] # type: List[QWidget]

Loading…
Cancel
Save