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

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 235
Merged at revision: 237
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1384806
Merge into: lp:ubuntu-keyboard
Diff against target: 138 lines (+38/-11)
3 files modified
src/lib/logic/abstractwordengine.h (+1/-1)
src/lib/logic/wordengine.cpp (+36/-10)
src/lib/logic/wordengine.h (+1/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1384806
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+239992@code.launchpad.net

Commit message

Don't show word candidates arriving after a word has been committed and allow candidates to remain on the word ribbon until a new set has been calculated prior to commit.

Description of the change

Don't show word candidates arriving after a word has been committed and allow candidates to remain on the word ribbon until a new set has been calculated prior to commit.

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 UI labels, did you update the pot file?

 * No change

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

 * No change

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/lib/logic/abstractwordengine.h'
2--- src/lib/logic/abstractwordengine.h 2014-07-25 14:08:51 +0000
3+++ src/lib/logic/abstractwordengine.h 2014-10-29 13:59:35 +0000
4@@ -66,7 +66,7 @@
5 Q_SLOT virtual void setSpellcheckerEnabled(bool on);
6 Q_SLOT virtual void setAutoCorrectEnabled(bool on);
7
8- void clearCandidates();
9+ virtual void clearCandidates();
10 void computeCandidates(Model::Text *text);
11 Q_SIGNAL void candidatesChanged(const WordCandidateList &candidates);
12
13
14=== modified file 'src/lib/logic/wordengine.cpp'
15--- src/lib/logic/wordengine.cpp 2014-08-07 17:04:01 +0000
16+++ src/lib/logic/wordengine.cpp 2014-10-29 13:59:35 +0000
17@@ -58,13 +58,15 @@
18
19 bool calculated_primary_candidate;
20
21+ bool clear_candidates_on_incoming;
22+
23 LanguagePluginInterface* languagePlugin;
24
25 QPluginLoader pluginLoader;
26
27 WordCandidateList* candidates;
28
29- QString currentPreedit;
30+ Model::Text *currentText;
31
32 explicit WordEnginePrivate();
33
34@@ -110,6 +112,7 @@
35 , is_preedit_capitalized(false)
36 , auto_correct_enabled(false)
37 , calculated_primary_candidate(false)
38+ , clear_candidates_on_incoming(false)
39 , languagePlugin(0)
40 {
41 loadPlugin(DEFAULT_PLUGIN);
42@@ -226,15 +229,15 @@
43
44 d->calculated_primary_candidate = false;
45
46- d->currentPreedit = text->preedit();
47-
48- d->candidates = new WordCandidateList();
49+ // Allow the current candidates to remain on the word ribbon until
50+ // a new set have been calculated.
51+ d->clear_candidates_on_incoming = true;
52+
53+ d->currentText = text;
54+
55 const QString &preedit(text->preedit());
56 d->is_preedit_capitalized = not preedit.isEmpty() && preedit.at(0).isUpper();
57
58- WordCandidate userCandidate(WordCandidate::SourceUser, preedit);
59- d->candidates->append(userCandidate);
60-
61 Q_EMIT candidatesChanged(*d->candidates);
62
63 Q_EMIT primaryCandidateChanged(QString());
64@@ -252,7 +255,7 @@
65 {
66 Q_D(WordEngine);
67
68- if (word != d->currentPreedit) {
69+ if (d->currentText && word != d->currentText->preedit()) {
70 // Don't add suggestions coming in for a previous word
71 return;
72 }
73@@ -261,6 +264,11 @@
74 // So we need to ensure only one primary candidate is selected
75 suggestionMutex.lock();
76
77+ if (d->clear_candidates_on_incoming) {
78+ clearCandidates();
79+ d->clear_candidates_on_incoming = false;
80+ }
81+
82 Q_FOREACH(const QString &correction, suggestions) {
83 appendToCandidates(d->candidates, WordCandidate::SourceSpellChecking, correction);
84 }
85@@ -276,7 +284,7 @@
86 {
87 Q_D(WordEngine);
88
89- if (word != d->currentPreedit) {
90+ if (d->currentText && word != d->currentText->preedit()) {
91 // Don't add suggestions coming in for a previous word
92 return;
93 }
94@@ -285,8 +293,13 @@
95 // So we need to ensure only one primary candidate is selected
96 suggestionMutex.lock();
97
98+ if (d->clear_candidates_on_incoming) {
99+ clearCandidates();
100+ d->clear_candidates_on_incoming = false;
101+ }
102+
103 Q_FOREACH(const QString &correction, suggestions) {
104- appendToCandidates(d->candidates, WordCandidate::SourceSpellChecking, correction);
105+ appendToCandidates(d->candidates, WordCandidate::SourcePrediction, correction);
106 }
107
108 calculatePrimaryCandidate();
109@@ -406,4 +419,17 @@
110 return d->languagePlugin->languageFeature();
111 }
112
113+void WordEngine::clearCandidates()
114+{
115+ Q_D(WordEngine);
116+ if(isEnabled()) {
117+ d->candidates = new WordCandidateList();
118+ if (d->currentText) {
119+ WordCandidate userCandidate(WordCandidate::SourceUser, d->currentText->preedit());
120+ d->candidates->append(userCandidate);
121+ }
122+ Q_EMIT candidatesChanged(*d->candidates);
123+ }
124+}
125+
126 }} // namespace Logic, MaliitKeyboard
127
128=== modified file 'src/lib/logic/wordengine.h'
129--- src/lib/logic/wordengine.h 2014-08-01 15:40:48 +0000
130+++ src/lib/logic/wordengine.h 2014-10-29 13:59:35 +0000
131@@ -63,6 +63,7 @@
132 virtual void addToUserDictionary(const QString &word);
133 virtual void setSpellcheckerEnabled(bool enabled);
134 virtual void setAutoCorrectEnabled(bool enabled);
135+ virtual void clearCandidates();
136 //! \reimp_end
137
138 void appendToCandidates(WordCandidateList *candidates,

Subscribers

People subscribed via source and target branches