mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
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:
parent
1d88215e87
commit
3b3d9cc7d5
1 changed files with 21 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue