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