Merge lp:~kissiel/checkbox/error-reporting into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 3395
Merged at revision: 3408
Proposed branch: lp:~kissiel/checkbox/error-reporting
Merge into: lp:checkbox
Diff against target: 145 lines (+110/-1)
3 files modified
checkbox-touch/components/ErrorDialog.qml (+82/-0)
checkbox-touch/components/ErrorLogic.js (+19/-0)
checkbox-touch/main.qml (+9/-1)
To merge this branch: bzr merge lp:~kissiel/checkbox/error-reporting
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+241370@code.launchpad.net

Description of the change

This MR introduces error popup in checkbox touch.
It also includes changes to main.qml to use those popups.

d5e1a41 checkbox-touch: make use of error popup in main.qml
5b7e4e3 checkbox-touch: add error dialog

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Just a suggestion to replace the Dialog label by a Flickable, see below.

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

> Just a suggestion to replace the Dialog label by a Flickable, see below.

As flickable is difficult to get working in dialogs I think it's good to land this one and file an improvement bug.

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

It's so useful for debugging. Let's land this version and iterate. thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'checkbox-touch/components/ErrorDialog.qml'
2--- checkbox-touch/components/ErrorDialog.qml 1970-01-01 00:00:00 +0000
3+++ checkbox-touch/components/ErrorDialog.qml 2014-11-11 05:56:24 +0000
4@@ -0,0 +1,82 @@
5+/*
6+ * This file is part of Checkbox
7+ *
8+ * Copyright 2014 Canonical Ltd.
9+ *
10+ * Authors:
11+ * - Maciej Kisielewski <maciej.kisielewski@canonical.com>
12+ *
13+ * This program is free software; you can redistribute it and/or modify
14+ * it under the terms of the GNU General Public License as published by
15+ * the Free Software Foundation; version 3.
16+ *
17+ * This program is distributed in the hope that it will be useful,
18+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+ * GNU General Public License for more details.
21+ *
22+ * You should have received a copy of the GNU General Public License
23+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
24+ */
25+import QtQuick 2.0
26+import Ubuntu.Components 1.1
27+import Ubuntu.Components.Popups 0.1
28+
29+/*! \brief Error message popup.
30+ \inherits Item
31+
32+ This component is an error reporting dialog.
33+ To use this component call showError() from ErrorLogic.js
34+ Typical usage is:
35+ import "components/ErrorLogic.js" as ErrorLogic
36+ (...)
37+ ErrorLogic.showError(mainView, "There was something wrong", Qt.quit)
38+*/
39+
40+Item {
41+ id: errorDialog
42+ /*!
43+ Gets signalled when user taps on the button
44+ */
45+ signal done()
46+
47+ property string buttonLabel: i18n.tr("Um, OK")
48+
49+ /*!
50+ `dialog` alias helps use the component containing dialog
51+ */
52+ property alias dialog: dialogComponent
53+
54+ /*!
55+ Text to display in the error dialog
56+ */
57+ property string errorMessage: i18n.tr("Error encountered")
58+
59+
60+ Component {
61+ id: dialogComponent
62+
63+ Dialog {
64+ id: dlg
65+ width: errorDialog.width
66+ height: errorDialog.height
67+ title: i18n.tr("Error encountered")
68+
69+ Label {
70+ text: errorMessage
71+ width: parent.width
72+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
73+ }
74+
75+ Button {
76+ id: button
77+ text: errorDialog.buttonLabel
78+ color: UbuntuColors.red
79+ onClicked: {
80+ done();
81+ PopupUtils.close(dlg);
82+ }
83+ }
84+ }
85+ }
86+}
87
88=== added file 'checkbox-touch/components/ErrorLogic.js'
89--- checkbox-touch/components/ErrorLogic.js 1970-01-01 00:00:00 +0000
90+++ checkbox-touch/components/ErrorLogic.js 2014-11-11 05:56:24 +0000
91@@ -0,0 +1,19 @@
92+.import Ubuntu.Components.Popups 1.0 as Popups
93+
94+function showError(caller, errorMessage, continuation) {
95+ // stackDepth keeps track of how many popups are stacked on the screen
96+ // we need this so continuation is called only if the last (the bottom one) popup
97+ // is closed
98+ showError.stackDepth = ++showError.stackDepth || 1;
99+ var popup = Qt.createComponent(Qt.resolvedUrl("ErrorDialog.qml")).createObject(caller);
100+ popup.errorMessage = errorMessage;
101+ if (showError.stackDepth > 1) {
102+ popup.buttonLabel = i18n.tr("Continue")
103+ } else {
104+ popup.buttonLabel = i18n.tr("Quit")
105+ popup.done.connect(function() {
106+ continuation();
107+ });
108+ }
109+ Popups.PopupUtils.open(popup.dialog);
110+}
111
112=== modified file 'checkbox-touch/main.qml'
113--- checkbox-touch/main.qml 2014-11-05 10:56:36 +0000
114+++ checkbox-touch/main.qml 2014-11-11 05:56:24 +0000
115@@ -23,6 +23,7 @@
116 import Ubuntu.Components 1.1
117 import io.thp.pyotherside 1.2
118 import "components"
119+import "components/ErrorLogic.js" as ErrorLogic
120
121
122 /*!
123@@ -68,7 +69,10 @@
124 });
125 });
126 }
127- onError: console.error("python error: " + traceback)
128+ onError: {
129+ console.error("python error: " + traceback);
130+ ErrorLogic.showError(mainView, "python error: " + traceback, Qt.quit);
131+ }
132 onReceived: console.log("pyotherside.send: " + data)
133 }
134
135@@ -124,6 +128,10 @@
136 title: i18n.tr("Testplan Selection")
137 onlyOneAllowed: true
138 function setup(testplan_info_list) {
139+ if (testplan_info_list.length<1) {
140+ ErrorLogic.showError(mainView, "Test plan missing", Qt.quit);
141+ }
142+
143 model.clear();
144 for (var i=0; i<testplan_info_list.length; i++) {
145 var testplan_info = testplan_info_list[i];

Subscribers

People subscribed via source and target branches