Merge ~pieq/bugit/+git/qabro:modal-error-window into bugit:master

Proposed by Pierre Equoy
Status: Merged
Approved by: Pierre Equoy
Approved revision: cdd37eaf5051d3f75d9f69fb40f155e0315de010
Merged at revision: 5965e5f78bf5d2593c98910c2b3f21209bf3e254
Proposed branch: ~pieq/bugit/+git/qabro:modal-error-window
Merge into: bugit:master
Diff against target: 86 lines (+23/-8)
2 files modified
qabro/__init__.py (+1/-2)
qabro/ui.py (+22/-6)
Reviewer Review Type Date Requested Status
Maciej Kisielewski (community) Approve
Nara Huang (community) Approve
Review via email: mp+386549@code.launchpad.net

Description of the change

See commit message for more info.

To test (on Ubuntu classic):

1. Run `snapcraft` from this branch to build a `qabro_0.13dev_amd64.snap` file
2. Install the snap:
    sudo snap install qabro_0.13dev_amd64.snap --devmode
3. Run `qabro`
4. Try to generate an error (for instance, leave the "Title" field blank and press `Alt+Enter` to try to submit the report)

→ You should see a modal error dialog popping up in red, with a 'OK' button to dismiss it (you can also press Esc key).

To post a comment you must log in.
Revision history for this message
Nara Huang (narahuang) wrote :

Tested, the new error window is great, LGTM.

review: Approve
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

The code looks good too. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/qabro/__init__.py b/qabro/__init__.py
2index dee80a3..ce717ad 100644
3--- a/qabro/__init__.py
4+++ b/qabro/__init__.py
5@@ -67,9 +67,8 @@ def start_ui(assignee='', project='', tags=''):
6 try:
7 result = ba.file_bug()
8 except Exception as exc:
9- ui.message.set_text([('error', "Error: "), str(exc)])
10 logging.error(exc)
11- ui.run()
12+ ui.show_error_dialog(message=str(exc))
13 ba.update(ui.report())
14 else:
15 print(result)
16diff --git a/qabro/ui.py b/qabro/ui.py
17index 059d39e..1a78c20 100644
18--- a/qabro/ui.py
19+++ b/qabro/ui.py
20@@ -80,12 +80,10 @@ class ReportScreen:
21 importance_list = urwid.LineBox(urwid.Pile(self._importance), 'Importance')
22 self.bug_features_list = urwid.LineBox(urwid.Pile(self._bug_features), 'Impacted Feature(s)')
23 self.bug_vendors_list = urwid.LineBox(urwid.Pile(self._bug_vendors), 'Impacted Vendor(s)')
24- self.message = urwid.Text('')
25 self.footer = urwid.AttrMap(urwid.Text(self.footer_text), 'foot')
26 self.bug_tags_lists = urwid.Columns([self.bug_features_list,
27 self.bug_vendors_list])
28- self.pile = urwid.Pile([self.message,
29- self._title,
30+ self.pile = urwid.Pile([self._title,
31 self._description,
32 self._project,
33 self._series,
34@@ -94,7 +92,13 @@ class ReportScreen:
35 self._assignee,
36 self._tags,
37 self.bug_tags_lists])
38- self.view = urwid.Frame(urwid.Filler(self.pile, 'top'), footer=self.footer)
39+ self.main_view = urwid.Frame(urwid.Filler(self.pile, 'top'), footer=self.footer)
40+ self.error_text = urwid.Text("")
41+ self.ok_button = urwid.Padding(urwid.Button("OK", on_press=self.close_dialog), align="center", width=6)
42+ self.error_dialog = urwid.AttrMap(urwid.LineBox(urwid.Pile([self.error_text, self.ok_button]), "Error"),
43+ "error")
44+ self.error_view = urwid.Overlay(self.error_dialog, self.main_view, align="center", width=("relative", 50),
45+ valign="middle", height="pack")
46
47 def set_tag(self, cb, cb_state, user_data):
48 tags = user_data[cb.label]
49@@ -113,16 +117,24 @@ class ReportScreen:
50 dedup_tags = OrderedDict.fromkeys(current_tags)
51 self._tags.base_widget.edit_text = " ".join(dedup_tags)
52
53+ def show_error_dialog(self, message):
54+ self.error_text.set_text(message)
55+ self.loop.widget = self.error_view
56+ self.loop.run()
57+
58+ def close_dialog(self, button=None):
59+ self.loop.widget = self.main_view
60+
61 def run(self):
62 """Run the urwid MainLoop."""
63- self.loop = urwid.MainLoop(self.view,
64+ self.loop = urwid.MainLoop(self.main_view,
65 self.palette,
66 handle_mouse=False,
67 unhandled_input=self.unhandled_input)
68 self.loop.run()
69
70 def unhandled_input(self, key):
71- if self.loop.widget == self.view:
72+ if self.loop.widget == self.main_view:
73 if key == 'esc':
74 sys.exit(0)
75 if key == 'meta enter':
76@@ -131,6 +143,10 @@ class ReportScreen:
77 self.loop.process_input(['down' for _ in range(5)])
78 if key == 'page up':
79 self.loop.process_input(['up' for _ in range(5)])
80+ else: # We are showing the error dialog
81+ if key == 'esc':
82+ self.close_dialog()
83+ return True
84
85 def report(self):
86 tags = self._tags.base_widget.text

Subscribers

People subscribed via source and target branches

to all changes: