From fef95cecbdc6e2127fd34aa369e0486243b9028d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 9 Feb 2010 13:01:37 +0000 Subject: [PATCH] Add language selector to the spell chekcer dialog (bug 2208). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33381 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiSpellchecker.cpp | 23 ++++++++++ src/frontends/qt4/GuiSpellchecker.h | 1 + src/frontends/qt4/ui/SpellcheckerUi.ui | 60 ++++++++++++++++++-------- 3 files changed, 66 insertions(+), 18 deletions(-) diff --git a/src/frontends/qt4/GuiSpellchecker.cpp b/src/frontends/qt4/GuiSpellchecker.cpp index 10edda4462..7fc734a58a 100644 --- a/src/frontends/qt4/GuiSpellchecker.cpp +++ b/src/frontends/qt4/GuiSpellchecker.cpp @@ -13,6 +13,7 @@ #include #include "GuiSpellchecker.h" +#include "GuiApplication.h" #include "qt_helpers.h" @@ -77,6 +78,12 @@ GuiSpellchecker::GuiSpellchecker(GuiView & lv) connect(d->ui.suggestionsLW, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(on_replacePB_clicked())); + // language + QAbstractItemModel * language_model = guiApp->languageModel(); + // FIXME: it would be nice if sorting was enabled/disabled via a checkbox. + language_model->sort(0); + d->ui.languageCO->setModel(language_model); + d->ui.wordED->setReadOnly(true); d->ui.suggestionsLW->installEventFilter(this); @@ -146,6 +153,18 @@ void GuiSpellchecker::updateView() } +void GuiSpellchecker::on_languageCO_activated(int index) +{ + string const lang = + fromqstr(d->ui.languageCO->itemData(index).toString()); + if (d->word_.lang()->lang() == lang) + // nothing changed + return; + dispatch(FuncRequest(LFUN_LANGUAGE, lang)); + check(); +} + + void GuiSpellchecker::on_ignoreAllPB_clicked() { /// replace all occurances of word @@ -283,6 +302,10 @@ void GuiSpellchecker::check() d->ui.spellcheckPR->setValue(progress_bar); // set suggestions updateSuggestions(suggestions); + // set language + int const pos = d->ui.languageCO->findData(toqstr(word_lang.lang()->lang())); + if (pos != -1) + d->ui.languageCO->setCurrentIndex(pos); // FIXME: if we used a lfun like in find/replace, dispatch would do // that for us diff --git a/src/frontends/qt4/GuiSpellchecker.h b/src/frontends/qt4/GuiSpellchecker.h index 937d4f294b..c460c0beba 100644 --- a/src/frontends/qt4/GuiSpellchecker.h +++ b/src/frontends/qt4/GuiSpellchecker.h @@ -39,6 +39,7 @@ private Q_SLOTS: void on_replaceAllPB_clicked(); void on_suggestionsLW_itemClicked(QListWidgetItem *); void on_replaceCO_highlighted(const QString & str); + void on_languageCO_activated(int index); void on_ignoreAllPB_clicked(); void on_addPB_clicked(); void on_ignorePB_clicked(); diff --git a/src/frontends/qt4/ui/SpellcheckerUi.ui b/src/frontends/qt4/ui/SpellcheckerUi.ui index 8c6eddb7f8..dd07aebe19 100644 --- a/src/frontends/qt4/ui/SpellcheckerUi.ui +++ b/src/frontends/qt4/ui/SpellcheckerUi.ui @@ -6,7 +6,7 @@ 0 0 259 - 506 + 528 @@ -21,23 +21,30 @@ 6 - + - Unknown word: + &Language: - wordED + languageCO - + + + + The checked language. Switching this alters the language of the checked word. + + + + Current word - + Replace word with current choice @@ -47,7 +54,7 @@ - + Re&placement: @@ -57,7 +64,7 @@ - + @@ -87,7 +94,7 @@ - + Replace word with current choice @@ -97,7 +104,7 @@ - + S&uggestions: @@ -107,7 +114,7 @@ - + Replace word with current choice @@ -117,10 +124,10 @@ - + - + Ignore this word @@ -130,7 +137,7 @@ - + Ignore this word throughout this session @@ -140,7 +147,7 @@ - + Add the word to your personal dictionary @@ -150,7 +157,7 @@ - + Qt::Vertical @@ -166,7 +173,7 @@ - + 24 @@ -176,13 +183,30 @@ - + &Close + + + + Unknown word: + + + wordED + + + + + + + Qt::Horizontal + + + -- 2.39.2