From 4ab469d02d2933d6ead6c900dbb1b097b7e01a79 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Wed, 18 Jan 2017 17:59:11 +0100 Subject: [PATCH] apps.wallet: add qr code to get_address TODO: the widget system clearly needs some work --- src/apps/wallet/get_address.py | 10 ++++++---- src/trezor/ui/container.py | 15 +++++++++++++++ src/trezor/ui/qr.py | 15 +++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/trezor/ui/container.py create mode 100644 src/trezor/ui/qr.py diff --git a/src/apps/wallet/get_address.py b/src/apps/wallet/get_address.py index 51ea72cc0b..77b4e92eac 100644 --- a/src/apps/wallet/get_address.py +++ b/src/apps/wallet/get_address.py @@ -29,12 +29,14 @@ async def layout_get_address(session_id, msg): async def _show_address(session_id, address): from trezor.messages.ButtonRequestType import Address from trezor.ui.text import Text + from trezor.ui.qr import Qr + from trezor.ui.container import Container from ..common.confirm import require_confirm - # TODO: qr code - - content = Text('Confirm address', ui.ICON_RESET, - ui.MONO, *_split_address(address)) + lines = _split_address(address) + content = Container( + Qr(address, (76, 90), 3), + Text('Confirm address', ui.ICON_RESET, ui.MONO, *lines)) await require_confirm(session_id, content, code=Address) diff --git a/src/trezor/ui/container.py b/src/trezor/ui/container.py new file mode 100644 index 0000000000..422c992e15 --- /dev/null +++ b/src/trezor/ui/container.py @@ -0,0 +1,15 @@ + +class Container: + + def __init__(self, *children): + self.children = children + + def render(self): + for child in self.children: + child.render() + + def send(self, event, pos): + for child in self.children: + result = child.send(event, pos) + if result is not None: + return result diff --git a/src/trezor/ui/qr.py b/src/trezor/ui/qr.py new file mode 100644 index 0000000000..09acb8700c --- /dev/null +++ b/src/trezor/ui/qr.py @@ -0,0 +1,15 @@ +from trezor import ui + + +class Qr: + + def __init__(self, data, pos, scale): + self.data = data + self.pos = pos + self.scale = scale + + def render(self): + ui.display.qrcode(self.pos[0], self.pos[1], self.data, self.scale) + + def send(self, event, pos): + pass