From 4f850d23e8c6312556efd7fe5b2e97017c1e6ac3 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Fri, 27 Sep 2013 15:29:03 +0200 Subject: [PATCH] [vkb] Key shift transition behavior --- icons/enter.png | Bin 501 -> 447 bytes qml/Key.qml | 91 +++++++++++++++++++++++++++-------------------- qml/Keyboard.qml | 2 +- qml/Main.qml | 2 -- 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/icons/enter.png b/icons/enter.png index 41203b475e6647c0c22097cb76618dba5caa4836..a4b0c822b7e17fbb86ebeb99977fe548c19f9172 100644 GIT binary patch delta 336 zcmV-W0k8h`1HS{1R0j+V6iyOE>XBP0e8^Ove z2o}PEf?(kxY@I7uSlTLtJ;W4S2!bLQ!2@`KNQBMI|BlTHtAxeX?5vUhsfXnIW-^nc z*HcOf197Y z2WCYHZH!60_xr%z?9CS~V2nwk7MKPf0uQ0Vq6O-@-i%Tp&-1>B8~~4Dj_($*)()I= z+YKvNwHn-7I}nj0;3-4^jN1%;3_OR3y!XRaj?pa3(&^aOh+m}_X_}5&zp!&|2e<+z zOL$}^z`cl^EPaNms@ed~fS2EHKH`-siegPf4uNqe3w$}pw}4CFt&;^llx4XtBB#K$ i{IT_0U0000o&Ee_csLK~!ko?byFc!%!H8@kF#%q2S=+P#grW zz{yJxoW$A9*{x36rK8}`!7C8lyalg75eLV@!4ic)C6ct}e9v(bN^OnkO zfZK6?$a+n6co>Ey5vc&L-xth9K&#bS6Ol6@?7iTq0mhi()B~a@S_f*tyBlEC0Bh~u z)B@r--T*Fu5BG;*1Hv#YS!)k~pwD~7V+~J|qzu%7#AN`uAGB@px8dz}d#g|=oO+&j z zo6VJpeiw}~MG-j$o+o_@%~Z8o^{uu0z+El_x}|Bl1Ka>MmjPWz?j~>vM7a#;c|NKD kb^X^$DW#NBN~yW_1*em)23`48L;wH)07*qoM6N<$g0(NVi~s-t diff --git a/qml/Key.qml b/qml/Key.qml index ebb3a70..b74512f 100644 --- a/qml/Key.qml +++ b/qml/Key.qml @@ -25,11 +25,12 @@ Rectangle { property string label_alt: "" property int code: 0 property int code_alt: 0 - property int currentCode: code - property string currentLabel: keyLabel.text + property int currentCode: (shiftActive && label_alt != '') ? code_alt : code + property string currentLabel: (shiftActive && label_alt != '') ? label_alt : label property bool sticky: false // can key be stickied? property bool becomesSticky: false // will this become sticky after release? property int stickiness: 0 // current stickiness status + property real labelOpacity: keyboard.active ? 1.0 : 0.3 // mouse input handling property int clickThreshold: 20 @@ -44,52 +45,64 @@ Rectangle { border.width: 1 radius: 5 - Connections { - target: keyboard - onKeyModifiersChanged: { - if( (keyboard.keyModifiers & Qt.ShiftModifier) && !sticky ) { - if(key.label_alt!="") { - keyLabel.text = key.label_alt - keyAltLabel.text = key.label - key.currentCode = key.code_alt - } else if(key.label.length==1) { - keyLabel.text = key.label.toUpperCase() - } - } else if(!sticky) { - if(key.label.length==1) - keyLabel.text = key.label.toLowerCase() - else - keyLabel.text = key.label - - keyAltLabel.text = key.label_alt - key.currentCode = key.code - } - } - } + property bool shiftActive: (keyboard.keyModifiers & Qt.ShiftModifier) && !sticky Image { id: keyImage anchors.centerIn: parent - opacity: 0.4 + opacity: key.labelOpacity source: { if(key.label.length>1 && key.label.charAt(0)==':') return "qrc:/icons/"+key.label.substring(1)+".png"; else return ""; } } - Text { + Column { visible: keyImage.source == "" - id: keyLabel anchors.centerIn: parent - text: key.label - color: keyboard.keyFgColor - font.pointSize: key.label.length>1 ? 18 : 26 - } - Text { - id: keyAltLabel - anchors.bottom: parent.bottom - anchors.right: parent.right - text: key.label_alt - color: keyboard.keyFgColor - font.pointSize: key.label.length>1 ? 10 : 13 + spacing: -17 + + Text { + id: keyAltLabel + property bool highlighted: key.shiftActive + + anchors.horizontalCenter: parent.horizontalCenter + + text: key.label_alt + color: keyboard.keyFgColor + + opacity: key.labelOpacity * (highlighted ? 1.0 : 0.2) + Behavior on opacity { NumberAnimation { duration: 100 } } + + font.pointSize: (highlighted ? 24 : 14) * (text.length > 1 ? 0.5 : 1.0) + Behavior on font.pointSize { NumberAnimation { duration: 100 } } + } + + Text { + id: keyLabel + property bool highlighted: key.label_alt == '' || !key.shiftActive + + anchors.horizontalCenter: parent.horizontalCenter + + text: { + if (key.label.length == 1 && key.label_alt == '') { + if (key.shiftActive) { + return key.label.toUpperCase(); + } else { + return key.label.toLowerCase(); + } + } + + return key.label; + } + + color: keyboard.keyFgColor + + opacity: key.labelOpacity * (highlighted ? 1.0 : 0.2) + Behavior on opacity { NumberAnimation { duration: 100 } } + + font.pointSize: (highlighted ? 24 : 14) * (text.length > 1 ? 0.5 : 1.0) + Behavior on font.pointSize { NumberAnimation { duration: 100 } } + } } + Rectangle { id: stickIndicator visible: sticky && stickiness>0 @@ -147,7 +160,7 @@ Rectangle { key.color = keyboard.keyBgColor; keyboard.currentKeyPressed = 0; - if (sticky) { + if (sticky && !becomesSticky) { keyboard.keyModifiers &= ~code keyboard.currentStickyPressed = null; } diff --git a/qml/Keyboard.qml b/qml/Keyboard.qml index 39a504c..868df07 100644 --- a/qml/Keyboard.qml +++ b/qml/Keyboard.qml @@ -31,7 +31,7 @@ Rectangle { property variant currentStickyPressed: null property variant currentKeyPressed: 0 - property string keyFgColor: "#565656" + property string keyFgColor: "#ffffff" property string keyBgColor: "#202020" property string keyHilightBgColor: "#ffffff" property string keyBorderColor: "#303030" diff --git a/qml/Main.qml b/qml/Main.qml index 71f837d..6b01be6 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -342,7 +342,6 @@ PageStackWindow { lineView.duration = window.fadeOutTime; textrender.duration = window.fadeOutTime; - vkb.keyFgColor = "#cccccc"; fadeTimer.restart(); vkb.active = true; lineView.setPosition(vkb.active); @@ -355,7 +354,6 @@ PageStackWindow { { textrender.duration = window.fadeInTime; lineView.duration = window.fadeInTime; - vkb.keyFgColor = "#565656"; vkb.active = false; lineView.setPosition(vkb.active); util.updateSwipeLock(!vkb.active);