From 3b3d9cc7d5ce89fd0bd372840df15ebd6b486304 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 19 Apr 2024 20:55:18 +0300 Subject: [PATCH] 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 --- .../runners/spellchecker/spellcheck.cpp | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/kdeplasma-addons/runners/spellchecker/spellcheck.cpp b/kdeplasma-addons/runners/spellchecker/spellcheck.cpp index 2dda63bf..7c2688ac 100644 --- a/kdeplasma-addons/runners/spellchecker/spellcheck.cpp +++ b/kdeplasma-addons/runners/spellchecker/spellcheck.cpp @@ -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); } }