Merge lp:~zsombi/ubuntu-ui-toolkit/dialogCloseOnEsc into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri on 2015-12-14
Status: Merged
Approved by: Christian Dywan on 2015-12-14
Approved revision: 1759
Merged at revision: 1761
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/dialogCloseOnEsc
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 78 lines (+57/-0)
2 files modified
src/Ubuntu/Components/Popups/1.3/Dialog.qml (+4/-0)
tests/unit_x11/tst_components/tst_popups_dialog13.qml (+53/-0)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/dialogCloseOnEsc
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-12-14
Christian Dywan (community) 2015-12-14 Approve on 2015-12-14
Review via email: mp+280423@code.launchpad.net

Commit message

Close Popups.Dialog when Esc key is pressed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/Popups/1.3/Dialog.qml'
2--- src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-12-08 09:06:13 +0000
3+++ src/Ubuntu/Components/Popups/1.3/Dialog.qml 2015-12-14 08:28:31 +0000
4@@ -164,6 +164,8 @@
5
6 height: Math.min(contentsColumn.height + foreground.margins, dialog.height - keyboardHeight)
7
8+ Keys.onEscapePressed: dialog.hide()
9+
10 Flickable {
11 anchors.fill: parent
12 anchors.margins: foreground.margins
13@@ -208,5 +210,7 @@
14 }
15
16 styleName: "DialogForegroundStyle"
17+
18+ Component.onCompleted: foreground.forceActiveFocus()
19 }
20 }
21
22=== added file 'tests/unit_x11/tst_components/tst_popups_dialog13.qml'
23--- tests/unit_x11/tst_components/tst_popups_dialog13.qml 1970-01-01 00:00:00 +0000
24+++ tests/unit_x11/tst_components/tst_popups_dialog13.qml 2015-12-14 08:28:31 +0000
25@@ -0,0 +1,53 @@
26+/*
27+ * Copyright 2015 Canonical Ltd.
28+ *
29+ * This program is free software; you can redistribute it and/or modify
30+ * it under the terms of the GNU Lesser General Public License as published by
31+ * the Free Software Foundation; version 3.
32+ *
33+ * This program is distributed in the hope that it will be useful,
34+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
35+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36+ * GNU Lesser General Public License for more details.
37+ *
38+ * You should have received a copy of the GNU Lesser General Public License
39+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
40+ */
41+
42+import QtQuick 2.4
43+import QtTest 1.0
44+import Ubuntu.Test 1.0
45+import Ubuntu.Components 1.3
46+import Ubuntu.Components.Popups 1.3
47+
48+MainView {
49+ id: main
50+
51+ width: units.gu(40)
52+ height: units.gu(71)
53+
54+ UbuntuTestCase {
55+ id: test
56+ name: "Popups.Dialog"
57+ when: windowShown
58+
59+ property bool dialogDestroyed: false
60+
61+ function test_dismiss_dialog_on_esc_bug1523833() {
62+ var dlg = PopupUtils.open(dialog);
63+ waitForRendering(dlg);
64+ dlg.Component.destruction.connect(function() { test.dialogDestroyed = true });
65+ keyClick(Qt.Key_Escape);
66+ tryCompare(test, "dialogDestroyed", true, 500, "Dialog not destroyed");
67+ }
68+ }
69+
70+ Component {
71+ id: dialog
72+ Dialog {
73+ title: "Ahoj"
74+ }
75+ }
76+}
77+
78+

Subscribers

People subscribed via source and target branches