kdeplasma-addons: add match for each suggestion from spellchecker runner

that way what is copied is not a list of suggestions but a chosen
suggestion

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-19 20:55:18 +03:00
parent 1d88215e87
commit 3b3d9cc7d5

View file

@ -93,25 +93,33 @@ void SpellCheckRunner::match(Plasma::RunnerContext &context)
foreach (const QString &word, terms) {
Plasma::QueryMatch match(this);
const bool correct = m_speller->check(word);
if (correct) {
Plasma::QueryMatch match(this);
match.setIcon(KIcon(QLatin1String("checkbox")));
match.setText(i18n("Correct: ") + word);
match.setEnabled(false);
} else {
const QStringList suggestions = m_speller->suggest(word);
match.setIcon(KIcon(QLatin1String("edit-delete")));
if (suggestions.isEmpty()) {
match.setText(i18n("Incorrect but no suggestions for: %1", word));
match.setEnabled(false);
} else {
const QString recommended = i18n("Suggested words: %1", suggestions.join(i18nc("seperator for a list of words", ", ")));
match.setText(recommended);
match.setData(suggestions);
}
context.addMatch(match);
continue;
}
const QStringList suggestions = m_speller->suggest(word);
if (suggestions.isEmpty()) {
Plasma::QueryMatch match(this);
match.setIcon(KIcon(QLatin1String("edit-delete")));
match.setText(i18n("Incorrect but no suggestions for: %1", word));
match.setEnabled(false);
context.addMatch(match);
continue;
}
foreach (const QString &suggestion, suggestions) {
Plasma::QueryMatch match(this);
match.setIcon(KIcon(QLatin1String("edit-delete")));
match.setText(i18n("Suggested words: %1", suggestion));
match.setData(suggestion);
context.addMatch(match);
}
context.addMatch(match);
}
}