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
diff --git a/qabro/__init__.py b/qabro/__init__.py
index dee80a3..ce717ad 100644
--- a/qabro/__init__.py
+++ b/qabro/__init__.py
@@ -67,9 +67,8 @@ def start_ui(assignee='', project='', tags=''):
67 try:67 try:
68 result = ba.file_bug()68 result = ba.file_bug()
69 except Exception as exc:69 except Exception as exc:
70 ui.message.set_text([('error', "Error: "), str(exc)])
71 logging.error(exc)70 logging.error(exc)
72 ui.run()71 ui.show_error_dialog(message=str(exc))
73 ba.update(ui.report())72 ba.update(ui.report())
74 else:73 else:
75 print(result)74 print(result)
diff --git a/qabro/ui.py b/qabro/ui.py
index 059d39e..1a78c20 100644
--- a/qabro/ui.py
+++ b/qabro/ui.py
@@ -80,12 +80,10 @@ class ReportScreen:
80 importance_list = urwid.LineBox(urwid.Pile(self._importance), 'Importance')80 importance_list = urwid.LineBox(urwid.Pile(self._importance), 'Importance')
81 self.bug_features_list = urwid.LineBox(urwid.Pile(self._bug_features), 'Impacted Feature(s)')81 self.bug_features_list = urwid.LineBox(urwid.Pile(self._bug_features), 'Impacted Feature(s)')
82 self.bug_vendors_list = urwid.LineBox(urwid.Pile(self._bug_vendors), 'Impacted Vendor(s)')82 self.bug_vendors_list = urwid.LineBox(urwid.Pile(self._bug_vendors), 'Impacted Vendor(s)')
83 self.message = urwid.Text('')
84 self.footer = urwid.AttrMap(urwid.Text(self.footer_text), 'foot')83 self.footer = urwid.AttrMap(urwid.Text(self.footer_text), 'foot')
85 self.bug_tags_lists = urwid.Columns([self.bug_features_list,84 self.bug_tags_lists = urwid.Columns([self.bug_features_list,
86 self.bug_vendors_list])85 self.bug_vendors_list])
87 self.pile = urwid.Pile([self.message,86 self.pile = urwid.Pile([self._title,
88 self._title,
89 self._description,87 self._description,
90 self._project,88 self._project,
91 self._series,89 self._series,
@@ -94,7 +92,13 @@ class ReportScreen:
94 self._assignee,92 self._assignee,
95 self._tags,93 self._tags,
96 self.bug_tags_lists])94 self.bug_tags_lists])
97 self.view = urwid.Frame(urwid.Filler(self.pile, 'top'), footer=self.footer)95 self.main_view = urwid.Frame(urwid.Filler(self.pile, 'top'), footer=self.footer)
96 self.error_text = urwid.Text("")
97 self.ok_button = urwid.Padding(urwid.Button("OK", on_press=self.close_dialog), align="center", width=6)
98 self.error_dialog = urwid.AttrMap(urwid.LineBox(urwid.Pile([self.error_text, self.ok_button]), "Error"),
99 "error")
100 self.error_view = urwid.Overlay(self.error_dialog, self.main_view, align="center", width=("relative", 50),
101 valign="middle", height="pack")
98102
99 def set_tag(self, cb, cb_state, user_data):103 def set_tag(self, cb, cb_state, user_data):
100 tags = user_data[cb.label]104 tags = user_data[cb.label]
@@ -113,16 +117,24 @@ class ReportScreen:
113 dedup_tags = OrderedDict.fromkeys(current_tags)117 dedup_tags = OrderedDict.fromkeys(current_tags)
114 self._tags.base_widget.edit_text = " ".join(dedup_tags)118 self._tags.base_widget.edit_text = " ".join(dedup_tags)
115119
120 def show_error_dialog(self, message):
121 self.error_text.set_text(message)
122 self.loop.widget = self.error_view
123 self.loop.run()
124
125 def close_dialog(self, button=None):
126 self.loop.widget = self.main_view
127
116 def run(self):128 def run(self):
117 """Run the urwid MainLoop."""129 """Run the urwid MainLoop."""
118 self.loop = urwid.MainLoop(self.view,130 self.loop = urwid.MainLoop(self.main_view,
119 self.palette,131 self.palette,
120 handle_mouse=False,132 handle_mouse=False,
121 unhandled_input=self.unhandled_input)133 unhandled_input=self.unhandled_input)
122 self.loop.run()134 self.loop.run()
123135
124 def unhandled_input(self, key):136 def unhandled_input(self, key):
125 if self.loop.widget == self.view:137 if self.loop.widget == self.main_view:
126 if key == 'esc':138 if key == 'esc':
127 sys.exit(0)139 sys.exit(0)
128 if key == 'meta enter':140 if key == 'meta enter':
@@ -131,6 +143,10 @@ class ReportScreen:
131 self.loop.process_input(['down' for _ in range(5)])143 self.loop.process_input(['down' for _ in range(5)])
132 if key == 'page up':144 if key == 'page up':
133 self.loop.process_input(['up' for _ in range(5)])145 self.loop.process_input(['up' for _ in range(5)])
146 else: # We are showing the error dialog
147 if key == 'esc':
148 self.close_dialog()
149 return True
134150
135 def report(self):151 def report(self):
136 tags = self._tags.base_widget.text152 tags = self._tags.base_widget.text

Subscribers

People subscribed via source and target branches

to all changes: