Skip to content

Commit c0fe676

Browse files
committed
add ScanInvalidQRTypeView
1 parent 7edcd33 commit c0fe676

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

src/seedsigner/views/scan_views.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import re
33

44
from gettext import gettext as _
5-
from seedsigner.gui.components import SeedSignerIconConstants
65
from seedsigner.helpers.l10n import mark_for_translation as _mft
76
from seedsigner.models.settings import SettingsConstants
87
from seedsigner.views.view import BackStackView, ErrorView, MainMenuView, NotYetImplementedView, View, Destination
8+
from seedsigner.gui.screens.screen import ButtonOption
99

1010
logger = logging.getLogger(__name__)
1111

@@ -164,18 +164,7 @@ def run(self):
164164
# For now, don't even try to re-do the attempted operation, just reset and
165165
# start everything over.
166166
self.controller.resume_main_flow = None
167-
168-
# TODO: Refactor this warning screen into its own Screen class; the
169-
# screenshot generator is currently manually re-creating it, but it would be
170-
# better if a dedicated Screen could just be instantiated instead.
171-
return Destination(ErrorView, view_args=dict(
172-
title=_("Error"),
173-
status_icon_name=SeedSignerIconConstants.WARNING,
174-
status_headline=_("Unknown QR Type"),
175-
text=_("QRCode is invalid or is a data format not yet supported."),
176-
button_text=_("Done"),
177-
next_destination=Destination(MainMenuView, clear_history=True),
178-
))
167+
return Destination(ScanInvalidQRTypeView)
179168

180169
return Destination(MainMenuView)
181170

@@ -218,3 +207,23 @@ class ScanAddressView(ScanView):
218207
@property
219208
def is_valid_qr_type(self):
220209
return self.decoder.is_address
210+
211+
212+
213+
class ScanInvalidQRTypeView(View):
214+
def run(self):
215+
from seedsigner.gui.screens import WarningScreen
216+
217+
# TODO: This screen says "Error" but is intentionally using the WarningScreen in
218+
# order to avoid the perception that something is broken on our end. This should
219+
# either change to use the red ErrorScreen or the "Error" title should be
220+
# changed to something softer.
221+
self.run_screen(
222+
WarningScreen,
223+
title=_("Error"),
224+
status_headline=_("Unknown QR Type"),
225+
text=_("QRCode is invalid or is a data format not yet supported."),
226+
button_data=[ButtonOption("Done")],
227+
)
228+
229+
return Destination(MainMenuView, clear_history=True)

tests/screenshot_generator/generator.py

+4-15
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
patch('PIL.ImageFont.core.HAVE_RAQM', False).start()
2525

2626
from seedsigner.controller import Controller
27-
from seedsigner.gui.components import SeedSignerIconConstants
2827
from seedsigner.gui.renderer import Renderer
2928
from seedsigner.gui.screens.seed_screens import SeedAddPassphraseScreen
30-
from seedsigner.gui.toast import BaseToastOverlayManagerThread, RemoveSDCardToastManagerThread, SDCardStateChangeToastManagerThread
29+
from seedsigner.gui.toast import RemoveSDCardToastManagerThread, SDCardStateChangeToastManagerThread
3130
from seedsigner.hardware.microsd import MicroSD
3231
from seedsigner.helpers import embit_utils
3332
from seedsigner.models.decode_qr import DecodeQR
@@ -37,9 +36,9 @@
3736
from seedsigner.models.settings import Settings
3837
from seedsigner.models.settings_definition import SettingsConstants, SettingsDefinition
3938
from seedsigner.views import (MainMenuView, PowerOptionsView, RestartView, NotYetImplementedView, UnhandledExceptionView,
40-
psbt_views, seed_views, settings_views, tools_views)
39+
psbt_views, seed_views, settings_views, tools_views, scan_views)
4140
from seedsigner.views.screensaver import OpeningSplashView
42-
from seedsigner.views.view import ErrorView, NetworkMismatchErrorView, OptionDisabledView, PowerOffView, View
41+
from seedsigner.views.view import NetworkMismatchErrorView, OptionDisabledView, PowerOffView
4342

4443
from .utils import ScreenshotComplete, ScreenshotConfig, ScreenshotRenderer
4544

@@ -360,17 +359,7 @@ def PSBTOpReturnView_raw_hex_data_cb_before():
360359
ScreenshotConfig(UnhandledExceptionView, dict(error=["IndexError", "line 1, in some_buggy_code.py", "list index out of range"])),
361360
ScreenshotConfig(NetworkMismatchErrorView, dict(derivation_path="m/84'/1'/0'")),
362361
ScreenshotConfig(OptionDisabledView, dict(settings_attr=SettingsConstants.SETTING__MESSAGE_SIGNING)),
363-
ScreenshotConfig(
364-
ErrorView,
365-
dict(
366-
title="Error",
367-
status_icon_name=SeedSignerIconConstants.WARNING,
368-
status_headline="Unknown QR Type",
369-
text="QRCode is invalid or is a data format not yet supported.",
370-
button_text="Back",
371-
),
372-
screenshot_name="ScanView__UnknownQRType"
373-
),
362+
ScreenshotConfig(scan_views.ScanInvalidQRTypeView)
374363
]
375364
}
376365

tests/test_flows_seed.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def load_invalid_signmessage_qr(view: scan_views.ScanView):
646646
FlowStep(seed_views.SeedFinalizeView, button_data_selection=seed_views.SeedFinalizeView.FINALIZE),
647647
FlowStep(seed_views.SeedOptionsView, button_data_selection=seed_views.SeedOptionsView.SIGN_MESSAGE),
648648
FlowStep(scan_views.ScanView, before_run=load_invalid_signmessage_qr), # simulate read message QR; ret val is ignored
649-
FlowStep(ErrorView),
649+
FlowStep(scan_views.ScanInvalidQRTypeView),
650650
FlowStep(MainMenuView),
651651
])
652652

0 commit comments

Comments
 (0)