Qt send tab: move payto_edit input buttons to toolbar
This commit is contained in:
@@ -65,7 +65,7 @@ class PayToEdit(CompletionTextEdit, ScanQRTextEdit, Logger):
|
||||
|
||||
def __init__(self, send_tab: 'SendTab'):
|
||||
CompletionTextEdit.__init__(self)
|
||||
ScanQRTextEdit.__init__(self, config=send_tab.config, setText=self._on_input_btn)
|
||||
ScanQRTextEdit.__init__(self, config=send_tab.config, setText=self._on_input_btn, is_payto=True)
|
||||
Logger.__init__(self)
|
||||
self.send_tab = send_tab
|
||||
self.win = send_tab.window
|
||||
|
||||
@@ -30,44 +30,49 @@ class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
|
||||
*,
|
||||
config: SimpleConfig,
|
||||
setText: Callable[[str], None] = None,
|
||||
is_payto = False,
|
||||
):
|
||||
ButtonsTextEdit.__init__(self, text)
|
||||
self.setReadOnly(False)
|
||||
|
||||
input_qr_from_camera = partial(
|
||||
self.on_qr_from_camera_input_btn = partial(
|
||||
self.input_qr_from_camera,
|
||||
config=config,
|
||||
allow_multi=allow_multi,
|
||||
show_error=self.show_error,
|
||||
setText=setText,
|
||||
)
|
||||
self.on_qr_from_camera_input_btn = input_qr_from_camera
|
||||
|
||||
input_qr_from_screenshot = partial(
|
||||
self.on_qr_from_screenshot_input_btn = partial(
|
||||
self.input_qr_from_screenshot,
|
||||
allow_multi=allow_multi,
|
||||
show_error=self.show_error,
|
||||
setText=setText,
|
||||
)
|
||||
self.on_qr_from_screenshot_input_btn = input_qr_from_screenshot
|
||||
|
||||
input_file = partial(self.input_file, config=config, show_error=self.show_error, setText=setText)
|
||||
self.on_input_file = partial(
|
||||
self.input_file,
|
||||
config=config,
|
||||
show_error=self.show_error,
|
||||
setText=setText,
|
||||
)
|
||||
# for send tab, buttons are available in the toolbar
|
||||
if not is_payto:
|
||||
self.add_input_buttons(config, allow_multi, setText)
|
||||
run_hook('scan_text_edit', self)
|
||||
|
||||
def add_input_buttons(self, config, allow_multi, setText):
|
||||
self.add_menu_button(
|
||||
options=[
|
||||
("picture_in_picture.png", _("Read QR code from screen"), input_qr_from_screenshot),
|
||||
("file.png", _("Read file"), input_file),
|
||||
("picture_in_picture.png", _("Read QR code from screen"), self.on_qr_from_screenshot_input_btn),
|
||||
("file.png", _("Read file"), self.on_input_file),
|
||||
],
|
||||
)
|
||||
self.add_qr_input_from_camera_button(config=config, show_error=self.show_error, allow_multi=allow_multi, setText=setText)
|
||||
|
||||
run_hook('scan_text_edit', self)
|
||||
|
||||
def contextMenuEvent(self, e):
|
||||
m = self.createStandardContextMenu()
|
||||
m.addSeparator()
|
||||
m.addAction(read_QIcon(get_iconname_camera()), _("Read QR code from camera"), self.on_qr_from_camera_input_btn)
|
||||
m.addAction(read_QIcon(get_iconname_camera()), _("Read QR code with camera"), self.on_qr_from_camera_input_btn)
|
||||
m.addAction(read_QIcon("picture_in_picture.png"), _("Read QR code from screen"), self.on_qr_from_screenshot_input_btn)
|
||||
m.addAction(read_QIcon("file.png"), _("Read file"), self.on_input_file)
|
||||
m.exec_(e.globalPos())
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl, LNURLErr
|
||||
|
||||
from .amountedit import AmountEdit, BTCAmountEdit, SizedFreezableLineEdit
|
||||
from .util import WaitingDialog, HelpLabel, MessageBoxMixin, EnterButton, char_width_in_lineedit
|
||||
from .util import get_iconname_camera, get_iconname_qrcode, read_QIcon
|
||||
from .confirm_tx_dialog import ConfirmTxDialog
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -150,7 +151,11 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
||||
from .invoice_list import InvoiceList
|
||||
self.invoice_list = InvoiceList(self)
|
||||
self.toolbar, menu = self.invoice_list.create_toolbar_with_menu('')
|
||||
menu.addAction(read_QIcon(get_iconname_camera()), _("Read QR code with camera"), self.payto_e.on_qr_from_camera_input_btn)
|
||||
menu.addAction(read_QIcon("picture_in_picture.png"), _("Read QR code from screen"), self.payto_e.on_qr_from_screenshot_input_btn)
|
||||
menu.addAction(read_QIcon("file.png"), _("Read invoice from file"), self.payto_e.on_input_file)
|
||||
menu.addToggle(_("&Pay to many"), self.paytomany)
|
||||
menu.addSeparator()
|
||||
menu.addAction(_("Import invoices"), self.window.import_invoices)
|
||||
menu.addAction(_("Export invoices"), self.window.export_invoices)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user