Merge lp:~bfiller/ubuntu-keyboard/fix-preedit into lp:ubuntu-keyboard

Proposed by Bill Filler
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 143
Merged at revision: 146
Proposed branch: lp:~bfiller/ubuntu-keyboard/fix-preedit
Merge into: lp:ubuntu-keyboard
Diff against target: 81 lines (+31/-1)
3 files modified
src/plugin/inputmethod.cpp (+9/-0)
src/plugin/inputmethod.h (+1/-0)
src/view/abstracttexteditor.cpp (+21/-1)
To merge this branch: bzr merge lp:~bfiller/ubuntu-keyboard/fix-preedit
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+210527@code.launchpad.net

This proposal supersedes a proposal from 2014-02-24.

Commit message

clear the preedit and word candidates when the focused editor changes by implementing reset() in the plugin

Description of the change

sil's changes plus clear the preedit and word candidates when the focused editor changes by implementing reset() in the plugin. This cause the word candidate list and preedit to be cleared if the keyboard is closed or when the focused editor changes. So after sending a text message with an outstanding preedit the word list and preedit now correclty cleared.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote : Posted in a previous version of this proposal

This branch had some problems. While it did fix the issue on the backspace, it didn't solve the problem where the previous uncommited word and word candidates were showing up when you refocused the field. That should be solved now with my branch and the messaging-app branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Awesome, yes - I didn't check the case of switching focus, this way it seems to be cool. Tested and works like a charm, so an overall Approve.

Just a small nitpick if I can: I see some whitespace changes done unnecessarily, like in handleFocusChange and that TODO. And while we're at it, maybe we could 4 spaces instead of 2 in the reset() method? These are really just nitpicks, but since we're anyway blocked by Qt5.2 with ubuntu-keyboard landings, I would say - let's fix it :)

Thanks!

review: Needs Fixing (whitespaces)
143. By Bill Filler

fix whitespace issues

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

fixed whitespace issues, should be good to go

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Awesome!

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-01-31 17:20:14 +0000
3+++ src/plugin/inputmethod.cpp 2014-03-12 18:05:26 +0000
4@@ -147,6 +147,15 @@
5 d->closeOskWindow();
6 }
7
8+void InputMethod::reset()
9+{
10+ //this gets called from Qt when the focused editor changes
11+ //we need to clear preedit/word candidates in this case
12+ qDebug() << "inputMethod::reset()";
13+ Q_D(InputMethod);
14+ d->editor.clearPreedit();
15+}
16+
17 void InputMethod::setPreedit(const QString &preedit,
18 int cursor_position)
19 {
20
21=== modified file 'src/plugin/inputmethod.h'
22--- src/plugin/inputmethod.h 2014-01-21 22:51:18 +0000
23+++ src/plugin/inputmethod.h 2014-03-12 18:05:26 +0000
24@@ -84,6 +84,7 @@
25 virtual void handleFocusChange(bool focusIn);
26 virtual void handleAppOrientationChanged(int angle);
27 virtual void handleClientChange();
28+ virtual void reset();
29 virtual bool imExtensionEvent(MImExtensionEvent *event);
30 virtual void setKeyOverrides(const QMap<QString, QSharedPointer<MKeyOverride> > &overrides);
31 //! \reimp_end
32
33=== modified file 'src/view/abstracttexteditor.cpp'
34--- src/view/abstracttexteditor.cpp 2013-11-21 13:26:12 +0000
35+++ src/view/abstracttexteditor.cpp 2014-03-12 18:05:26 +0000
36@@ -433,7 +433,7 @@
37 case Key::ActionSpace: {
38 QString textOnLeft = d->text->surroundingLeft() + d->text->preedit();
39 const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);
40- const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty();
41+ const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty() && not d->text->preedit().isEmpty();
42
43 if (replace_preedit) {
44 const QString &appendix = d->word_engine->languageFeature()->appendixForReplacedPreedit(d->text->preedit());
45@@ -572,6 +572,15 @@
46 void AbstractTextEditor::clearPreedit()
47 {
48 replacePreedit("");
49+
50+ Q_D(AbstractTextEditor);
51+
52+ if (not d->valid()) {
53+ return;
54+ }
55+
56+ qDebug() << "in clear preedit.. clearing word engine";
57+ d->word_engine->clearCandidates();
58 }
59
60 //! \brief Returns whether preedit functionality is enabled.
61@@ -756,9 +765,20 @@
62 sendKeyEvent(ev);
63 } else {
64 d->text->removeFromPreedit(1);
65+
66 d->word_engine->computeCandidates(d->text.data());
67 sendPreeditString(d->text->preedit(), d->text->preeditFace(),
68 Replacement());
69+
70+ if (d->text->preedit().isEmpty()) {
71+ d->word_engine->clearCandidates();
72+ d->text->commitPreedit();
73+ // XXX: This is something like a workaround for maliit reporting an invalid state to Qt.
74+ // When preedit is cleared, for Qt not reporting it as inputMethodComposing all the time we need
75+ // to flush out all the TextFormat attributes - so we actually need to commit anything for that
76+ // to happen
77+ sendCommitString("");
78+ }
79 }
80
81 d->backspace_sent = true;

Subscribers

People subscribed via source and target branches