Merge lp:~schwann/ubuntu-keyboard/spellchecker-languages into lp:ubuntu-keyboard

Proposed by Günter Schwann
Status: Merged
Approved by: Thomas Moenicke
Approved revision: 111
Merged at revision: 110
Proposed branch: lp:~schwann/ubuntu-keyboard/spellchecker-languages
Merge into: lp:ubuntu-keyboard
Diff against target: 634 lines (+215/-72)
12 files modified
buildOnDevice.sh (+1/-12)
src/lib/logic/abstractwordengine.cpp (+7/-0)
src/lib/logic/abstractwordengine.h (+2/-0)
src/lib/logic/spellchecker.cpp (+128/-32)
src/lib/logic/spellchecker.h (+6/-2)
src/lib/logic/wordengine.cpp (+15/-0)
src/lib/logic/wordengine.h (+1/-0)
src/plugin/inputmethod.cpp (+1/-0)
src/plugin/inputmethod_p.h (+12/-5)
src/plugin/keyboardsettings.cpp (+18/-5)
src/plugin/keyboardsettings.h (+7/-5)
tests/unittests/ut_keyboardsettings/ut_keyboardsettings.cpp (+17/-11)
To merge this branch: bzr merge lp:~schwann/ubuntu-keyboard/spellchecker-languages
Reviewer Review Type Date Requested Status
Thomas Moenicke (community) Approve
Review via email: mp+194695@code.launchpad.net

Commit message

Spellchecker uses active language (if installed)

Description of the change

Spellchecker can uses active language (if installed)

The packages of hunspell (like hunspell-en-us or hunspell-fr) need to installed

To post a comment you must log in.
109. By Günter Schwann

* remove Hunspell object if not used
* use the settings to enable/disable spell checking

110. By Günter Schwann

Remove a debug message

111. By Günter Schwann

Trunk merged

Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

tested following test plan, all working

112. By Günter Schwann

Trunk merged

113. By Günter Schwann

Add fallback functionality for country specific languages, to search for another country (use en-us, if en-gb is not available)

114. By Günter Schwann

Print a warning is original language wasn't found

Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

tested with english and german, spell checker is working in both languages when changing language in lang menu

Revision history for this message
Thomas Moenicke (thomas-moenicke) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildOnDevice.sh'
2--- buildOnDevice.sh 2013-10-31 14:24:31 +0000
3+++ buildOnDevice.sh 2013-11-14 11:50:58 +0000
4@@ -29,10 +29,6 @@
5 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t $USER@$TARGET_IP -p $TARGET_SSH_PORT "bash -ic \"$@\""
6 }
7
8-exec_with_adb() {
9- adb shell chroot /data/ubuntu /usr/bin/env -i PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin "$@"
10-}
11-
12 adb_root() {
13 adb root
14 adb wait-for-device
15@@ -50,7 +46,7 @@
16 }
17
18 install_dependencies() {
19- exec_with_adb apt-get -y install openssh-server
20+ adb shell apt-get -y install openssh-server
21 adb shell start ssh
22 sleep 2
23 exec_with_ssh $SUDO apt-get -y install build-essential rsync bzr ccache gdb libglib2.0-bin unzip
24@@ -59,11 +55,6 @@
25 exec_with_ssh $SUDO apt-get -y build-dep $PACKAGE
26 }
27
28-reset_screen_powerdown() {
29- exec_with_ssh $SUDO dbus-launch gsettings set com.canonical.powerd activity-timeout 600
30- exec_with_ssh $SUDO sudo initctl restart powerd
31-}
32-
33 setup_adb_forwarding() {
34 adb forward tcp:$TARGET_SSH_PORT tcp:22
35 adb forward tcp:$TARGET_DEBUG_PORT tcp:$TARGET_DEBUG_PORT
36@@ -82,7 +73,6 @@
37 echo "Installing"
38 adb shell pkill "maliit-server"
39 exec_with_ssh "cd $CODE_DIR/ && " $SUDO " make install"
40-# exec_with_ssh "cd $CODE_DIR/ && dpkg-buildpackage -j4"
41 }
42
43 run() {
44@@ -114,7 +104,6 @@
45 echo "Setting up environment for building shell.."
46 install_ssh_key
47 install_dependencies
48- reset_screen_powerdown
49 sync_code
50 else
51 echo "Transferring code.."
52
53=== modified file 'src/lib/logic/abstractwordengine.cpp'
54--- src/lib/logic/abstractwordengine.cpp 2013-07-19 12:05:07 +0000
55+++ src/lib/logic/abstractwordengine.cpp 2013-11-14 11:50:58 +0000
56@@ -159,4 +159,11 @@
57 Q_UNUSED(word);
58 }
59
60+//!
61+void AbstractWordEngine::enableSpellchecker(bool on)
62+{
63+ Q_UNUSED(on);
64+ qDebug() << Q_FUNC_INFO << "should be implemented by inherited class";
65+}
66+
67 }} // namespace MaliitKeyboard, Logic
68
69=== modified file 'src/lib/logic/abstractwordengine.h'
70--- src/lib/logic/abstractwordengine.h 2013-07-19 12:05:07 +0000
71+++ src/lib/logic/abstractwordengine.h 2013-11-14 11:50:58 +0000
72@@ -60,6 +60,8 @@
73 Q_SLOT virtual void setEnabled(bool enabled);
74 Q_SIGNAL void enabledChanged(bool enabled);
75
76+ Q_SLOT virtual void enableSpellchecker(bool on);
77+
78 void clearCandidates();
79 void computeCandidates(Model::Text *text);
80 Q_SIGNAL void candidatesChanged(const WordCandidateList &candidates);
81
82=== modified file 'src/lib/logic/spellchecker.cpp'
83--- src/lib/logic/spellchecker.cpp 2013-07-19 12:05:07 +0000
84+++ src/lib/logic/spellchecker.cpp 2013-11-14 11:50:58 +0000
85@@ -58,6 +58,7 @@
86 #include <QTextCodec>
87 #include <QStringList>
88 #include <QDebug>
89+#include <QDir>
90
91 namespace MaliitKeyboard {
92 namespace Logic {
93@@ -68,55 +69,114 @@
94
95 struct SpellCheckerPrivate
96 {
97- Hunspell hunspell; //!< The spellchecker backend, Hunspell.
98+ Hunspell *hunspell; //!< The spellchecker backend, Hunspell.
99 QTextCodec *codec; //!< Which codec to use.
100- bool enabled; //!< Whether the spellchecker is enabled.
101 QSet<QString> ignored_words; //!< The words to ignore.
102 QString user_dictionary_file;
103+ QString aff_file;
104+ QString dic_file;
105
106- SpellCheckerPrivate(const QString &dictionary_path,
107- const QString &user_dictionary);
108+ SpellCheckerPrivate(const QString &user_dictionary);
109+ ~SpellCheckerPrivate();
110+ void addUserDictionary(const QString &user_dictionary);
111+ void clear();
112 };
113
114
115-SpellCheckerPrivate::SpellCheckerPrivate(const QString &dictionary_path,
116- const QString &user_dictionary)
117+SpellCheckerPrivate::SpellCheckerPrivate(const QString &user_dictionary)
118 // XXX: toUtf8? toLatin1? toAscii? toLocal8Bit?
119- : hunspell((dictionary_path + ".aff").toUtf8().constData(),
120- (dictionary_path + ".dic").toUtf8().constData())
121- , codec(QTextCodec::codecForName(hunspell.get_dic_encoding()))
122- , enabled(false)
123+ : hunspell(0)
124+ , codec(0)
125 , ignored_words()
126 , user_dictionary_file(user_dictionary)
127-{
128- if (not codec) {
129- qWarning () << __PRETTY_FUNCTION__ << ":Could not find codec for" << hunspell.get_dic_encoding() << "- turning off spellchecking and suggesting.";
130+ , aff_file()
131+ , dic_file()
132+{
133+}
134+
135+SpellCheckerPrivate::~SpellCheckerPrivate()
136+{
137+ clear();
138+}
139+
140+//! \brief SpellCheckerPrivate::addUserDictionary adds the users custom words to the dictionary
141+//! \param user_dictionary filename of the user's dictionary
142+void SpellCheckerPrivate::addUserDictionary(const QString &user_dictionary)
143+{
144+ if (not hunspell)
145 return;
146- }
147
148 if (not user_dictionary.isEmpty() and QFile::exists(user_dictionary)) {
149 QFile file(user_dictionary);
150 if (file.open(QFile::ReadOnly)) {
151 QTextStream stream(&file);
152 while (!stream.atEnd()) {
153- hunspell.add(codec->fromUnicode(stream.readLine()));
154+ hunspell->add(codec->fromUnicode(stream.readLine()));
155 }
156 }
157 }
158-
159- enabled = true;
160-}
161-
162+}
163+
164+//! \brief SpellCheckerPrivate::clear cleans up all memory and does reset
165+//! everything for a new language
166+void SpellCheckerPrivate::clear()
167+{
168+ delete(hunspell);
169+ hunspell = 0;
170+ aff_file.clear();
171+ dic_file.clear();
172+}
173
174 SpellChecker::~SpellChecker()
175 {}
176
177-
178-//! \param dictionary_path The directory path to the (system) dictionaries.
179+//! \brief SpellChecker::enabled returns if the spechchecking is active
180+//! \return
181+bool SpellChecker::enabled() const
182+{
183+ Q_D(const SpellChecker);
184+ return (d->hunspell != 0);
185+}
186+
187+//! \brief SpellChecker::setEnabled
188+//! \param on
189+//! \return true if setting it enabled/disabled went ok
190+bool SpellChecker::setEnabled(bool on)
191+{
192+ Q_D(SpellChecker);
193+
194+ if (enabled() == on)
195+ return true;
196+
197+ delete(d->hunspell);
198+ d->hunspell = 0;
199+
200+ if (not on) {
201+ return true;
202+ }
203+
204+ if (d->aff_file.isEmpty() || d->dic_file.isEmpty()) {
205+ qWarning() << "no dictionary to turn on spellchecking";
206+ return false;
207+ }
208+
209+ d->hunspell = new Hunspell(d->aff_file.toUtf8().constData(),
210+ d->dic_file.toUtf8().constData());
211+
212+ d->codec = QTextCodec::codecForName(d->hunspell->get_dic_encoding());
213+ if (not d->codec) {
214+ qWarning () << Q_FUNC_INFO << ":Could not find codec for" << d->hunspell->get_dic_encoding() << "- turning off spellchecking";
215+ d->clear();
216+ return false;
217+ }
218+
219+ d->addUserDictionary(d->user_dictionary_file);
220+ return true;
221+}
222+
223 //! \param user_dictionary The file path to the user's own dictionary.
224-SpellChecker::SpellChecker(const QString &dictionary_path,
225- const QString &user_dictionary)
226- : d_ptr(new SpellCheckerPrivate(dictionary_path, user_dictionary))
227+SpellChecker::SpellChecker(const QString &user_dictionary)
228+ : d_ptr(new SpellCheckerPrivate(user_dictionary))
229 {}
230
231
232@@ -130,11 +190,11 @@
233 {
234 Q_D(SpellChecker);
235
236- if (not d->enabled or d->ignored_words.contains(word)) {
237+ if (not enabled() or d->ignored_words.contains(word)) {
238 return true;
239 }
240
241- return d->hunspell.spell(d->codec->fromUnicode(word));
242+ return d->hunspell->spell(d->codec->fromUnicode(word));
243 }
244
245
246@@ -147,12 +207,12 @@
247 {
248 Q_D(SpellChecker);
249
250- if (not d->enabled) {
251+ if (not enabled()) {
252 return QStringList();
253 }
254
255 char** suggestions = NULL;
256- const int suggestions_count = d->hunspell.suggest(&suggestions, d->codec->fromUnicode(word));
257+ const int suggestions_count = d->hunspell->suggest(&suggestions, d->codec->fromUnicode(word));
258
259 // Less than zero means some error.
260 if (suggestions_count < 0) {
261@@ -166,7 +226,7 @@
262 for (int index(0); index < final_limit; ++index) {
263 result << d->codec->toUnicode(suggestions[index]);
264 }
265- d->hunspell.free_list(&suggestions, suggestions_count);
266+ d->hunspell->free_list(&suggestions, suggestions_count);
267 return result;
268 }
269
270@@ -177,7 +237,7 @@
271 {
272 Q_D(SpellChecker);
273
274- if (not d->enabled) {
275+ if (not enabled()) {
276 return;
277 }
278
279@@ -191,7 +251,7 @@
280 {
281 Q_D(SpellChecker);
282
283- if (not d->enabled) {
284+ if (not enabled()) {
285 return;
286 }
287
288@@ -203,11 +263,47 @@
289 }
290
291 // Non-zero return value means some error.
292- if (d->hunspell.add(d->codec->fromUnicode(word))) {
293+ if (d->hunspell->add(d->codec->fromUnicode(word))) {
294 qWarning() << __PRETTY_FUNCTION__ << ": Failed to add '" << word << "' to user dictionary.";
295 }
296 }
297
298+//! \brief SpellChecker::setLanguage switches to the given language if possible
299+//! \param language The new language use "en" or "en_US". If more than one
300+//! exists, the first one in the directory listing is used
301+//! \return true if switching the language succeded
302+bool SpellChecker::setLanguage(const QString &language)
303+{
304+ Q_D(SpellChecker);
305+
306+ QDir dictDir(dictPath());
307+ QStringList affMatches = dictDir.entryList(QStringList(language+"*.aff"));
308+ QStringList dicMatches = dictDir.entryList(QStringList(language+"*.dic"));
309+
310+ if (affMatches.isEmpty() || dicMatches.isEmpty()) {
311+ QString lang = language;
312+ lang.truncate(2);
313+ qWarning() << "Did not find a dictionary for" << language << " - checking for " << lang;
314+ if (language.length() > 2) {
315+ return setLanguage(lang);
316+ }
317+
318+ qWarning() << "No dictionary found for" << language << "turning off spellchecking";
319+ d->clear();
320+ return false;
321+ }
322+
323+ d->aff_file = dictPath() + "/" + affMatches[0];
324+ d->dic_file = dictPath() + "/" + dicMatches[0];
325+
326+ if (enabled()) {
327+ setEnabled(false);
328+ return setEnabled(true);
329+ } else {
330+ return true;
331+ }
332+}
333+
334 // static
335 QString SpellChecker::dictPath()
336 {
337
338=== modified file 'src/lib/logic/spellchecker.h'
339--- src/lib/logic/spellchecker.h 2013-07-19 12:05:07 +0000
340+++ src/lib/logic/spellchecker.h 2013-11-14 11:50:58 +0000
341@@ -46,17 +46,21 @@
342 public:
343 // FIXME: Find better way to discover default dictionaries.
344 // FIXME: Allow changing languages in between.
345- explicit SpellChecker(const QString &dictionary_path = QString("%1/en_GB").arg(SpellChecker::dictPath()),
346- const QString &user_dictionary = QString("%1/.config/maliit/userwords.txt").arg(QDir::homePath()));
347+ explicit SpellChecker(const QString &user_dictionary = QString("%1/.config/maliit/userwords.txt").arg(QDir::homePath()));
348
349 ~SpellChecker();
350
351+ bool enabled() const;
352+ bool setEnabled(bool on);
353+
354 bool spell(const QString &word);
355 QStringList suggest(const QString &word,
356 int limit = -1);
357 void ignoreWord(const QString &word);
358 void addToUserWordlist(const QString &word);
359
360+ bool setLanguage(const QString& language);
361+
362 static QString dictPath();
363
364 private:
365
366=== modified file 'src/lib/logic/wordengine.cpp'
367--- src/lib/logic/wordengine.cpp 2013-11-13 15:34:34 +0000
368+++ src/lib/logic/wordengine.cpp 2013-11-14 11:50:58 +0000
369@@ -119,6 +119,7 @@
370 PredictiveBackend predictiveBackend;
371
372 SpellChecker spell_checker;
373+ bool use_spell_checker;
374 #ifdef HAVE_PRESAGE
375 std::string candidates_context;
376 CandidatesCallback presage_candidates;
377@@ -135,6 +136,7 @@
378 WordEnginePrivate::WordEnginePrivate()
379 : predictiveBackend(PresageBackend)
380 , spell_checker()
381+ , use_spell_checker(false)
382 #ifdef HAVE_PRESAGE
383 , candidates_context()
384 , presage_candidates(CandidatesCallback(candidates_context))
385@@ -256,6 +258,15 @@
386 d->spell_checker.addToUserWordlist(word);
387 }
388
389+//! \brief WordEngine::enableSpellcheker turns on/off the usage of the spellchecker
390+//! \param on
391+void WordEngine::enableSpellchecker(bool on)
392+{
393+ Q_D(WordEngine);
394+ d->use_spell_checker = on;
395+ d->spell_checker.setEnabled(d->use_spell_checker);
396+}
397+
398 void WordEngine::onLanguageChanged(const QString &languageId)
399 {
400 Q_D(WordEngine);
401@@ -264,6 +275,10 @@
402 d->predictiveBackend = WordEnginePrivate::PinyinBackend;
403 else
404 d->predictiveBackend = WordEnginePrivate::PresageBackend;
405+
406+ bool ok = d->spell_checker.setLanguage(languageId);
407+ if (ok)
408+ d->spell_checker.setEnabled(d->use_spell_checker);
409 }
410
411 }} // namespace Logic, MaliitKeyboard
412
413=== modified file 'src/lib/logic/wordengine.h'
414--- src/lib/logic/wordengine.h 2013-07-19 12:05:07 +0000
415+++ src/lib/logic/wordengine.h 2013-11-14 11:50:58 +0000
416@@ -57,6 +57,7 @@
417 virtual void setEnabled(bool enabled);
418
419 virtual void addToUserDictionary(const QString &word);
420+ virtual void enableSpellchecker(bool on);
421 //! \reimp_end
422
423 Q_SLOT void onWordCandidateSelected(QString word);
424
425=== modified file 'src/plugin/inputmethod.cpp'
426--- src/plugin/inputmethod.cpp 2013-11-13 15:34:34 +0000
427+++ src/plugin/inputmethod.cpp 2013-11-14 11:50:58 +0000
428@@ -102,6 +102,7 @@
429 d->registerAutoCorrectSetting();
430 d->registerAutoCapsSetting();
431 d->registerWordEngineSetting();
432+ d->registerSpellcheckingSetting();
433 d->registerEnabledLanguages();
434
435 // Setting layout orientation depends on word engine and hide word ribbon
436
437=== modified file 'src/plugin/inputmethod_p.h'
438--- src/plugin/inputmethod_p.h 2013-11-06 14:01:51 +0000
439+++ src/plugin/inputmethod_p.h 2013-11-14 11:50:58 +0000
440@@ -311,27 +311,27 @@
441
442 void registerFeedbackSetting()
443 {
444- QObject::connect(&m_settings, SIGNAL(keyPressFeedbackChanged()),
445+ QObject::connect(&m_settings, SIGNAL(keyPressFeedbackChanged(bool)),
446 q, SLOT(onFeedbackSettingChanged()));
447 feedback.setEnabled(m_settings.keyPressFeedback());
448 }
449
450 void registerAutoCorrectSetting()
451 {
452- QObject::connect(&m_settings, SIGNAL(autoCompletionChanged()),
453+ QObject::connect(&m_settings, SIGNAL(autoCompletionChanged(bool)),
454 q, SLOT(onAutoCorrectSettingChanged()));
455 editor.setAutoCorrectEnabled(m_settings.autoCompletion());
456 }
457
458 void registerAutoCapsSetting()
459 {
460- QObject::connect(&m_settings, SIGNAL(autoCapitalizationChanged()),
461+ QObject::connect(&m_settings, SIGNAL(autoCapitalizationChanged(bool)),
462 q, SLOT(updateAutoCaps()));
463 }
464
465 void registerWordEngineSetting()
466 {
467- QObject::connect(&m_settings, SIGNAL(predictiveTextChanged()),
468+ QObject::connect(&m_settings, SIGNAL(predictiveTextChanged(bool)),
469 q, SLOT(updateWordEngine()));
470 #ifndef DISABLE_PREEDIT
471 editor.wordEngine()->setEnabled(m_settings.predictiveText());
472@@ -340,9 +340,16 @@
473 #endif
474 }
475
476+ void registerSpellcheckingSetting()
477+ {
478+ QObject::connect(&m_settings, SIGNAL(spellCheckingChanged(bool)),
479+ editor.wordEngine(), SLOT(enableSpellchecker(bool)));
480+ editor.wordEngine()->enableSpellchecker(m_settings.spellchecking());
481+ }
482+
483 void registerEnabledLanguages()
484 {
485- QObject::connect(&m_settings, SIGNAL(enabledLanguagesChanged()),
486+ QObject::connect(&m_settings, SIGNAL(enabledLanguagesChanged(QStringList)),
487 q, SLOT(onEnabledLanguageSettingsChanged()));
488 q->onEnabledLanguageSettingsChanged();
489
490
491=== modified file 'src/plugin/keyboardsettings.cpp'
492--- src/plugin/keyboardsettings.cpp 2013-11-05 14:13:52 +0000
493+++ src/plugin/keyboardsettings.cpp 2013-11-14 11:50:58 +0000
494@@ -38,6 +38,7 @@
495 const QLatin1String AUTO_CAPITALIZATION_KEY = QLatin1String("autoCapitalization");
496 const QLatin1String AUTO_COMPLETION_KEY = QLatin1String("autoCompletion");
497 const QLatin1String PREDICTIVE_TEXT_KEY = QLatin1String("predictiveText");
498+const QLatin1String SPELL_CHECKING_KEY = QLatin1String("spellChecking");
499 const QLatin1String KEY_PRESS_FEEDBACK_KEY = QLatin1String("keyPressFeedback");
500
501 /*!
502@@ -95,6 +96,15 @@
503 }
504
505 /*!
506+ * \brief KeyboardSettings::spellchecking returns true if spellchecking should be used
507+ * \return
508+ */
509+bool KeyboardSettings::spellchecking() const
510+{
511+ return m_settings->get(SPELL_CHECKING_KEY).toBool();
512+}
513+
514+/*!
515 * \brief KeyboardSettings::keyPressFeedback returns true if feedback is enabled
516 * when the user presses a keyboad key
517 * \return
518@@ -112,19 +122,22 @@
519 void KeyboardSettings::settingUpdated(const QString &key)
520 {
521 if (key == ENABLED_LANGUAGES_KEY) {
522- Q_EMIT enabledLanguagesChanged();
523+ Q_EMIT enabledLanguagesChanged(enabledLanguages());
524 return;
525 } else if (key == AUTO_CAPITALIZATION_KEY) {
526- Q_EMIT autoCapitalizationChanged();
527+ Q_EMIT autoCapitalizationChanged(autoCapitalization());
528 return;
529 } else if (key == AUTO_COMPLETION_KEY) {
530- Q_EMIT autoCompletionChanged();
531+ Q_EMIT autoCompletionChanged(autoCompletion());
532 return;
533 } else if (key == PREDICTIVE_TEXT_KEY) {
534- Q_EMIT predictiveTextChanged();
535+ Q_EMIT predictiveTextChanged(predictiveText());
536+ return;
537+ } else if (key == SPELL_CHECKING_KEY) {
538+ Q_EMIT spellCheckingChanged(spellchecking());
539 return;
540 } else if (key == KEY_PRESS_FEEDBACK_KEY) {
541- Q_EMIT keyPressFeedbackChanged();
542+ Q_EMIT keyPressFeedbackChanged(keyPressFeedback());
543 return;
544 }
545
546
547=== modified file 'src/plugin/keyboardsettings.h'
548--- src/plugin/keyboardsettings.h 2013-11-05 14:13:52 +0000
549+++ src/plugin/keyboardsettings.h 2013-11-14 11:50:58 +0000
550@@ -47,14 +47,16 @@
551 bool autoCapitalization() const;
552 bool autoCompletion() const;
553 bool predictiveText() const;
554+ bool spellchecking() const;
555 bool keyPressFeedback() const;
556
557 Q_SIGNALS:
558- void enabledLanguagesChanged();
559- void autoCapitalizationChanged();
560- void autoCompletionChanged();
561- void predictiveTextChanged();
562- void keyPressFeedbackChanged();
563+ void enabledLanguagesChanged(QStringList);
564+ void autoCapitalizationChanged(bool);
565+ void autoCompletionChanged(bool);
566+ void predictiveTextChanged(bool);
567+ void spellCheckingChanged(bool);
568+ void keyPressFeedbackChanged(bool);
569
570 private:
571 Q_SLOT void settingUpdated(const QString &key);
572
573=== modified file 'tests/unittests/ut_keyboardsettings/ut_keyboardsettings.cpp'
574--- tests/unittests/ut_keyboardsettings/ut_keyboardsettings.cpp 2013-11-05 14:13:52 +0000
575+++ tests/unittests/ut_keyboardsettings/ut_keyboardsettings.cpp 2013-11-14 11:50:58 +0000
576@@ -63,20 +63,23 @@
577 QTest::addColumn<int>("capitalSpyCount");
578 QTest::addColumn<int>("completionSpyCount");
579 QTest::addColumn<int>("predictSpyCount");
580+ QTest::addColumn<int>("spellSpyCount");
581 QTest::addColumn<int>("feedbackSpyCount");
582
583 QTest::newRow("languages changed") << QString("enabledLanguages")
584- << 1 << 0 << 0 << 0 << 0;
585+ << 1 << 0 << 0 << 0 << 0 << 0;
586 QTest::newRow("capitalization changed") << QString("autoCapitalization")
587- << 0 << 1 << 0 << 0 << 0;
588+ << 0 << 1 << 0 << 0 << 0 << 0;
589 QTest::newRow("completion changed") << QString("autoCompletion")
590- << 0 << 0 << 1 << 0 << 0;
591+ << 0 << 0 << 1 << 0 << 0 << 0;
592 QTest::newRow("predict changed") << QString("predictiveText")
593- << 0 << 0 << 0 << 1 << 0;
594+ << 0 << 0 << 0 << 1 << 0 << 0;
595+ QTest::newRow("spellcheck changed") << QString("spellChecking")
596+ << 0 << 0 << 0 << 0 << 1 << 0;
597 QTest::newRow("feedback changed") << QString("keyPressFeedback")
598- << 0 << 0 << 0 << 0 << 1;
599+ << 0 << 0 << 0 << 0 << 0 << 1;
600 QTest::newRow("unknown changed") << QString("unknownKey")
601- << 0 << 0 << 0 << 0 << 0;
602+ << 0 << 0 << 0 << 0 << 0 << 0;
603 }
604
605 Q_SLOT void testSettingUpdated()
606@@ -86,13 +89,15 @@
607 QFETCH(int, capitalSpyCount);
608 QFETCH(int, completionSpyCount);
609 QFETCH(int, predictSpyCount);
610+ QFETCH(int, spellSpyCount);
611 QFETCH(int, feedbackSpyCount);
612
613- QSignalSpy languagesSpy(m_settings, SIGNAL(enabledLanguagesChanged()));
614- QSignalSpy capitalSpy(m_settings, SIGNAL(autoCapitalizationChanged()));
615- QSignalSpy completionSpy(m_settings, SIGNAL(autoCompletionChanged()));
616- QSignalSpy predictSpy(m_settings, SIGNAL(predictiveTextChanged()));
617- QSignalSpy feedbackSpy(m_settings, SIGNAL(keyPressFeedbackChanged()));
618+ QSignalSpy languagesSpy(m_settings, SIGNAL(enabledLanguagesChanged(QStringList)));
619+ QSignalSpy capitalSpy(m_settings, SIGNAL(autoCapitalizationChanged(bool)));
620+ QSignalSpy completionSpy(m_settings, SIGNAL(autoCompletionChanged(bool)));
621+ QSignalSpy predictSpy(m_settings, SIGNAL(predictiveTextChanged(bool)));
622+ QSignalSpy spellSpy(m_settings, SIGNAL(spellCheckingChanged(bool)));
623+ QSignalSpy feedbackSpy(m_settings, SIGNAL(keyPressFeedbackChanged(bool)));
624
625 m_settings->settingUpdated(key);
626
627@@ -100,6 +105,7 @@
628 QCOMPARE(capitalSpy.count(), capitalSpyCount);
629 QCOMPARE(completionSpy.count(), completionSpyCount);
630 QCOMPARE(predictSpy.count(), predictSpyCount);
631+ QCOMPARE(spellSpy.count(), spellSpyCount);
632 QCOMPARE(feedbackSpy.count(), feedbackSpyCount);
633 }
634 };

Subscribers

People subscribed via source and target branches