Merge lp:~michael-sheldon/ubuntu-keyboard/swipe-cursor-vivid into lp:ubuntu-keyboard/vivid

Proposed by Michael Sheldon
Status: Needs review
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/swipe-cursor-vivid
Merge into: lp:ubuntu-keyboard/vivid
Diff against target: 196 lines (+119/-1)
4 files modified
qml/Keyboard.qml (+67/-1)
qml/keys/SpaceKey.qml (+35/-0)
src/plugin/inputmethod.cpp (+12/-0)
src/plugin/inputmethod.h (+5/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/swipe-cursor-vivid
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+314333@code.launchpad.net

Commit message

Implement swipe based cursor movement after long pressing on the space key

Description of the change

Implement swipe based cursor movement after long pressing on the space key

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

Implement swipe based cursor movement after long pressing on the space key

528. By Michael Sheldon

Fix position calculation for swipe cursor movement after releasing and swiping a second time

529. By Michael Sheldon

Wait until cursor movement has stopped to trigger autocaps

530. By Michael Sheldon

Reduce cursor swipe timeout duration to 400ms

Unmerged revisions

530. By Michael Sheldon

Reduce cursor swipe timeout duration to 400ms

529. By Michael Sheldon

Wait until cursor movement has stopped to trigger autocaps

528. By Michael Sheldon

Fix position calculation for swipe cursor movement after releasing and swiping a second time

527. By Michael Sheldon

Implement swipe based cursor movement after long pressing on the space key

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Keyboard.qml'
2--- qml/Keyboard.qml 2016-08-02 12:05:45 +0000
3+++ qml/Keyboard.qml 2017-01-11 14:04:26 +0000
4@@ -42,6 +42,12 @@
5 property bool landscape: width > height
6 readonly property bool tablet: landscape ? width >= units.gu(90) : height >= units.gu(90)
7
8+ property bool cursorSwipe: false
9+ property int prevSwipePositionX
10+ property int prevSwipePositionY
11+ property int cursorSwipeDuration: 400
12+ property var timerSwipe: swipeTimer
13+
14 property variant input_method: maliit_input_method
15 property variant event_handler: maliit_event_handler
16
17@@ -253,7 +259,7 @@
18 Connections {
19 target: input_method
20 onActivateAutocaps: {
21- if (keypad.state == "CHARACTERS" && keypad.activeKeypadState != "CAPSLOCK") {
22+ if (keypad.state == "CHARACTERS" && keypad.activeKeypadState != "CAPSLOCK" && !cursorSwipe) {
23 keypad.activeKeypadState = "SHIFTED";
24 keypad.autoCapsTriggered = true;
25 } else {
26@@ -273,8 +279,51 @@
27 }
28 }
29
30+ MouseArea {
31+ id: cursorSwipeArea
32+ anchors.fill: parent
33+ enabled: cursorSwipe
34+
35+ Rectangle {
36+ anchors.fill: parent
37+ visible: parent.enabled
38+ color: UI.charKeyPressedColor
39+ opacity: 0.5
40+ }
41+
42+ onMouseXChanged: {
43+ processSwipe(mouseX, mouseY)
44+ }
45+
46+ onPressed: {
47+ prevSwipePositionX = mouseX
48+ prevSwipePositionY = mouseY
49+ fullScreenItem.timerSwipe.stop()
50+ }
51+
52+ onReleased: {
53+ fullScreenItem.timerSwipe.restart()
54+ }
55+ }
56+
57 } // canvas
58
59+ Timer {
60+ id: swipeTimer
61+ interval: cursorSwipeDuration
62+ running: false
63+ onTriggered: {
64+ fullScreenItem.cursorSwipe = false
65+ // We only enable autocaps after cursor movement has stopped
66+ if (keypad.delayedAutoCaps) {
67+ keypad.activeKeypadState = "SHIFTED"
68+ keypad.delayedAutoCaps = false
69+ } else {
70+ keypad.activeKeypadState = "NORMAL"
71+ }
72+ }
73+ }
74+
75 function reportKeyboardVisibleRect() {
76
77 var vx = 0;
78@@ -318,4 +367,21 @@
79 event_handler.onKeyReleased("", "end");
80 }
81
82+ function processSwipe(positionX, positionY) {
83+ if (positionX < prevSwipePositionX - units.gu(1) && input_method.surroundingLeft != "") {
84+ sendLeftKey();
85+ prevSwipePositionX = positionX
86+ } else if (positionX > prevSwipePositionX + units.gu(1) && input_method.surroundingRight != "") {
87+ sendRightKey();
88+ prevSwipePositionX = positionX
89+ }
90+ if (positionY < prevSwipePositionY - units.gu(4)) {
91+ sendUpKey();
92+ prevSwipePositionY = positionY
93+ } else if (positionY > prevSwipePositionY + units.gu(4)) {
94+ sendDownKey();
95+ prevSwipePositionY = positionY
96+ }
97+ }
98+
99 } // fullScreenItem
100
101=== modified file 'qml/keys/SpaceKey.qml'
102--- qml/keys/SpaceKey.qml 2016-04-18 15:23:00 +0000
103+++ qml/keys/SpaceKey.qml 2017-01-11 14:04:26 +0000
104@@ -30,6 +30,8 @@
105 action: "space"
106 switchBackFromSymbols: true
107
108+ overridePressArea: true
109+
110 Label {
111 anchors.centerIn: parent
112 anchors.verticalCenterOffset: -parent.rowMargin / 2 - units.gu(0.15)
113@@ -40,4 +42,37 @@
114 text: Languages.languageIdToName(maliit_input_method.activeLanguage)
115 horizontalAlignment: Text.AlignHCenter
116 }
117+
118+ MouseArea {
119+ id: swipeArea
120+ anchors.fill: parent
121+
122+ onPressAndHold: {
123+ fullScreenItem.cursorSwipe = true
124+ spaceKey.currentlyPressed = false
125+ }
126+
127+ onPressed: {
128+ spaceKey.currentlyPressed = true
129+ fullScreenItem.timerSwipe.stop()
130+ }
131+ onReleased: {
132+ if (fullScreenItem.cursorSwipe) {
133+ fullScreenItem.timerSwipe.restart()
134+ } else {
135+ spaceKey.currentlyPressed = false
136+ event_handler.onKeyReleased("", "space")
137+ if (switchBackFromSymbols && panel.state === "SYMBOLS") {
138+ panel.state = "CHARACTERS"
139+ }
140+ }
141+ }
142+
143+ onMouseXChanged: {
144+ if (fullScreenItem.cursorSwipe) {
145+ fullScreenItem.processSwipe(mouseX, mouseY);
146+ }
147+ }
148+ }
149+
150 }
151
152=== modified file 'src/plugin/inputmethod.cpp'
153--- src/plugin/inputmethod.cpp 2016-10-12 12:43:45 +0000
154+++ src/plugin/inputmethod.cpp 2017-01-11 14:04:26 +0000
155@@ -670,6 +670,18 @@
156 d->editor.setCursorPosition(pos);
157 }
158
159+QString InputMethod::surroundingLeft()
160+{
161+ Q_D(InputMethod);
162+ return d->editor.text()->surroundingLeft();
163+}
164+
165+QString InputMethod::surroundingRight()
166+{
167+ Q_D(InputMethod);
168+ return d->editor.text()->surroundingRight();
169+}
170+
171 bool InputMethod::languageIsSupported(const QString plugin) {
172 Q_D(const InputMethod);
173 foreach(QString pluginPath, d->pluginPaths) {
174
175=== modified file 'src/plugin/inputmethod.h'
176--- src/plugin/inputmethod.h 2015-08-15 06:10:39 +0000
177+++ src/plugin/inputmethod.h 2017-01-11 14:04:26 +0000
178@@ -61,6 +61,8 @@
179 Q_PROPERTY(QString currentPluginPath READ currentPluginPath NOTIFY currentPluginPathChanged)
180 Q_PROPERTY(QString preedit READ preedit WRITE replacePreedit NOTIFY preeditChanged)
181 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
182+ Q_PROPERTY(QString surroundingLeft READ surroundingLeft)
183+ Q_PROPERTY(QString surroundingRight READ surroundingRight)
184
185 Q_ENUMS(TextContentType)
186
187@@ -135,6 +137,9 @@
188
189 QObject* actionKeyOverride() const;
190
191+ QString surroundingLeft();
192+ QString surroundingRight();
193+
194 Q_SLOT void close();
195
196 Q_INVOKABLE bool languageIsSupported(const QString plugin);

Subscribers

People subscribed via source and target branches