Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1312329 into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 164
Merged at revision: 170
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1312329
Merge into: lp:ubuntu-keyboard
Diff against target: 141 lines (+31/-7)
5 files modified
src/plugin/inputmethod.cpp (+11/-6)
src/plugin/inputmethod_p.h (+3/-0)
src/view/abstracttexteditor.cpp (+13/-0)
tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp (+2/-1)
tests/unittests/ut_repeat-backspace/ut_repeat-backspace.pro (+2/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1312329
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+219330@code.launchpad.net

Commit message

Re-evaluate the state of autocaps when the user is deleting characters and when the cursor position changes to the beginning of a field

Description of the change

Re-evaluates the state of autocaps when the user is deleting characters and when the cursor position changes to the beginning of a field (e.g. when that field is cleared via an external action).

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-keyboard) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed the packaging (debian), did you subscribe a core-dev to this MP?

 * No change

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
162. By Michael Sheldon

Merge from trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
163. By Michael Sheldon

Fix activation of autocaps on backspace when word immediately following punctuation is still in pre-edit

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
164. By Michael Sheldon

Use mock word engine for repeat backspace tests instead of attempting to load system plugin

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
yes

Did CI run pass? If not, please explain why.
yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/plugin/inputmethod.cpp'
2--- src/plugin/inputmethod.cpp 2014-05-01 16:39:00 +0000
3+++ src/plugin/inputmethod.cpp 2014-05-16 16:13:27 +0000
4@@ -158,6 +158,7 @@
5 qDebug() << "inputMethod::reset()";
6 Q_D(InputMethod);
7 d->editor.clearPreedit();
8+ d->previous_position = -1;
9 }
10
11 void InputMethod::setPreedit(const QString &preedit,
12@@ -201,9 +202,7 @@
13
14 void InputMethod::handleFocusChange(bool focusIn)
15 {
16- if (focusIn) {
17- checkInitialAutocaps();
18- } else {
19+ if (!focusIn) {
20 hide();
21 }
22 }
23@@ -357,9 +356,16 @@
24 if (ok) {
25 d->editor.text()->setSurrounding(text);
26 d->editor.text()->setSurroundingOffset(position);
27+
28+ updateAutoCaps();
29+
30+ // If we're at the beginning of a text field (e.g. because it's been cleared,
31+ // or the cursor has been moved) then re-evaluate initial autocaps
32+ if (position == 0 && position != d->previous_position) {
33+ checkInitialAutocaps();
34+ }
35+ d->previous_position = position;
36 }
37-
38- updateAutoCaps();
39 }
40
41 void InputMethod::updateWordEngine()
42@@ -404,7 +410,6 @@
43 void InputMethod::checkInitialAutocaps()
44 {
45 Q_D(InputMethod);
46- update();
47
48 if (d->autocapsEnabled) {
49 QString text;
50
51=== modified file 'src/plugin/inputmethod_p.h'
52--- src/plugin/inputmethod_p.h 2014-05-01 16:39:00 +0000
53+++ src/plugin/inputmethod_p.h 2014-05-16 16:13:27 +0000
54@@ -62,6 +62,8 @@
55
56 WordRibbon* wordRibbon;
57
58+ int previous_position;
59+
60 explicit InputMethodPrivate(InputMethod * const _q,
61 MAbstractInputMethodHost *host)
62 : q(_q)
63@@ -79,6 +81,7 @@
64 , m_geometry(new KeyboardGeometry(q))
65 , m_settings()
66 , wordRibbon(new WordRibbon)
67+ , previous_position(-1)
68 {
69 applicationApiWrapper->setGeometryItem(m_geometry);
70
71
72=== modified file 'src/view/abstracttexteditor.cpp'
73--- src/view/abstracttexteditor.cpp 2014-05-09 12:51:35 +0000
74+++ src/view/abstracttexteditor.cpp 2014-05-16 16:13:27 +0000
75@@ -787,10 +787,16 @@
76 {
77 Q_D(AbstractTextEditor);
78
79+ QString textOnLeft = d->text->surroundingLeft();
80+
81 if (d->text->preedit().isEmpty()) {
82 sendKeyPressAndReleaseEvents(Qt::Key_Backspace, Qt::NoModifier);
83+ // Deletion of surrounding text isn't updated in the model until later
84+ // Update it locally here for autocaps detection
85+ textOnLeft.chop(1);
86 } else {
87 d->text->removeFromPreedit(1);
88+ textOnLeft += d->text->preedit();
89
90 // Don't find word candidates if the user is holding down backspace
91 if(!d->repeating_backspace) {
92@@ -812,6 +818,13 @@
93 }
94 }
95
96+ textOnLeft = textOnLeft.trimmed();
97+
98+ const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);
99+ if (auto_caps_activated && d->auto_caps_enabled) {
100+ Q_EMIT autoCapsActivated();
101+ }
102+
103 d->backspace_sent = true;
104 }
105
106
107=== modified file 'tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp'
108--- tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2014-04-02 11:47:41 +0000
109+++ tests/unittests/ut_repeat-backspace/ut_repeat-backspace.cpp 2014-05-16 16:13:27 +0000
110@@ -34,6 +34,7 @@
111 #include "models/text.h"
112 #include "logic/wordengine.h"
113 #include "plugin/editor.h"
114+#include "common/wordengineprobe.h"
115
116 #include <inputmethodhostprobe.h>
117
118@@ -68,7 +69,7 @@
119
120 Q_SLOT void init()
121 {
122- editor.reset(new Editor(options, new Model::Text, new Logic::WordEngine));
123+ editor.reset(new Editor(options, new Model::Text, new Logic::WordEngineProbe));
124 host.reset(new InputMethodHostProbe);
125 editor->setHost(host.data());
126 }
127
128=== modified file 'tests/unittests/ut_repeat-backspace/ut_repeat-backspace.pro'
129--- tests/unittests/ut_repeat-backspace/ut_repeat-backspace.pro 2013-11-06 09:31:37 +0000
130+++ tests/unittests/ut_repeat-backspace/ut_repeat-backspace.pro 2014-05-16 16:13:27 +0000
131@@ -15,8 +15,10 @@
132 PRE_TARGETDEPS += $${TOP_BUILDDIR}/$${UBUNTU_KEYBOARD_LIB}
133
134 HEADERS += \
135+ ../common/wordengineprobe.h \
136
137 SOURCES += \
138+ ../common/wordengineprobe.cpp \
139 ut_repeat-backspace.cpp \
140
141 target.path = $$INSTALL_BIN

Subscribers

People subscribed via source and target branches