Merge lp:~ken-vandine/ubuntu-ui-toolkit/raring.0.1.43 into lp:ubuntu-ui-toolkit/raring

Proposed by Ken VanDine
Status: Merged
Merged at revision: 418
Proposed branch: lp:~ken-vandine/ubuntu-ui-toolkit/raring.0.1.43
Merge into: lp:ubuntu-ui-toolkit/raring
Diff against target: 552 lines (+312/-55)
9 files modified
debian/changelog (+14/-0)
demos/ListItems.qml (+9/-0)
modules/Ubuntu/Components/TextArea.qml (+17/-10)
modules/Ubuntu/Components/TextField.qml (+0/-10)
modules/Ubuntu/Components/plugin/quickutils.cpp (+28/-0)
modules/Ubuntu/Components/plugin/quickutils.h (+5/-0)
tests/unit/tst_components/tst_textarea.qml (+125/-3)
tests/unit/tst_components/tst_textfield.qml (+90/-13)
themes/Ambiance/qmltheme/TextAreaDelegate.qml (+24/-19)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-ui-toolkit/raring.0.1.43
Reviewer Review Type Date Requested Status
Timo Jyrinki Approve
Review via email: mp+159638@code.launchpad.net

Commit message

  * Fix for text inputs staying disabled after being re-enabled. The previous
    workaround for removing input panel was blocking re-enabling a
    previously enabled input. (LP: #1164634)
  * Fixing disabled text input delegate background color theming when userValue
    is set to TextField or TextArea color property. (LP: #1169601)
  * Workaround for TextArea and TextField removing OSK when active focus is
    transferred from one instance to another using focus property (LP: #1163371)
  * Fix for TextArea Enter/Return keys being stolen when embedded in
    ListItems.Empty. (LP: #1166840)

Description of the change

cherrypicked important bug fixes from trunk that are safe to upload to raring and prepared an update for raring.

To post a comment you must log in.
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-04-12 12:04:33 +0000
3+++ debian/changelog 2013-04-18 14:13:29 +0000
4@@ -1,3 +1,17 @@
5+ubuntu-ui-toolkit (0.1.43) UNRELEASED; urgency=low
6+
7+ * Fix for text inputs staying disabled after being re-enabled. The previous
8+ workaround for removing input panel was blocking re-enabling a
9+ previously enabled input. (LP: #1164634)
10+ * Fixing disabled text input delegate background color theming when userValue
11+ is set to TextField or TextArea color property. (LP: #1169601)
12+ * Workaround for TextArea and TextField removing OSK when active focus is
13+ transferred from one instance to another using focus property (LP: #1163371)
14+ * Fix for TextArea Enter/Return keys being stolen when embedded in
15+ ListItems.Empty. (LP: #1166840)
16+
17+ -- Ken VanDine <ken.vandine@canonical.com> Thu, 18 Apr 2013 10:01:45 -0400
18+
19 ubuntu-ui-toolkit (0.1.42) raring; urgency=low
20
21 [ Loïc Minier ]
22
23=== modified file 'demos/ListItems.qml'
24--- demos/ListItems.qml 2013-03-25 20:01:52 +0000
25+++ demos/ListItems.qml 2013-04-18 14:13:29 +0000
26@@ -356,6 +356,15 @@
27 }
28 }
29 }
30+ ListItem.Empty {
31+ TextArea {
32+ text: i18n.tr("text")
33+ anchors {
34+ margins: units.gu(1)
35+ fill: parent
36+ }
37+ }
38+ }
39 }
40 }
41 FadingRectangle {
42
43=== modified file 'modules/Ubuntu/Components/TextArea.qml'
44--- modules/Ubuntu/Components/TextArea.qml 2013-03-13 15:11:28 +0000
45+++ modules/Ubuntu/Components/TextArea.qml 2013-04-18 14:13:29 +0000
46@@ -795,6 +795,23 @@
47 }
48 }
49
50+ // grab Enter/Return keys which may be stolen from parent components of TextArea
51+ // due to forwarded keys from TextEdit
52+ Keys.onPressed: {
53+ if ((event.key === Qt.Key_Enter) || (event.key === Qt.Key_Return)) {
54+ if (editor.textFormat === TextEdit.RichText) {
55+ // FIXME: use control.paste("<br />") instead when paste() gets sich text support
56+ editor.insert(editor.cursorPosition, "<br />");
57+ } else {
58+ control.paste("\n");
59+ }
60+ event.accepted = true;
61+ } else {
62+ event.accepted = false;
63+ }
64+ }
65+ Keys.onReleased: event.accepted = (event.key === Qt.Key_Enter) || (event.key === Qt.Key_Return)
66+
67 // cursor is FIXME: move in a separate element and align with TextField
68 Component {
69 id: cursor
70@@ -902,16 +919,6 @@
71 // autosize handling
72 onLineCountChanged: internal.frameSize()
73
74- // virtual keyboard handling
75- activeFocusOnPress: false
76- onActiveFocusChanged: {
77- if (activeFocus) {
78- internal.showInputPanel();
79- } else {
80- internal.hideInputPanel();
81- }
82- }
83-
84 // remove selection when typing starts or input method start entering text
85 onInputMethodComposingChanged: {
86 if (inputMethodComposing)
87
88=== modified file 'modules/Ubuntu/Components/TextField.qml'
89--- modules/Ubuntu/Components/TextField.qml 2013-03-27 08:15:42 +0000
90+++ modules/Ubuntu/Components/TextField.qml 2013-04-18 14:13:29 +0000
91@@ -617,16 +617,6 @@
92 // forward keys to the root element so it can be captured outside of it
93 Keys.forwardTo: [control]
94
95- // virtual keyboard/software input panel handling
96- activeFocusOnPress: false
97- onActiveFocusChanged: {
98- if (activeFocus) {
99- internal.showInputPanel();
100- } else {
101- internal.hideInputPanel();
102- }
103- }
104-
105 // handle virtual keyboard and cursor positioning, as the MouseArea overrides
106 // those functionalities of the TextInput
107 MouseArea {
108
109=== modified file 'modules/Ubuntu/Components/plugin/quickutils.cpp'
110--- modules/Ubuntu/Components/plugin/quickutils.cpp 2013-03-07 12:40:45 +0000
111+++ modules/Ubuntu/Components/plugin/quickutils.cpp 2013-04-18 14:13:29 +0000
112@@ -25,10 +25,15 @@
113 #include <QtCore/QAbstractProxyModel>
114 #include <QtQml/QQmlPropertyMap>
115
116+#include <private/qquicktextinput_p.h>
117+#include <private/qquicktextedit_p.h>
118+
119 QuickUtils::QuickUtils(QObject *parent) :
120 QObject(parent)
121 {
122 QGuiApplication::instance()->installEventFilter(this);
123+ // connect to focusObjectChanged() to get the latest active focus object
124+ QObject::connect(QGuiApplication::instance(), SIGNAL(focusObjectChanged(QObject*)), this, SLOT(activeFocus(QObject*)));
125 }
126
127 /*!
128@@ -45,6 +50,23 @@
129 return QObject::eventFilter(obj, event);
130 }
131
132+/*!
133+ * \internal
134+ * Catch active focus object change to detecte whether we need to remove OSK or not.
135+ */
136+void QuickUtils::activeFocus(QObject *active)
137+{
138+ // FIXME: workaround for bug https://bugreports.qt-project.org/browse/QTBUG-30729
139+ // input panel does not get removed when no input is active
140+ // remove input panel if there's no more active object or the new active object
141+ // is not a text input
142+ // workaround for bug https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1163371
143+ if (QGuiApplication::inputMethod()->isVisible() && (!active || (active &&
144+ !qobject_cast<QQuickTextInput*>(active) &&
145+ !qobject_cast<QQuickTextEdit*>(active)))) {
146+ QGuiApplication::inputMethod()->hide();
147+ }
148+}
149
150 /*!
151 * \internal
152@@ -57,6 +79,12 @@
153 return (m_rootView) ? m_rootView->rootObject() : 0;
154 }
155
156+QString QuickUtils::inputMethodProvider() const
157+{
158+ return QString(getenv("QT_IM_MODULE"));
159+}
160+
161+
162 /*!
163 * \internal
164 * Creates an instance out of a delegate using the roles specified in the
165
166=== modified file 'modules/Ubuntu/Components/plugin/quickutils.h'
167--- modules/Ubuntu/Components/plugin/quickutils.h 2013-03-07 12:40:45 +0000
168+++ modules/Ubuntu/Components/plugin/quickutils.h 2013-04-18 14:13:29 +0000
169@@ -29,6 +29,7 @@
170 {
171 Q_OBJECT
172 Q_PROPERTY(QQuickItem *rootObject READ rootObject NOTIFY rootObjectChanged)
173+ Q_PROPERTY(QString inputMethodProvider READ inputMethodProvider)
174 public:
175 static QuickUtils& instance()
176 {
177@@ -37,6 +38,7 @@
178 }
179
180 QQuickItem *rootObject();
181+ QString inputMethodProvider() const;
182
183 Q_INVOKABLE qreal modelDelegateHeight(QQmlComponent *delegate, const QVariant &model);
184 Q_INVOKABLE QString className(QQuickItem *item);
185@@ -47,6 +49,9 @@
186 protected:
187 bool eventFilter(QObject *, QEvent *);
188
189+private Q_SLOTS:
190+ void activeFocus(QObject*);
191+
192 private:
193 explicit QuickUtils(QObject *parent = 0);
194 QQuickView *m_rootView;
195
196=== modified file 'tests/unit/tst_components/tst_textarea.qml'
197--- tests/unit/tst_components/tst_textarea.qml 2013-02-13 09:36:45 +0000
198+++ tests/unit/tst_components/tst_textarea.qml 2013-04-18 14:13:29 +0000
199@@ -17,10 +17,13 @@
200 import QtQuick 2.0
201 import QtTest 1.0
202 import Ubuntu.Components 0.1
203+import Ubuntu.Components.ListItems 0.1 as ListItem
204
205 Item {
206 width: 200; height: 200
207
208+ property bool hasOSK: QuickUtils.inputMethodProvider !== ""
209+
210 TextArea {
211 id: textArea
212 SignalSpy {
213@@ -34,10 +37,45 @@
214 Keys.onReleased: keyReleaseData = event.key
215 }
216
217+ TextArea {
218+ id: colorTest
219+ color: colorTest.text.length < 4 ? "#0000ff" : "#00ff00"
220+ }
221+
222 TextEdit {
223 id: textEdit
224 }
225
226+ ListItem.Empty {
227+ id: listItem
228+ height: 200
229+ anchors.left: parent.left
230+
231+ anchors.right: parent.right
232+ SignalSpy {
233+ id: listItemSpy
234+ signalName: "clicked"
235+ target: listItem
236+ }
237+
238+ TextArea {
239+ id: input
240+ anchors.fill: parent
241+ Component.onCompleted: forceActiveFocus()
242+ }
243+ }
244+
245+ Item {
246+ TextArea {
247+ id: t1
248+ objectName: "t1"
249+ }
250+ TextArea {
251+ id: t2
252+ objectName: "t2"
253+ }
254+ }
255+
256 TestCase {
257 name: "TextAreaAPI"
258 when: windowShown
259@@ -335,9 +373,93 @@
260 textArea.readOnly = false;
261 textArea.keyPressData = 0;
262 textArea.keyReleaseData = 0;
263- keyClick(Qt.Key_Control, Qt.NoModifier, 100);
264- compare(textArea.keyPressData, Qt.Key_Control, "Key press filtered");
265- compare(textArea.keyReleaseData, Qt.Key_Control, "Key release filtered");
266+ keyClick(Qt.Key_T, Qt.NoModifier, 100);
267+ compare(textArea.keyPressData, Qt.Key_T, "Key press filtered");
268+ compare(textArea.keyReleaseData, Qt.Key_T, "Key release filtered");
269+ }
270+
271+ function test_TextAreaInListItem_EnterCaptured() {
272+ input.forceActiveFocus();
273+ input.textFormat = TextEdit.PlainText;
274+ input.text = "";
275+ keyClick(Qt.Key_T);
276+ keyClick(Qt.Key_E);
277+ keyClick(Qt.Key_S);
278+ keyClick(Qt.Key_T);
279+ keyClick(Qt.Key_Enter);
280+ compare(input.text, "test\n", "Keys");
281+ }
282+ function test_TextAreaInListItem_EnterDoesNotProduceClick() {
283+ input.forceActiveFocus();
284+ input.textFormat = TextEdit.PlainText;
285+ input.text = "";
286+ listItemSpy.clear();
287+ keyClick(Qt.Key_Enter);
288+ tryCompare(listItemSpy, "count", 0, 100);
289+ }
290+
291+ function test_colorCollisionOnDelegate() {
292+ // fixes bug lp:1169601
293+ colorTest.text = "abc";
294+ compare(colorTest.color, "#0000ff", "Color when text length < 4");
295+ colorTest.text = "abcd";
296+ compare(colorTest.color, "#00ff00", "Color when text length >= 4");
297+ }
298+
299+ function test_OneActiveFocus() {
300+ t1.focus = true;
301+ compare(t1.activeFocus, true, "T1 has activeFocus");
302+ compare(t2.activeFocus, false, "T1 has activeFocus");
303+ t2.focus = true;
304+ compare(t1.activeFocus, false, "T1 has activeFocus");
305+ compare(t2.activeFocus, true, "T1 has activeFocus");
306+ }
307+
308+ function test_OSK_ShownWhenNextTextAreaIsFocused() {
309+ if (!hasOSK)
310+ expectFail("", "OSK can be tested only when present");
311+ t1.focus = true;
312+ compare(Qt.inputMethod.visible, true, "OSK is shown for the first TextArea");
313+ t2.focus = true;
314+ compare(Qt.inputMethod.visible, true, "OSK is shown for the second TextArea");
315+ }
316+
317+ function test_RemoveOSKWhenFocusLost() {
318+ if (!hasOSK)
319+ expectFail("", "OSK can be tested only when present");
320+ t1.focus = true;
321+ compare(Qt.inputMethod.visible, true, "OSK is shown when TextArea gains focus");
322+ t1.focus = false;
323+ compare(Qt.inputMethod.visible, false, "OSK is hidden when TextArea looses focus");
324+ }
325+
326+ function test_ReEnabledInput() {
327+ textArea.forceActiveFocus();
328+ textArea.enabled = false;
329+ compare(textArea.enabled, false, "textArea is disabled");
330+ compare(textArea.focus, true, "textArea is focused");
331+ compare(textArea.activeFocus, false, "textArea is not active focus");
332+ compare(Qt.inputMethod.visible, false, "OSK removed");
333+
334+ textArea.enabled = true;
335+ compare(textArea.enabled, true, "textArea is enabled");
336+ compare(textArea.focus, true, "textArea is focused");
337+ compare(textArea.activeFocus, true, "textArea is active focus");
338+ if (!hasOSK)
339+ expectFail("", "OSK can be tested only when present");
340+ compare(Qt.inputMethod.visible, true, "OSK shown");
341+ }
342+
343+ // make it to b ethe last test case executed
344+ function test_zz_TextareaInListItem_RichTextEnterCaptured() {
345+ textArea.text = "a<br />b";
346+ textArea.textFormat = TextEdit.RichText;
347+ input.forceActiveFocus();
348+ input.textFormat = TextEdit.RichText;
349+ input.text = "ab";
350+ input.cursorPosition = 1;
351+ keyClick(Qt.Key_Return);
352+ compare(input.text, textArea.text, "Formatted text split");
353 }
354 }
355 }
356
357=== modified file 'tests/unit/tst_components/tst_textfield.qml'
358--- tests/unit/tst_components/tst_textfield.qml 2013-02-13 10:52:46 +0000
359+++ tests/unit/tst_components/tst_textfield.qml 2013-04-18 14:13:29 +0000
360@@ -21,23 +21,47 @@
361 Item {
362 id: textItem
363 width: 200; height: 200
364+
365+ property bool hasOSK: QuickUtils.inputMethodProvider !== ""
366+
367+ function reset() {
368+ colorTest.focus = false;
369+ textField.focus = false;
370+ t1.focus = false;
371+ t2.focus = false;
372+ }
373+
374+ TextField {
375+ id: colorTest
376+ color: colorTest.text.length < 4 ? "#0000ff" : "#00ff00"
377+ }
378+
379+ TextField {
380+ id: textField
381+ SignalSpy {
382+ id: signalSpy
383+ target: parent
384+ }
385+
386+ property int keyPressData
387+ property int keyReleaseData
388+ Keys.onPressed: keyPressData = event.key
389+ Keys.onReleased: keyReleaseData = event.key
390+ }
391+
392+ Item {
393+ TextField {
394+ id: t1
395+ }
396+ TextField {
397+ id: t2
398+ }
399+ }
400+
401 TestCase {
402 name: "TextFieldAPI"
403 when: windowShown
404
405- TextField {
406- id: textField
407- SignalSpy {
408- id: signalSpy
409- target: parent
410- }
411-
412- property int keyPressData
413- property int keyReleaseData
414- Keys.onPressed: keyPressData = event.key
415- Keys.onReleased: keyReleaseData = event.key
416- }
417-
418 function initTestCase() {
419 textField.forceActiveFocus();
420 compare(textField.focus, true, "TextField is focused");
421@@ -195,6 +219,59 @@
422 compare(textField.text, "test text", "Data pasted");
423 }
424
425+ function test_colorCollisionOnDelegate() {
426+ // fixes bug lp:1169601
427+ colorTest.text = "abc";
428+ compare(colorTest.color, "#0000ff", "Color when text length < 4");
429+ colorTest.text = "abcd";
430+ compare(colorTest.color, "#00ff00", "Color when text length >= 4");
431+ }
432+
433+ function test_OneActiveFocus() {
434+ t1.focus = true;
435+ compare(t1.activeFocus, true, "T1 has activeFocus");
436+ compare(t2.activeFocus, false, "T1 has activeFocus");
437+ t2.focus = true;
438+ compare(t1.activeFocus, false, "T1 has activeFocus");
439+ compare(t2.activeFocus, true, "T1 has activeFocus");
440+ }
441+
442+ // need to make the very first test case, otherwise OSK detection fails on phablet
443+ function test_zz_OSK_ShownWhenNextTextFieldIsFocused() {
444+ if (!hasOSK)
445+ expectFail("", "OSK can be tested only when present");
446+ t1.focus = true;
447+ compare(Qt.inputMethod.visible, true, "OSK is shown for the first TextField");
448+ t2.focus = true;
449+ compare(Qt.inputMethod.visible, true, "OSK is shown for the second TextField");
450+ }
451+
452+ function test_zz_RemoveOSKWhenFocusLost() {
453+ if (!hasOSK)
454+ expectFail("", "OSK can be tested only when present");
455+ t1.focus = true;
456+ compare(Qt.inputMethod.visible, true, "OSK is shown when TextField gains focus");
457+ t1.focus = false;
458+ compare(Qt.inputMethod.visible, false, "OSK is hidden when TextField looses focus");
459+ }
460+
461+ function test_zz_ReEnabledInput() {
462+ textField.forceActiveFocus();
463+ textField.enabled = false;
464+ compare(textField.enabled, false, "textField is disabled");
465+ compare(textField.focus, true, "textField is focused");
466+ compare(textField.activeFocus, false, "textField is not active focus");
467+ compare(Qt.inputMethod.visible, false, "OSK removed");
468+
469+ textField.enabled = true;
470+ compare(textField.enabled, true, "textField is enabled");
471+ compare(textField.focus, true, "textField is focused");
472+ compare(textField.activeFocus, true, "textField is active focus");
473+ if (!hasOSK)
474+ expectFail("", "OSK can be tested only when present");
475+ compare(Qt.inputMethod.visible, true, "OSK shown");
476+ }
477+
478 RegExpValidator {
479 id: regExpValidator
480 regExp: /[a-z]*/
481
482=== modified file 'themes/Ambiance/qmltheme/TextAreaDelegate.qml'
483--- themes/Ambiance/qmltheme/TextAreaDelegate.qml 2013-03-27 07:51:04 +0000
484+++ themes/Ambiance/qmltheme/TextAreaDelegate.qml 2013-04-18 14:13:29 +0000
485@@ -18,15 +18,16 @@
486 import Ubuntu.Components 0.1
487
488 // frame
489-UbuntuShape {
490- id: shape
491-
492+Item {
493+ id: visuals
494 // style properties
495- /*!
496- Background fill color
497- */
498 // FIXME: needs type checking in themes to define the proper type to be used
499 // if color type is used, alpha value gets lost
500+
501+ property color color
502+ /*!
503+ Background fill color
504+ */
505 property color backgroundColor: Qt.rgba(0, 0, 0, 0.1)
506 property color errorColor: "red"
507 property real backgroundOpacity
508@@ -37,27 +38,31 @@
509 property var frameSpacing
510 property real overlaySpacing
511
512- // visuals
513- z: -1
514- property bool error: (item.hasOwnProperty("errorHighlight") && item.errorHighlight && !item.acceptableInput)
515- onErrorChanged: color = (error) ? errorColor : backgroundColor;
516- color: backgroundColor
517 anchors.fill: parent
518- opacity: backgroundOpacity
519-
520- MouseArea {
521- anchors.fill: parent
522- onPressed: if (!item.activeFocus && item.activeFocusOnPress) item.forceActiveFocus()
523- }
524
525 Binding {
526 target: item.__internal
527 property: "frameSpacing"
528- value: shape.frameSpacing
529+ value: visuals.frameSpacing
530 }
531 Binding {
532 target: item.__internal
533 property: "spacing"
534- value: overlaySpacing
535+ value: visuals.overlaySpacing
536+ }
537+
538+ z: -1
539+ UbuntuShape {
540+ id: shape
541+ property bool error: (item.hasOwnProperty("errorHighlight") && item.errorHighlight && !item.acceptableInput)
542+ onErrorChanged: (error) ? visuals.errorColor : visuals.backgroundColor;
543+ color: visuals.backgroundColor;
544+ anchors.fill: parent
545+ opacity: visuals.backgroundOpacity
546+
547+ MouseArea {
548+ anchors.fill: parent
549+ onPressed: if (!item.activeFocus && item.activeFocusOnPress) item.forceActiveFocus()
550+ }
551 }
552 }

Subscribers

People subscribed via source and target branches

to all changes: