Merge lp:~michael-sheldon/ubuntu-keyboard/fix-1347488 into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Merged
Approved by: Bill Filler
Approved revision: 258
Merged at revision: 278
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/fix-1347488
Merge into: lp:ubuntu-keyboard
Diff against target: 126 lines (+28/-7)
2 files modified
src/view/abstracttexteditor.cpp (+25/-6)
src/view/abstracttexteditor.h (+3/-1)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/fix-1347488
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+245830@code.launchpad.net

Commit message

Speed up individual backspaces and switch between individual and word backspace based on 3 words having been deleted instead of 3 seconds having passed.

Description of the change

Speed up individual backspaces and switch between individual and word backspace based on 3 words having been deleted instead of 3 seconds having passed.

To post a comment you must log in.
258. By Michael Sheldon

Merge from trunk

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Are there any related MPs required for this MP to build/function as expected? Please list.

 * No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)

 * Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?

 * Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/ubuntu-keyboard) on device or emulator?

 * Yes

If you changed the UI, was the change specified/approved by design?

 * No change

If you changed UI labels, did you update the pot file?

 * No change

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?

 * No change

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

works much better, nice job

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/view/abstracttexteditor.cpp'
2--- src/view/abstracttexteditor.cpp 2014-12-04 17:44:17 +0000
3+++ src/view/abstracttexteditor.cpp 2015-01-08 10:29:34 +0000
4@@ -264,7 +264,9 @@
5 EditorOptions::EditorOptions()
6 : backspace_auto_repeat_delay(500)
7 , backspace_auto_repeat_interval(200)
8- , backspace_word_delay(3000)
9+ , backspace_auto_repeat_acceleration_rate(10)
10+ , backspace_auto_repeat_min_interval(50)
11+ , backspace_word_switch_threshold(3)
12 , backspace_word_interval(400)
13 , backspace_word_acceleration_rate(10)
14 , backspace_word_min_interval(50)
15@@ -274,7 +276,6 @@
16 {
17 public:
18 QTimer auto_repeat_backspace_timer;
19- QElapsedTimer backspace_hold_timer;
20 bool backspace_sent;
21 bool repeating_backspace;
22 EditorOptions options;
23@@ -289,7 +290,9 @@
24 bool double_space_full_stop_enabled;
25 bool editing_middle_of_text;
26 QString appendix_for_previous_preedit;
27+ int backspace_acceleration;
28 int backspace_word_acceleration;
29+ int deleted_words;
30 QString keyboardState;
31
32 explicit AbstractTextEditorPrivate(const EditorOptions &new_options,
33@@ -316,7 +319,9 @@
34 , double_space_full_stop_enabled(false)
35 , editing_middle_of_text(false)
36 , appendix_for_previous_preedit()
37+ , backspace_acceleration(0)
38 , backspace_word_acceleration(0)
39+ , deleted_words(0)
40 , keyboardState("CHARACTERS")
41 {
42 auto_repeat_backspace_timer.setSingleShot(true);
43@@ -405,7 +410,7 @@
44 if (key.action() == Key::ActionBackspace) {
45 d->backspace_sent = false;
46 d->auto_repeat_backspace_timer.start(d->options.backspace_auto_repeat_delay);
47- d->backspace_hold_timer.restart();
48+ d->deleted_words = 0;
49 }
50 }
51
52@@ -522,6 +527,7 @@
53
54 d->auto_repeat_backspace_timer.stop();
55 d->repeating_backspace = false;
56+ d->backspace_acceleration = 0;
57 } break;
58
59 case Key::ActionSpace: {
60@@ -856,12 +862,18 @@
61
62 d->repeating_backspace = true;
63
64- if (d->backspace_hold_timer.elapsed() < d->options.backspace_word_delay) {
65+ if (d->deleted_words < d->options.backspace_word_switch_threshold) {
66 singleBackspace();
67- d->auto_repeat_backspace_timer.start(d->options.backspace_auto_repeat_interval);
68+
69+ // Gradually speed up single letter deletion
70+ if(d->options.backspace_auto_repeat_interval - d->backspace_acceleration > d->options.backspace_auto_repeat_min_interval) {
71+ d->backspace_acceleration += d->options.backspace_auto_repeat_acceleration_rate;
72+ }
73+ d->auto_repeat_backspace_timer.start(d->options.backspace_auto_repeat_interval - d->backspace_acceleration);
74 d->backspace_word_acceleration = 0;
75 } else {
76 autoRepeatWordBackspace();
77+ d->backspace_acceleration = 0;
78 }
79 }
80
81@@ -934,15 +946,17 @@
82 void AbstractTextEditor::singleBackspace()
83 {
84 Q_D(AbstractTextEditor);
85-
86+ bool in_word = false;
87 QString textOnLeft = d->text->surroundingLeft();
88
89 if (d->text->preedit().isEmpty()) {
90+ in_word = textOnLeft.right(1) != " ";
91 sendKeyPressAndReleaseEvents(Qt::Key_Backspace, Qt::NoModifier);
92 // Deletion of surrounding text isn't updated in the model until later
93 // Update it locally here for autocaps detection
94 textOnLeft.chop(1);
95 } else {
96+ in_word = true;
97 d->text->removeFromPreedit(1);
98 textOnLeft += d->text->preedit();
99
100@@ -962,6 +976,11 @@
101 }
102 }
103
104+ if (in_word && textOnLeft.right(1) == " ") {
105+ // We were in a word, but now we're not, so we've just finished deleting a word
106+ d->deleted_words++;
107+ }
108+
109 textOnLeft = textOnLeft.trimmed();
110
111 const bool auto_caps_activated = d->word_engine->languageFeature()->activateAutoCaps(textOnLeft);
112
113=== modified file 'src/view/abstracttexteditor.h'
114--- src/view/abstracttexteditor.h 2014-11-26 15:02:05 +0000
115+++ src/view/abstracttexteditor.h 2015-01-08 10:29:34 +0000
116@@ -48,7 +48,9 @@
117 // all delays are in milliseconds
118 int backspace_auto_repeat_delay; // delay before first automatically repeated key
119 int backspace_auto_repeat_interval; // interval between automatically repeated keys
120- int backspace_word_delay; // delay before first automatically delete whole words
121+ int backspace_auto_repeat_acceleration_rate; // rate at which to accelerate key repetition
122+ int backspace_auto_repeat_min_interval; // minimum interval between repeating keys
123+ int backspace_word_switch_threshold; // switch to deleting whole words after we've deleted a certain number of words via single backspaces
124 int backspace_word_interval; // interval between deleting word on while pressing the backspace
125 int backspace_word_acceleration_rate; // rate at which to accelerate word deletion
126 int backspace_word_min_interval; // minimum interval between deleting words after acceleration

Subscribers

People subscribed via source and target branches