需求22759 shift支持长按
This commit is contained in:
parent
2e262db1a0
commit
702d834593
|
@ -133,6 +133,8 @@ Rectangle {
|
|||
property bool isAllLayoutListVisible: false
|
||||
property string layout: "classic"
|
||||
property bool isCurrentIMListVisible: false
|
||||
property bool isShiftKeyLongPressed: shiftState === "LONG_PRESSED" ||
|
||||
shiftState === "OPEN_LONG_PRESSED"
|
||||
|
||||
//内部使用
|
||||
signal showToolbar()
|
||||
|
@ -208,7 +210,7 @@ Rectangle {
|
|||
}
|
||||
|
||||
function onCharKeyClicked() {
|
||||
shiftState = "NORMAL"
|
||||
updateShiftKeyNormalState()
|
||||
ctrlState = "NORMAL"
|
||||
altState = "NORMAL"
|
||||
winState = "NORMAL"
|
||||
|
@ -221,23 +223,29 @@ Rectangle {
|
|||
}
|
||||
|
||||
function onCtrlClicked() {
|
||||
shiftState = "NORMAL"
|
||||
updateShiftKeyNormalState()
|
||||
altState = "NORMAL"
|
||||
winState = "NORMAL"
|
||||
}
|
||||
|
||||
function onAltClicked() {
|
||||
shiftState = "NORMAL"
|
||||
updateShiftKeyNormalState()
|
||||
ctrlState = "NORMAL"
|
||||
winState = "NORMAL"
|
||||
}
|
||||
|
||||
function onWinClicked() {
|
||||
shiftState = "NORMAL"
|
||||
updateShiftKeyNormalState()
|
||||
altState = "NORMAL"
|
||||
ctrlState = "NORMAL"
|
||||
}
|
||||
|
||||
function updateShiftKeyNormalState() {
|
||||
if (!isShiftKeyLongPressed) {
|
||||
shiftState = "NORMAL"
|
||||
}
|
||||
}
|
||||
|
||||
onUniqueNameChanged: {
|
||||
for(var i = 0; i<currentIMList.length; i++){
|
||||
if(currentIMList[i].includes(uniqueName)){
|
||||
|
|
|
@ -22,7 +22,7 @@ SwitchKey {
|
|||
label: "Caps"
|
||||
|
||||
switchKeyState: virtualKeyboard.capslockState
|
||||
keyMouseArea.onReleased: {
|
||||
multiPointTouchArea.onReleased: {
|
||||
if(virtualKeyboard.capslockState == "NORMAL") {
|
||||
virtualKeyboard.capslockState = "OPEN"
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ SwitchKey {
|
|||
}
|
||||
}
|
||||
|
||||
keyMouseArea.onReleased: {
|
||||
multiPointTouchArea.onReleased: {
|
||||
if(virtualKeyboard.changeIMState == "NORMAL"){
|
||||
virtualKeyboard.changeIMState = "OPEN"
|
||||
imList.open()
|
||||
|
@ -46,7 +46,7 @@ SwitchKey {
|
|||
}
|
||||
}
|
||||
|
||||
keyMouseArea.onPressed: {
|
||||
multiPointTouchArea.onPressed: {
|
||||
imList.currentIndex =
|
||||
virtualKeyboard.currentIMList.indexOf(virtualKeyboard.currentIM)
|
||||
}
|
||||
|
|
|
@ -42,8 +42,20 @@ BaseKey {
|
|||
MouseArea {
|
||||
id: keyMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
hoverEnabled: !virtualKeyboard.isShiftKeyLongPressed
|
||||
|
||||
onEntered: {
|
||||
keyBackground.state = "HOVER"
|
||||
}
|
||||
|
||||
onExited: {
|
||||
keyBackground.state = "NORMAL"
|
||||
}
|
||||
}
|
||||
|
||||
MultiPointTouchArea {
|
||||
anchors.fill: parent
|
||||
maximumTouchPoints: 1
|
||||
onReleased: {
|
||||
keyBackground.state = "NORMAL"
|
||||
timer.stop()
|
||||
|
@ -56,15 +68,6 @@ BaseKey {
|
|||
timer.start()
|
||||
sendKeyPressEvent()
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
keyBackground.state = "HOVER"
|
||||
}
|
||||
|
||||
onExited: {
|
||||
keyBackground.state = "NORMAL"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
keyBackground.state: "NORMAL"
|
||||
|
|
|
@ -23,7 +23,7 @@ SwitchKey {
|
|||
label: "Fn"
|
||||
|
||||
switchKeyState: fn.state
|
||||
keyMouseArea.onReleased: {
|
||||
multiPointTouchArea.onReleased: {
|
||||
if(fn.state == "NORMAL") {
|
||||
fn.state = "OPEN"
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,7 @@ TemporarySwitchKey {
|
|||
Component.onCompleted: {
|
||||
temporarySwitchKeyReleased.connect(updateShiftState)
|
||||
temporarySwitchKeyClicked.connect(virtualKeyboard.shiftClicked)
|
||||
temporarySwitchKeyLongPressed.connect(updateShiftState)
|
||||
}
|
||||
|
||||
function updateShiftState(shiftState) {
|
||||
|
@ -62,6 +63,30 @@ TemporarySwitchKey {
|
|||
target: keyBackground
|
||||
state: "OPEN"
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "LONG_PRESSED"
|
||||
PropertyChanges {
|
||||
target: virtualKeyboard
|
||||
letterState : virtualKeyboard.capslockState == "NORMAL" ? "SHIFT" : "NORMAL"
|
||||
symbolState : "SHIFT"
|
||||
}
|
||||
PropertyChanges {
|
||||
target: keyBackground
|
||||
state: "PRESSED"
|
||||
}
|
||||
},
|
||||
State {
|
||||
name: "OPEN_LONG_PRESSED"
|
||||
PropertyChanges {
|
||||
target: virtualKeyboard
|
||||
letterState : virtualKeyboard.capslockState == "NORMAL" ? "SHIFT" : "NORMAL"
|
||||
symbolState : "SHIFT"
|
||||
}
|
||||
PropertyChanges {
|
||||
target: keyBackground
|
||||
state: "OPEN_PRESSED"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ BaseKey {
|
|||
property color openPressedColor: virtualKeyboard.switchKeyOpenPressedColor
|
||||
property color hoverNormalColor: virtualKeyboard.switchKeyHoverNormalColor
|
||||
property color hoverOpenColor: virtualKeyboard.switchKeyHoverOpenColor
|
||||
property alias keyMouseArea: keyMouseArea_
|
||||
property alias multiPointTouchArea: multiPointTouchArea_
|
||||
property string switchKeyState
|
||||
|
||||
fontSize: virtualKeyboard.switchKeyFontSize
|
||||
|
@ -117,30 +117,34 @@ BaseKey {
|
|||
MouseArea {
|
||||
id: keyMouseArea_
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onPressed: {
|
||||
if(switchKeyState == "NORMAL") {
|
||||
keyBackground.state = "PRESSED"
|
||||
} else {
|
||||
keyBackground.state = "OPEN_PRESSED"
|
||||
}
|
||||
}
|
||||
|
||||
hoverEnabled: !virtualKeyboard.isShiftKeyLongPressed
|
||||
onEntered: {
|
||||
if(switchKeyState == "NORMAL") {
|
||||
if (switchKeyState == "NORMAL") {
|
||||
keyBackground.state = "HOVER_NORMAL"
|
||||
} else {
|
||||
} else if (switchKeyState == "OPEN") {
|
||||
keyBackground.state = "HOVER_OPEN"
|
||||
}
|
||||
}
|
||||
|
||||
onExited: {
|
||||
if(switchKeyState == "NORMAL") {
|
||||
if (switchKeyState == "NORMAL") {
|
||||
keyBackground.state = "NORMAL"
|
||||
} else {
|
||||
} else if (switchKeyState == "OPEN") {
|
||||
keyBackground.state = "OPEN"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MultiPointTouchArea {
|
||||
id: multiPointTouchArea_
|
||||
anchors.fill: parent
|
||||
maximumTouchPoints: 1
|
||||
onPressed: {
|
||||
if (switchKeyState == "NORMAL") {
|
||||
keyBackground.state = "PRESSED"
|
||||
} else {
|
||||
keyBackground.state = "OPEN_PRESSED"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,10 @@ import "../js/utils.js" as Utils
|
|||
SwitchKey {
|
||||
signal temporarySwitchKeyReleased(string temporarySwitchKeyState)
|
||||
signal temporarySwitchKeyClicked()
|
||||
signal temporarySwitchKeyLongPressed(string temporarySwitchKeyState)
|
||||
|
||||
keyMouseArea.onReleased: {
|
||||
multiPointTouchArea.onReleased: {
|
||||
longPressTimer_.stop()
|
||||
if(switchKeyState == "NORMAL") {
|
||||
switchKeyState = "OPEN"
|
||||
} else {
|
||||
|
@ -35,10 +37,24 @@ SwitchKey {
|
|||
temporarySwitchKeyReleased(switchKeyState)
|
||||
}
|
||||
|
||||
keyMouseArea.onPressed: {
|
||||
multiPointTouchArea.onPressed: {
|
||||
longPressTimer_.start()
|
||||
|
||||
var keysym = Utils.getKeysymByKeycode(keycode);
|
||||
var modifierKeyState = Utils.getModifierKeyStates()
|
||||
virtualKeyboard.processKeyEvent(keysym, keycode, modifierKeyState - Utils.getKeySym(label), false, Date())
|
||||
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: longPressTimer_
|
||||
interval: 600
|
||||
onTriggered: {
|
||||
if (switchKeyState == "NORMAL") {
|
||||
temporarySwitchKeyLongPressed("LONG_PRESSED")
|
||||
} else if (switchKeyState == "OPEN") {
|
||||
temporarySwitchKeyLongPressed("OPEN_LONG_PRESSED")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue