~michael-sheldon/ubuntu-keyboard/email-detection

« back to all changes in this revision

Viewing changes to src/plugin/inputmethod.cpp

  • Committer: CI bot
  • Author(s): Michael Sheldon
  • Date: 2014-10-10 13:50:57 UTC
  • mfrom: (231.1.5 fix-1375951)
  • Revision ID: ps-jenkins@lists.canonical.com-20141010135057-bv4nqyj09uh8fi81
Fix re-entry of preedit when in the middle of a sentence, disable preedit when editing in the middle of a word and re-evaluate autocaps whenever the cursor position changes. Fixes: 1375951
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
370
370
        d->editor.text()->setSurroundingOffset(position);
371
371
 
372
372
        updateAutoCaps();
373
 
        checkInitialAutocaps();
 
373
        checkAutocaps();
374
374
        d->previous_position = position;
375
375
    }
376
376
}
412
412
    updateAutoCaps();
413
413
}
414
414
 
415
 
//! \brief InputMethod::checkInitialAutocaps  Checks if the keyboard should be
416
 
//! set to uppercase, because the auto caps is enabled and the text is empty.
417
 
void InputMethod::checkInitialAutocaps()
 
415
//! \brief InputMethod::checkAutocaps  Checks if the keyboard should be
 
416
//! set to uppercase after the cursor position has been changed.
 
417
void InputMethod::checkAutocaps()
418
418
{
419
419
    Q_D(InputMethod);
420
420
 
422
422
        QString text;
423
423
        int position;
424
424
        bool ok = d->host->surroundingText(text, position);
425
 
        QString textOnLeft = (d->editor.text()->surroundingLeft() + d->editor.text()->preedit()).trimmed();
426
 
        if (ok && text.isEmpty() && d->editor.text()->preedit().isEmpty() && position == 0) {
 
425
        QString textOnLeft = d->editor.text()->surroundingLeft() + d->editor.text()->preedit();
 
426
        if (ok && ((text.isEmpty() && d->editor.text()->preedit().isEmpty() && position == 0) 
 
427
                || d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft)
 
428
                || d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft.trimmed()))) {
427
429
            Q_EMIT activateAutocaps();
428
 
        } else if (!d->editor.wordEngine()->languageFeature()->activateAutoCaps(textOnLeft)) {
429
 
            // Clear autocaps if it has been set by us previously being in an
430
 
            // empty field
 
430
        } else {
431
431
            Q_EMIT deactivateAutocaps();
432
432
        }
433
433
    }