kdeplasma-addons: start with new query match object for each word in spellchecker runner

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-08 11:03:48 +03:00
parent eee781dc85
commit 760ba3b708

View file

@ -75,9 +75,6 @@ void SpellCheckRunner::match(Plasma::RunnerContext &context)
terms.removeFirst();
}
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch);
QString spellerdictionary;
if (terms.size() > 1 && m_speller->dictionaries().contains(terms.at(0))) {
spellerdictionary = terms.at(0);
@ -86,6 +83,8 @@ void SpellCheckRunner::match(Plasma::RunnerContext &context)
spellerdictionary = KSpeller::defaultLanguage();
}
if (!m_speller->setDictionary(spellerdictionary)) {
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch);
match.setIcon(KIcon(QLatin1String("task-attention")));
match.setText(i18n("Could not find a dictionary."));
context.addMatch(term, match);
@ -94,6 +93,8 @@ void SpellCheckRunner::match(Plasma::RunnerContext &context)
foreach (const QString &word, terms) {
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch);
const bool correct = m_speller->check(word);
if (correct) {
match.setIcon(KIcon(QLatin1String("checkbox")));
@ -109,9 +110,8 @@ void SpellCheckRunner::match(Plasma::RunnerContext &context)
match.setData(suggestions);
}
}
context.addMatch(term, match);
}
context.addMatch(term, match);
}
void SpellCheckRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)