Merge lp:~michael-sheldon/ubuntu-keyboard/preedit-fixes into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 194
Merged at revision: 194
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/preedit-fixes
Merge into: lp:ubuntu-keyboard
Diff against target: 92 lines (+20/-7)
3 files modified
src/plugin/inputmethod.cpp (+1/-0)
src/view/abstracttexteditor.cpp (+17/-5)
src/view/abstracttexteditor.h (+2/-2)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/preedit-fixes
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+228270@code.launchpad.net

Commit message

Re-enter pre-edit after changing focus whilst still in a word (e.g. after swiping keyboard down and then tapping back in text field) or deleting punctuation characters and fix the pre-edit offset when deleting by holding backspace.

Description of the change

Re-enter pre-edit after changing focus whilst still in a word (e.g. after swiping keyboard down and then tapping back in text field), fix the pre-edit offset when deleting by holding backspace and re-enter pre-edit after deleting punctuation characters.

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 changes

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

 * No changes

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

tested, works

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-07-22 14:02:39 +0000
3+++ src/plugin/inputmethod.cpp 2014-07-25 10:30:36 +0000
4@@ -133,6 +133,7 @@
5
6 d->view->setVisible(true);
7 d->m_geometry->setShown(true);
8+ d->editor.checkPreeditReentry(false);
9 }
10
11 void InputMethod::hide()
12
13=== modified file 'src/view/abstracttexteditor.cpp'
14--- src/view/abstracttexteditor.cpp 2014-07-22 14:02:39 +0000
15+++ src/view/abstracttexteditor.cpp 2014-07-25 10:30:36 +0000
16@@ -486,11 +486,13 @@
17 case Key::ActionBackspace: {
18 if (not d->backspace_sent) {
19 singleBackspace();
20+ checkPreeditReentry(true);
21+ } else {
22+ checkPreeditReentry(false);
23 }
24
25 d->auto_repeat_backspace_timer.stop();
26 d->repeating_backspace = false;
27- checkPreeditReentry();
28 d->word_engine->computeCandidates(d->text.data());
29 } break;
30
31@@ -996,7 +998,7 @@
32
33 //! \brief AbstractTextEditor::checkPreeditReentry Checks to see whether we should
34 //! place a word back in to pre-edit after a character has been deleted
35-void AbstractTextEditor::checkPreeditReentry()
36+void AbstractTextEditor::checkPreeditReentry(bool uncommittedDelete)
37 {
38 if(!text()->preedit().isEmpty() || !isPreeditEnabled()) {
39 return;
40@@ -1004,17 +1006,27 @@
41
42 int currentOffset = text()->surroundingOffset();
43 if(currentOffset > 1 && !text()->surrounding().isEmpty()) {
44- // -2 for just deleted character that hasn't been committed and to reach character before cursor
45- QString lastChar = text()->surrounding().at(currentOffset-2);
46+ QString lastChar;
47+ if(uncommittedDelete) {
48+ // -2 for just deleted character that hasn't been committed and to reach character before cursor
49+ lastChar = text()->surrounding().at(currentOffset-2);
50+ } else {
51+ lastChar = text()->surrounding().at(currentOffset-1);
52+ }
53 if(!QRegExp("\\W+").exactMatch(lastChar)) {
54 QStringList leftWords = text()->surroundingLeft().trimmed().split(QRegExp("\\W+"));
55 int trimDiff = text()->surroundingLeft().size() - text()->surroundingLeft().trimmed().size();
56+ if(leftWords.last().isEmpty()) {
57+ // If removed char was punctuation trimming will result in an empty entry
58+ leftWords.removeLast();
59+ trimDiff += 1;
60+ }
61 if(!text()->surroundingRight().trimmed().isEmpty()) {
62 // We don't currently handle reentering preedit in the middle of the text
63 return;
64 }
65 QString recreatedPreedit = leftWords.last();
66- if(trimDiff == 0) {
67+ if(trimDiff == 0 && uncommittedDelete) {
68 // Remove the last character from the word if we weren't just deleting a space
69 // as the last backspace hasn't been committed yet.
70 recreatedPreedit.chop(1);
71
72=== modified file 'src/view/abstracttexteditor.h'
73--- src/view/abstracttexteditor.h 2014-07-22 14:02:39 +0000
74+++ src/view/abstracttexteditor.h 2014-07-25 10:30:36 +0000
75@@ -109,6 +109,8 @@
76 Model::Text * text() const;
77 Logic::AbstractWordEngine * wordEngine() const;
78
79+ void checkPreeditReentry(bool uncommittedDelete);
80+
81 Q_SLOT void onKeyPressed(const Key &key);
82 Q_SLOT void onKeyReleased(const Key &key);
83 Q_SLOT void onKeyEntered(const Key &key);
84@@ -170,8 +172,6 @@
85
86 void sendKeyPressAndReleaseEvents(int key, Qt::KeyboardModifiers modifiers,
87 const QString& text = QString());
88-
89- void checkPreeditReentry();
90 };
91
92 } // namespace MaliitKeyboard

Subscribers

People subscribed via source and target branches