| 1 |
/* |
| 2 |
* Copyright 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import QtMultimedia 5.0 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Lomiri.Components.Popups 1.3 |
| 21 |
|
| 22 |
import keys 1.0 |
| 23 |
|
| 24 |
FlickCharKey { |
| 25 |
padding: UI.actionKeyPadding |
| 26 |
label: kana.label |
| 27 |
leaves: ["↻", "", "あ", "A"] |
| 28 |
normalColor: fullScreenItem.theme.actionKeyColor |
| 29 |
pressedColor: fullScreenItem.theme.actionKeyPressedColor |
| 30 |
borderColor: fullScreenItem.theme.actionKeyBorderColor |
| 31 |
|
| 32 |
overridePressArea: true |
| 33 |
|
| 34 |
property bool isPreedit: maliit_input_method.preedit.length > 0 |
| 35 |
property string default_state: "kana" |
| 36 |
|
| 37 |
state: kana.state |
| 38 |
|
| 39 |
Item { |
| 40 |
id: kana |
| 41 |
property string label: "あ/A" |
| 42 |
|
| 43 |
state: parent.default_state; |
| 44 |
states: [ |
| 45 |
State { |
| 46 |
name: "kana" |
| 47 |
PropertyChanges { |
| 48 |
target: kana; |
| 49 |
label: "<font color=\"" + fullScreenItem.theme.selectionColor + "\">あ</font>/A"; |
| 50 |
state: "kana"; |
| 51 |
} |
| 52 |
}, |
| 53 |
State { |
| 54 |
name: "alnum" |
| 55 |
PropertyChanges { |
| 56 |
target: kana; |
| 57 |
label: "あ/<font color=\"" + fullScreenItem.theme.selectionColor + "\">A</font>"; |
| 58 |
state: "alnum"; |
| 59 |
} |
| 60 |
} |
| 61 |
] |
| 62 |
} |
| 63 |
|
| 64 |
onReleased: { |
| 65 |
if (isPreedit) { |
| 66 |
event_handler.onKeyReleased("", "commit"); |
| 67 |
} |
| 68 |
if (index == 0) { |
| 69 |
kana.state = kana.state == "kana" ? "alnum" : "kana" |
| 70 |
} else { |
| 71 |
if (index == 2) { |
| 72 |
kana.state = "kana" |
| 73 |
} else if (index == 3) { |
| 74 |
kana.state = "alnum" |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
onPressed: { |
| 80 |
if (maliit_input_method.useAudioFeedback) |
| 81 |
audioFeedback.play(); |
| 82 |
|
| 83 |
if (maliit_input_method.useHapticFeedback) |
| 84 |
pressEffect.start(); |
| 85 |
} |
| 86 |
} |