Skip to content

Commit 276eba4

Browse files
authored
Merge pull request #16 from sfos-ja/feature-assistlabel
Add assist labels to keyboard layout and a settings config page #8
2 parents c441b2f + 2ab987f commit 276eba4

File tree

10 files changed

+1127
-15
lines changed

10 files changed

+1127
-15
lines changed

diff/original/usr/share/jolla-settings/pages/text_input/textinput.qml

+407
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../../src/textinput.qml

jolla-kbd-flick-jp.pro

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ OTHER_FILES = \
77

88
src.files = \
99
src/Flicker.qml \
10+
src/FlickPopper.qml \
1011
src/layouts
1112
src.path = /usr/share/maliit/plugins/com/jolla
1213

rpm/jolla-kbd-flick-jp.spec

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ rm -rf %{buildroot}
3030

3131
%files
3232
/usr/share/maliit/plugins/com/jolla/Flicker.qml
33+
/usr/share/maliit/plugins/com/jolla/FlickPopper.qml
3334
/usr/share/maliit/plugins/com/jolla/layouts/ja_10key_flick.qml
3435
/usr/share/maliit/plugins/com/jolla/layouts/ja_10key_flick.conf
3536
/usr/share/maliit/plugins/com/jolla/layouts/ja_10key_flick/
@@ -44,5 +45,7 @@ fi
4445
/usr/sbin/patchmanager -u %{name} || true
4546

4647
%changelog
47-
* Wed Mar 2 2017 Topias Vainio <[email protected]> 0.07-1
48-
- Fixed patch for Lemmenjoki 3.0.0 update
48+
* Sun Mar 3 2019 Topias Vainio <[email protected]> 1.0.0-1
49+
- Added assisting labels and poppers to ease users unfamiliar with flick keyboards
50+
- Added settings entries for assist labels and poppers under text input
51+
- Refactoring and code cleanup

src/FlickPopper.qml

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright (C) Jakub Pavelek <[email protected]>
3+
* Copyright (C) 2013 Jolla Ltd.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* Redistributions of source code must retain the above copyright notice, this list
9+
* of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above copyright notice, this list
11+
* of conditions and the following disclaimer in the documentation and/or other materials
12+
* provided with the distribution.
13+
* Neither the name of Nokia Corporation nor the names of its contributors may be
14+
* used to endorse or promote products derived from this software without specific
15+
* prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20+
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*
27+
*/
28+
29+
import QtQuick 2.0
30+
import com.jolla.keyboard 1.0
31+
import Sailfish.Silica 1.0
32+
import org.nemomobile.configuration 1.0
33+
34+
Rectangle {
35+
id: popper
36+
37+
ConfigurationValue {
38+
id: flickPopperConfig
39+
40+
key: "/sailfish/text_input/flick_popper_enabled"
41+
defaultValue: false
42+
}
43+
44+
opacity: 0
45+
color: Qt.darker(Theme.highlightBackgroundColor, 1.2)
46+
height: portraitMode == false ? geometry.keyHeightLandscape
47+
: geometry.keyHeightPortrait
48+
width: portraitMode == false ? geometry.keyboardWidthLandscape / 5
49+
: geometry.keyboardWidthPortrait / 5
50+
radius: geometry.popperRadius
51+
visible: flickPopperConfig.value && popperText !== "" ? true : false
52+
53+
property Item target: null
54+
property int popperIndex
55+
property string popperText: target !== null
56+
? (target.enableFlicker === true
57+
? target.currentText.charAt(popperIndex)
58+
: "")
59+
: ""
60+
61+
onTargetChanged: {
62+
if (target && target.enableFlicker) {
63+
setup()
64+
}
65+
}
66+
67+
PopperCell {
68+
width: parent.width
69+
height: parent.height
70+
character: popperText
71+
active: target === null ? false : target.flickerIndex == popperIndex
72+
}
73+
74+
states: [
75+
State {
76+
name: "active"
77+
when: target !== null && target.enableFlicker
78+
79+
PropertyChanges {
80+
target: popper
81+
opacity: 1
82+
}
83+
}
84+
]
85+
86+
transitions: [
87+
Transition {
88+
from: "active"
89+
to: ""
90+
91+
SequentialAnimation {
92+
PauseAnimation { duration: 20 }
93+
PropertyAction {
94+
target: popper
95+
properties: "opacity"
96+
}
97+
ScriptAction {
98+
script: {
99+
popper.opacity = 0
100+
}
101+
}
102+
}
103+
}
104+
]
105+
106+
function setup() {
107+
// set the popper positions depending on the index position
108+
y = popper.parent.mapFromItem(target, 0, 0).y + (popperIndex == 1 || popperIndex == 3
109+
? 0
110+
: (popperIndex == 2
111+
? -popper.height
112+
: popper.height))
113+
x = popper.parent.mapFromItem(target, 0, 0).x + (popperIndex == 2 || popperIndex == 4
114+
? (target.width - popper.width) / 2
115+
: (popperIndex == 1
116+
? -target.width + (target.width - popper.width)
117+
: target.width))
118+
}
119+
}

src/Flicker.qml

+18-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import QtQuick 2.0
3030
import com.jolla.keyboard 1.0
31+
import Sailfish.Silica 1.0
3132

3233
QtObject {
3334
id: flicker
@@ -42,7 +43,6 @@ QtObject {
4243
}
4344

4445
function setIndex(point) {
45-
4646
var flickerStart = keyboard.mapToItem(target, point.startX, point.startY)
4747
var flickerMoved = keyboard.mapToItem(target, point.x, point.y)
4848
var flickerKeySize = Math.floor(Math.max(target.height, target.width) + Math.min(target.height, target.width)) / 2
@@ -53,6 +53,10 @@ QtObject {
5353
var flickerKeyDiffX = Math.floor(Math.max(flickerKeySize, target.width) - Math.min(flickerKeySize, target.width)) / 2
5454
var flickerKeyDiffY = Math.floor(Math.max(flickerKeySize, target.height) - Math.min(flickerKeySize, target.height)) / 2
5555

56+
var oldIndex = target.flickerIndex
57+
var oldChar = target.currentText.charAt(target.flickerIndex) === ""
58+
? target.currentText.charAt(0)
59+
: target.currentText.charAt(target.flickerIndex)
5660
if (flickerMoved.y > 0-flickerKeyDiffY-flickerKeyOuterY && flickerMoved.y < target.height+flickerKeyDiffY+flickerKeyOuterY && flickerMoved.x < flickerStart.x && flickerStart.x - flickerMoved.x > flickerKeySize * 0.4) {
5761
target.flickerIndex = 1
5862
} else if (flickerMoved.y > 0-flickerKeyDiffY-flickerKeyOuterY && flickerMoved.y < target.height+flickerKeyDiffY+flickerKeyOuterY && flickerMoved.x > flickerStart.x && flickerMoved.x - flickerStart.x > flickerKeySize * 0.4){
@@ -65,9 +69,21 @@ QtObject {
6569
target.flickerIndex = 0
6670
}
6771

72+
if (target.flickerEnabled) {
73+
for (var i = 0; i < 5 ; i++) {
74+
flickerPoppers.itemAt(i).setup()
75+
}
76+
}
77+
78+
if (oldIndex !== target.flickerIndex
79+
&& oldChar !== target.currentText.charAt(target.flickerIndex)
80+
&& target.currentText.charAt(target.flickerIndex) !== "") {
81+
SampleCache.play("/usr/share/sounds/jolla-ambient/stereo/keyboard_letter.wav")
82+
buttonPressEffect.play()
83+
}
84+
6885
if (target.showPopper) {
6986
popper.setup()
7087
}
71-
7288
}
7389
}

src/KeyboardBase_Flick.qml

+10
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ SwipeGestureArea {
110110
}
111111
}
112112

113+
Repeater {
114+
id: flickerPoppers
115+
model: 4
116+
FlickPopper {
117+
z: 10
118+
target: lastPressedKey
119+
popperIndex: index + 1
120+
}
121+
}
122+
113123
Popper {
114124
id: popper
115125
z: 10
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import QtQuick 2.0
2+
import Sailfish.Silica 1.0
3+
import com.jolla.keyboard 1.0
4+
5+
Text {
6+
property int keyIndex
7+
property real offset: (parent.width - Theme.paddingMedium * 1.5) / 3
8+
property string labelText
9+
visible: portraitMode && !pressed
10+
horizontalAlignment: Text.AlignHCenter
11+
verticalAlignment: Text.AlignVCenter
12+
anchors {
13+
verticalCenter: parent.verticalCenter
14+
horizontalCenter: parent.horizontalCenter
15+
horizontalCenterOffset: keyIndex == 2 || keyIndex == 4
16+
? 0
17+
: (keyIndex == 1
18+
? -offset
19+
: offset)
20+
verticalCenterOffset: keyIndex == 1 || keyIndex == 3
21+
? 0
22+
: (keyIndex == 2
23+
? -offset
24+
: offset)
25+
}
26+
font.family: Theme.fontFamily
27+
font.pixelSize: !portraitMode && attributes.isShifted
28+
? Theme.fontSizeSmall
29+
: Theme.fontSizeExtraSmall
30+
color: pressed ? Theme.highlightColor : Theme.secondaryColor
31+
text: portraitMode && flickerIndex == 0
32+
? labelText.charAt(keyIndex)
33+
: ""
34+
}

0 commit comments

Comments
 (0)