~michael-sheldon/ubuntu-keyboard/suggestion-override

« back to all changes in this revision

Viewing changes to src/view/abstracttexteditor.cpp

  • Committer: CI bot
  • Author(s): Michael Sheldon
  • Date: 2014-04-07 15:01:33 UTC
  • mfrom: (150.1.1 fix-1289374)
  • Revision ID: ps-jenkins@lists.canonical.com-20140407150133-ihjp7x1f9hd3v2pg
Gradually decreases the interval between word deletion when backspace is held down, allowing for fast deletion of large blocks of text (fixes bug #1289374). Fixes: 1289374

Show diffs side-by-side

added added

removed removed

Lines of Context:
266
266
    , backspace_auto_repeat_interval(200)
267
267
    , backspace_word_delay(3000)
268
268
    , backspace_word_interval(400)
 
269
    , backspace_word_acceleration_rate(10)
 
270
    , backspace_word_min_interval(50)
269
271
{}
270
272
 
271
273
class AbstractTextEditorPrivate
282
284
    bool auto_caps_enabled;
283
285
    int ignore_next_cursor_position;
284
286
    QString ignore_next_surrounding_text;
 
287
    int backspace_word_acceleration;
285
288
 
286
289
    explicit AbstractTextEditorPrivate(const EditorOptions &new_options,
287
290
                                       Model::Text *new_text,
302
305
    , auto_caps_enabled(false)
303
306
    , ignore_next_cursor_position(-1)
304
307
    , ignore_next_surrounding_text()
 
308
    , backspace_word_acceleration(0)
305
309
{
306
310
    auto_repeat_backspace_timer.setSingleShot(true);
307
311
    (void) valid();
675
679
    if (d->backspace_hold_timer.elapsed() < d->options.backspace_word_delay) {
676
680
        singleBackspace();
677
681
        d->auto_repeat_backspace_timer.start(d->options.backspace_auto_repeat_interval);
 
682
        d->backspace_word_acceleration = 0;
678
683
    } else {
679
684
        autoRepeatWordBackspace();
680
685
    }
696
701
        singleBackspace();
697
702
    }
698
703
 
699
 
    d->auto_repeat_backspace_timer.start(d->options.backspace_word_interval);
 
704
    // Gradually speed up deletion to allow for deleting large blocks of text
 
705
    if (d->options.backspace_word_interval - d->backspace_word_acceleration > d->options.backspace_word_min_interval) {
 
706
        d->backspace_word_acceleration += d->options.backspace_word_acceleration_rate;
 
707
    }
 
708
 
 
709
    d->auto_repeat_backspace_timer.start(d->options.backspace_word_interval - d->backspace_word_acceleration);
700
710
}
701
711
 
702
712
/*!