#7430 add check for first document language for the spell checker and initialize the language combo accordingly on open

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38294 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2011-04-06 18:26:50 +00:00
parent ae5d64908e
commit 01a21a60b5

View File

@ -70,6 +70,8 @@ struct SpellcheckerWidget::Private
///
bool continueFromBeginning();
///
void setLanguage(Language const * lang);
///
Ui::SpellcheckerUi ui;
///
SpellcheckerWidget * p;
@ -159,8 +161,16 @@ void SpellcheckerWidget::updateView()
{
BufferView * bv = d->gv_->documentBufferView();
setEnabled(bv != 0);
if (bv && hasFocus())
if (bv && hasFocus()) {
BufferView * bv = d->gv_->documentBufferView();
std::set<Language const *> languages =
bv->buffer().masterBuffer()->getLanguages();
if (!languages.empty())
d->setLanguage(*languages.begin());
d->check();
}
}
@ -288,6 +298,14 @@ void SpellcheckerWidget::Private::updateSuggestions(docstring_list & words)
}
void SpellcheckerWidget::Private::setLanguage(Language const * lang)
{
int const pos = ui.languageCO->findData(toqstr(lang->lang()));
if (pos != -1)
ui.languageCO->setCurrentIndex(pos);
}
void SpellcheckerWidget::Private::check()
{
BufferView * bv = gv_->documentBufferView();
@ -322,9 +340,7 @@ void SpellcheckerWidget::Private::check()
// set suggestions
updateSuggestions(suggestions);
// set language
int const pos = ui.languageCO->findData(toqstr(word_lang.lang()->lang()));
if (pos != -1)
ui.languageCO->setCurrentIndex(pos);
setLanguage(word_lang.lang());
// FIXME LFUN
// If we used a LFUN, dispatch would do all of this for us