Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1372948-rtm into lp:ubuntu-keyboard/rtm-14.09

Proposed by Michael Sheldon on 2014-12-03
Status: Merged
Approved by: Bill Filler on 2014-12-08
Approved revision: 237
Merged at revision: 237
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1372948-rtm
Merge into: lp:ubuntu-keyboard/rtm-14.09
Diff against target: 129 lines (+30/-6)
5 files modified
plugins/en/src/englishplugin.h (+1/-0)
plugins/westernsupport/spellpredictworker.cpp (+18/-5)
plugins/westernsupport/spellpredictworker.h (+3/-1)
plugins/westernsupport/westernlanguagesplugin.cpp (+6/-0)
plugins/westernsupport/westernlanguagesplugin.h (+2/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1372948-rtm
Reviewer Review Type Date Requested Status
Bill Filler (community) 2014-12-03 Approve on 2014-12-08
Review via email: mp+243564@code.launchpad.net

Commit message

Automatically correct 'i' to 'I' when using the English language plugin.

Description of the change

Automatically correct 'i' to 'I' when using the English language plugin.

To post a comment you must log in.
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)

 * In sync with rtm-14.09 branch

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, except for last test in word prediction section as this isn't implemented in the 14.09 branch.

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

Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/en/src/englishplugin.h'
2--- plugins/en/src/englishplugin.h 2014-05-19 11:53:27 +0000
3+++ plugins/en/src/englishplugin.h 2014-12-03 17:17:29 +0000
4@@ -17,6 +17,7 @@
5 explicit EnglishPlugin(QObject* parent = 0)
6 : WesternLanguagesPlugin(parent)
7 {
8+ addOverride("i", "I");
9 }
10
11 virtual ~EnglishPlugin()
12
13=== modified file 'plugins/westernsupport/spellpredictworker.cpp'
14--- plugins/westernsupport/spellpredictworker.cpp 2014-08-07 17:04:01 +0000
15+++ plugins/westernsupport/spellpredictworker.cpp 2014-12-03 17:17:29 +0000
16@@ -43,14 +43,23 @@
17 m_presage.config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");
18 }
19
20-void SpellPredictWorker::parsePredictionText(const QString& surroundingLeft, const QString& preedit)
21+void SpellPredictWorker::parsePredictionText(const QString& surroundingLeft, const QString& origPreedit)
22 {
23- m_candidatesContext = (surroundingLeft.toStdString() + preedit.toStdString());
24+ m_candidatesContext = (surroundingLeft.toStdString() + origPreedit.toStdString());
25
26 QStringList list;
27
28- // If the user input is spelt correctly add it to the start of the predictions
29- if(m_spellChecker.spell(preedit)) {
30+ QString preedit = origPreedit;
31+
32+ // Allow plugins to override certain words such as ('i' -> 'I')
33+ if(m_overrides.contains(preedit)) {
34+ preedit = m_overrides[preedit];
35+ list << preedit;
36+ // Emit the override corrections instantly so they're always up-to-date
37+ // as they're often used for short words like 'I'
38+ Q_EMIT newPredictionSuggestions(origPreedit, list);
39+ } else if(m_spellChecker.spell(preedit)) {
40+ // If the user input is spelt correctly add it to the start of the predictions
41 list << preedit;
42 }
43
44@@ -74,7 +83,7 @@
45 qWarning() << "An exception was thrown in libpresage when calling predict(), exception nr: " << error;
46 }
47
48- Q_EMIT newPredictionSuggestions(preedit, list);
49+ Q_EMIT newPredictionSuggestions(origPreedit, list);
50 }
51
52 void SpellPredictWorker::setLanguage(QString locale)
53@@ -131,3 +140,7 @@
54 m_limit = limit;
55 }
56
57+void SpellPredictWorker::addOverride(const QString& orig, const QString& overriden)
58+{
59+ m_overrides[orig] = overriden;
60+}
61
62=== modified file 'plugins/westernsupport/spellpredictworker.h'
63--- plugins/westernsupport/spellpredictworker.h 2014-08-07 17:04:01 +0000
64+++ plugins/westernsupport/spellpredictworker.h 2014-12-03 17:17:29 +0000
65@@ -34,6 +34,7 @@
66
67 #include <QObject>
68 #include <QStringList>
69+#include <QMap>
70
71 class CandidatesCallback;
72
73@@ -51,6 +52,7 @@
74 void setLanguage(QString language);
75 void setSpellCheckLimit(int limit);
76 void addToUserWordList(const QString& word);
77+ void addOverride(const QString& orig, const QString& overriden);
78
79 signals:
80 void newSpellingSuggestions(QString word, QStringList suggestions);
81@@ -64,7 +66,7 @@
82 QString m_word;
83 int m_limit;
84 bool m_processingWords;
85-
86+ QMap<QString, QString> m_overrides;
87 };
88
89 #endif // SPELLPREDICTWORKER_H
90
91=== modified file 'plugins/westernsupport/westernlanguagesplugin.cpp'
92--- plugins/westernsupport/westernlanguagesplugin.cpp 2014-08-07 17:04:01 +0000
93+++ plugins/westernsupport/westernlanguagesplugin.cpp 2014-12-03 17:17:29 +0000
94@@ -20,6 +20,7 @@
95 connect(this, SIGNAL(setSpellCheckLimit(int)), spellPredictWorker, SLOT(setSpellCheckLimit(int)));
96 connect(this, SIGNAL(parsePredictionText(QString, QString)), spellPredictWorker, SLOT(parsePredictionText(QString, QString)));
97 connect(this, SIGNAL(addToUserWordList(QString)), spellPredictWorker, SLOT(addToUserWordList(QString)));
98+ connect(this, SIGNAL(addOverride(QString, QString)), spellPredictWorker, SLOT(addOverride(QString, QString)));
99 m_spellPredictThread->start();
100 }
101
102@@ -59,3 +60,8 @@
103 Q_EMIT setSpellPredictLanguage(languageId);
104 return true;
105 }
106+
107+void WesternLanguagesPlugin::addSpellingOverride(const QString& orig, const QString& overriden)
108+{
109+ Q_EMIT addOverride(orig, overriden);
110+}
111
112=== modified file 'plugins/westernsupport/westernlanguagesplugin.h'
113--- plugins/westernsupport/westernlanguagesplugin.h 2014-08-07 17:04:01 +0000
114+++ plugins/westernsupport/westernlanguagesplugin.h 2014-12-03 17:17:29 +0000
115@@ -31,6 +31,7 @@
116 virtual void spellCheckerSuggest(const QString& word, int limit);
117 virtual void addToSpellCheckerUserWordList(const QString& word);
118 virtual bool setLanguage(const QString& languageId);
119+ virtual void addSpellingOverride(const QString& orig, const QString& overriden);
120
121 signals:
122 void newSpellingSuggestions(QString word, QStringList suggestions);
123@@ -41,6 +42,7 @@
124 void parsePredictionText(QString surroundingLeft, QString preedit);
125 void setPredictionLanguage(QString language);
126 void addToUserWordList(const QString& word);
127+ void addOverride(const QString& orig, const QString& overriden);
128
129 public slots:
130

Subscribers

People subscribed via source and target branches