1
0
Files
electrum/electrum/gui/qt/qrtextedit.py
SomberNight df974c2384 qt paytoedit: evaluate text on textChanged(), but no network requests
- add param to _check_text to toggle if network requests are allowed ("full check")
- every 0.5 sec, if the textedit has no focus, do full check
- on textChanged()
  - detect if user copy-pasted by comparing current text against clipboard contents,
    if so, do full check
  - otherwise, do partial check
- on clicking ButtonsWidget btns (scan qr, paste, read file), do full check
2022-06-29 16:18:30 +02:00

63 lines
2.3 KiB
Python

from typing import Callable
from electrum.i18n import _
from electrum.plugin import run_hook
from electrum.simple_config import SimpleConfig
from .util import ButtonsTextEdit, MessageBoxMixin
class ShowQRTextEdit(ButtonsTextEdit):
def __init__(self, text=None, *, config: SimpleConfig):
ButtonsTextEdit.__init__(self, text)
self.setReadOnly(True)
self.add_qr_show_button(config=config)
run_hook('show_text_edit', self)
def contextMenuEvent(self, e):
m = self.createStandardContextMenu()
m.addAction(_("Show as QR code"), self.on_qr_show_btn)
m.exec_(e.globalPos())
class ScanQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
def __init__(
self, text="", allow_multi: bool = False,
*,
config: SimpleConfig,
setText: Callable[[str], None] = None,
):
ButtonsTextEdit.__init__(self, text)
self.setReadOnly(False)
self.add_file_input_button(config=config, show_error=self.show_error, setText=setText)
self.add_qr_input_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 QR code from camera"), self.on_qr_from_camera_input_btn)
m.addAction(_("Read QR code from screen"), self.on_qr_from_screenshot_input_btn)
m.exec_(e.globalPos())
class ScanShowQRTextEdit(ButtonsTextEdit, MessageBoxMixin):
def __init__(self, text="", allow_multi: bool = False, *, config: SimpleConfig):
ButtonsTextEdit.__init__(self, text)
self.setReadOnly(False)
self.add_qr_input_button(config=config, show_error=self.show_error, allow_multi=allow_multi)
self.add_qr_show_button(config=config)
run_hook('scan_text_edit', self)
run_hook('show_text_edit', self)
def contextMenuEvent(self, e):
m = self.createStandardContextMenu()
m.addSeparator()
m.addAction(_("Read QR code from camera"), self.on_qr_from_camera_input_btn)
m.addAction(_("Read QR code from screen"), self.on_qr_from_screenshot_input_btn)
m.addAction(_("Show as QR code"), self.on_qr_show_btn)
m.exec_(e.globalPos())