2
import "utils.js" as Utils
9
/*color : "#FFFF0000"*/
11
property int keyWidth : 80
12
property int keyHeight : 60
13
property int numKeyWidth : 80
14
property int numKeyHeight : 60
16
property bool useIKey_l : true
17
property Item pressedKey
18
property alias backspaceKey : key_backspace
20
/*keyWidth : 800 / 10 * 1.010*/
21
/*keyHeight : keyWidth * 0.975*/
26
function updateCandString() {
27
engine.updateCandidate( 0 )
28
key_5_6.candString = engine.getWord()
30
/*preedit.preeditString = engine.getPreeditCode()*/
31
/*preedit.invaildCode = engine.getInvalidCode()*/
32
/*preedit.selectedWord = engine.getSelectedWord()*/
34
engine.updateCandidate( 1 )
35
key_3_4.candString = engine.getWord()
36
engine.updateCandidate( 2 )
37
key_7_8.candString = engine.getWord()
38
engine.updateCandidate( 3 )
39
key_9_0.candString = engine.getWord()
40
engine.updateCandidate( 4 )
41
key_1_2.candString = engine.getWord()
44
/*if ( engine.getSelectedWordLength() > 0 ) {*/
45
/*root.textview.insert( engine.getSelectedWord() )*/
46
inputmethod.sendCommit( engine.getSelectedWord() )
50
property bool needClearShift : false
51
property bool needClearAlt : false
52
function keyPress( key ) {
53
var keycode = key.keycode
54
if ( keycode == Utils.keycode_space ) {
55
if ( engine.getCodeLength() <= 0 ) {
56
if ( mask == Utils.keymask_null ) {
58
key_space.keepDown = true
59
mask = Utils.keymask_space
63
else if ( keycode == Utils.keycode_shift_l || keycode == Utils.keycode_shift_r ) {
64
if ( engine.getCodeLength() <= 0 ) {
65
if ( mask != Utils.keymask_shift ) {
67
key_shift_l.keepDown = true
68
key_shift_r.keepDown = true
69
mask = Utils.keymask_shift
75
else if ( keycode == Utils.keycode_alt_l || keycode == Utils.keycode_alt_r ) {
76
if ( engine.getCodeLength() <= 0 ) {
77
if ( mask != Utils.keymask_alt ) {
79
key_alt_l.keepDown = true
80
key_alt_r.keepDown = true
81
mask = Utils.keymask_alt
89
function clearMask() {
90
key_alt_l.keepDown = false
91
key_alt_r.keepDown = false
92
key_shift_l.keepDown = false
93
key_shift_r.keepDown = false
94
key_space.keepDown = false
95
mask = Utils.keymask_null
97
needClearShift = false
99
function switchMode() {
100
if ( mode == Utils.mode_CN ) {
101
if ( engine.getCodeLength() <= 0 ) {
105
else if ( mode == Utils.mode_EN ) {
109
function backspace() {
110
if ( !key_backspace.paused ) {
111
if ( engine.getSelectedWordLength() > 0 ) {
115
else if ( engine.getCodeLength() > 0 ) {
118
if ( engine.getCodeLength() <= 0 )
119
key_backspace.pauseAutoRepeat()
122
root.textview.backspace()
126
function keyRelease( key ) {
127
var keycode = key.keycode
128
var keysym = Utils.keysym[mode][keycode]
129
if ( keycode >= Utils.keycode_a && keycode <= Utils.keycode_z && mask == Utils.keymask_null ) {
130
/*engine.appendCode( keysym[mask][mode] )*/
131
if ( mode == Utils.mode_CN ) {
132
engine.appendCode( keysym[mask] )
136
root.textview.insert( keysym[mask] )
139
else if ( keycode == Utils.keycode_backspace ) {
142
else if ( keycode == Utils.keycode_shift_l ) {
143
if ( engine.getCodeLength() > 0 ) {
148
else if ( keycode == Utils.keycode_shift_r ) {
149
if ( engine.getCodeLength() > 0 ) {
154
else if ( keycode == Utils.keycode_alt_l ) {
155
if ( engine.getCodeLength() > 0 ) {
160
else if ( keycode == Utils.keycode_alt_r ) {
161
if ( engine.getCodeLength() > 0 ) {
166
else if ( keycode == Utils.keycode_enter ) {
167
if ( engine.getCodeLength() > 0 ) {
168
root.textview.insert( engine.getCode() )
173
root.textview.insert( "\n" )
176
else if ( keycode == Utils.keycode_space ) {
177
if ( engine.getCodeLength() > 0 ) {
180
if ( engine.getCodeLength() <= 0 && engine.getInvalidCodeLength() <= 0 && engine.getSelectedWordLength() > 0 ) {
186
root.textview.insert( keysym[mask] )
189
else if ( keycode >= Utils.keycode_0 && keycode <= Utils.keycode_9 ) {
190
if ( engine.getCodeLength() > 0 ) {
191
var index = keycode - Utils.keycode_0
192
index = Utils.candIndex[index]
193
engine.select( index )
195
if ( engine.getCodeLength() <= 0 && engine.getInvalidCodeLength() <= 0 && engine.getSelectedWordLength() > 0 ) {
201
root.textview.insert( keysym[mask] )
204
else if ( keycode != Utils.keycode_ctrl && keycode != Utils.keycode_alt_l && keycode != Utils.keycode_alt_r ) {
205
root.textview.insert( keysym[mask] )
208
if ( keycode == Utils.keycode_shift_l || keycode == Utils.keycode_shift_r ) {
209
if ( needClearShift ) {
211
/*needClearShift = false*/
214
/*needClearShift = true*/
216
else if ( keycode == Utils.keycode_alt_l || keycode == Utils.keycode_alt_r ) {
217
if ( needClearAlt ) {
219
/*needClearAlt = false*/
222
/*needClearAlt = true*/
226
/*if ( !needClearAlt && !needClearShift ) {*/
231
function keyExit( key ) {
234
/*tooltip.visible = false*/
235
/*console.log( "exit", key.keysym[0] )*/
237
function keyEnter( key ) {
238
/*console.log( "enter", key.keysym[0] )*/
242
function moveTooltip( key ) {
243
/*var keycode = key.keycode*/
244
/*var keysym = Utils.keysym[keycode]*/
245
if ( !key.keepDown ) {
246
var parent = key.parent
247
var pos = parent.mapToItem( tooltip.parent, key.x, key.y )
248
var x = pos.x + key.width / 2 - tooltip.width / 2
249
var y = pos.y - tooltip.height - keyHeight * 0.1
256
tooltip.text = key.text
264
/*anchors.fill : parent */
266
anchors.fill : parent
268
CandKey { id : key_1_2 ; keycode_l : Utils.keycode_1 ; keycode_r : Utils.keycode_2 ; width : numKeyWidth * 2.0 ; height : numKeyHeight ; color_l : palette.keyNormalColor ; color_r : palette.keyNormalColor }
269
CandKey { id : key_3_4 ; keycode_l : Utils.keycode_3 ; keycode_r : Utils.keycode_4 ; width : numKeyWidth * 2.0 ; height : numKeyHeight ; color_l : palette.keyNormalColor ; color_r : palette.keyNormalColor }
270
CandKey { id : key_5_6 ; keycode_l : Utils.keycode_5 ; keycode_r : Utils.keycode_6 ; width : numKeyWidth * 2.0 ; height : numKeyHeight ; color_l : palette.keyNormalColor ; color_r : palette.keyNormalColor }
271
CandKey { id : key_7_8 ; keycode_l : Utils.keycode_7 ; keycode_r : Utils.keycode_8 ; width : numKeyWidth * 2.0 ; height : numKeyHeight ; color_l : palette.keyNormalColor ; color_r : palette.keyNormalColor }
272
CandKey { id : key_9_0 ; keycode_l : Utils.keycode_9 ; keycode_r : Utils.keycode_0 ; width : numKeyWidth * 2.0 ; height : numKeyHeight ; color_l : palette.keyNormalColor ; color_r : palette.keyNormalColor }
273
AutoRepeatKey { id : key_backspace ; keycode : Utils.keycode_backspace ; width : numKeyWidth ; height : numKeyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) ; onRepeated : backspace() }
276
Item { width : keyWidth * 0.25 ; height : keyHeight }
277
Key { id : key_q ; keycode : Utils.keycode_q ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
278
Key { id : key_w ; keycode : Utils.keycode_w ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
279
Key { id : key_e ; keycode : Utils.keycode_e ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
280
Key { id : key_r ; keycode : Utils.keycode_r ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
281
Key { id : key_t ; keycode : Utils.keycode_t ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
282
Key { id : key_y ; keycode : Utils.keycode_y ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
283
Key { id : key_u ; keycode : Utils.keycode_u ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
284
Key { id : key_i ; keycode : Utils.keycode_i ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
285
Key { id : key_o ; keycode : Utils.keycode_o ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
286
Key { id : key_p ; keycode : Utils.keycode_p ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
287
/*ProxyMouseArea { id : ikey_backspace ; width : keyWidth ; height : keyHeight }*/
288
ProxyMouseArea { id : ikey_p ; width : keyWidth ; height : keyHeight }
291
ProxyMouseArea { id : ikey_a ; width : keyWidth * 0.5 ; height : keyHeight }
292
Key { id : key_a ; keycode : Utils.keycode_a ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
293
Key { id : key_s ; keycode : Utils.keycode_s ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
294
Key { id : key_d ; keycode : Utils.keycode_d ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
295
Key { id : key_f ; keycode : Utils.keycode_f ; width : keyWidth ; height : keyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) }
296
Key { id : key_g ; keycode : Utils.keycode_g ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
297
Key { id : key_h ; keycode : Utils.keycode_h ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
298
Key { id : key_j ; keycode : Utils.keycode_j ; width : keyWidth ; height : keyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) }
299
Key { id : key_k ; keycode : Utils.keycode_k ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
300
Key { id : key_l ; keycode : Utils.keycode_l ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
301
Key { id : key_enter ; keycode : Utils.keycode_enter ; width : keyWidth * 2.0 ; height : keyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) }
304
ProxyMouseArea { id : ikey_shift_l ; width : keyWidth ; height : keyHeight }
305
Key { id : key_z ; keycode : Utils.keycode_z ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
306
Key { id : key_x ; keycode : Utils.keycode_x ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
307
Key { id : key_c ; keycode : Utils.keycode_c ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
308
Key { id : key_v ; keycode : Utils.keycode_v ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
309
Key { id : key_b ; keycode : Utils.keycode_b ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
310
Key { id : key_n ; keycode : Utils.keycode_n ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
311
Key { id : key_m ; keycode : Utils.keycode_m ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
312
Key { id : key_comma ; keycode : Utils.keycode_comma ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
313
Key { id : key_dot ; keycode : Utils.keycode_dot ; width : keyWidth ; height : keyHeight ; color : palette.keyNormalColor }
314
ProxyMouseArea { id : ikey_shift_r ; width : keyWidth ; height : keyHeight }
317
Key { id : key_shift_l ; keycode : Utils.keycode_shift_l ; width : keyWidth * 2.0 ; height : keyHeight ; color : palette.keyNormalColor }
318
ProxyMouseArea { id : ikey_shift_l_2 ; width : keyWidth * 0.25 ; height : keyHeight }
319
Key { id : key_alt_l ; keycode : Utils.keycode_alt_l ; width : keyWidth * 1.5 ; height : keyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) }
320
ProxyMouseArea { id : ikey_alt_l ; width : keyWidth * 0.25 ; height : keyHeight }
321
Key { id : key_space ; keycode : Utils.keycode_space ; width : keyWidth * 3.0 ; height : keyHeight ; color : palette.keyNormalColor }
322
ProxyMouseArea { id : ikey_alt_r ; width : keyWidth * 0.25 ; height : keyHeight }
323
Key { id : key_alt_r ; keycode : Utils.keycode_alt_r ; width : keyWidth * 1.5 ; height : keyHeight ; color : Qt.darker( palette.keyNormalColor, 1.25 ) }
324
ProxyMouseArea { id : ikey_shift_r_2 ; width : keyWidth * 0.25 ; height : keyHeight }
325
Key { id : key_shift_r ; keycode : Utils.keycode_shift_r ; width : keyWidth * 2.0 ; height : keyHeight ; color : palette.keyNormalColor }
329
id : ikey_l ; width : keyWidth * 0.35 ; height : keyHeight
330
x : key_l.x + key_l.parent.x + key_l.parent.parent.x + key_l.width
331
y : key_l.y + key_l.parent.y + key_l.parent.parent.y
335
Component.onCompleted : {
336
ikey_a.target = key_a
338
ikey_l.target = key_l
340
ikey_l.target = key_enter
341
ikey_p.target = key_p
342
ikey_shift_l.target = key_shift_l
343
ikey_shift_r.target = key_shift_r
344
ikey_shift_l_2.target = key_shift_l
345
ikey_shift_r_2.target = key_shift_r
346
ikey_alt_l.target = key_alt_l
347
ikey_alt_r.target = key_alt_r