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