diff --git a/qml.qrc b/qml.qrc
index dd2d1f2fda71e788061ec050f2e93eb6fc897565..da1792e63ded605550e7207b6b34c1b6cfa1f163 100644
--- a/qml.qrc
+++ b/qml.qrc
@@ -42,5 +42,6 @@
img/up.svg
img/down.svg
qml/js/keycode.js
+ qml/LongPressedKeyManager.qml
diff --git a/qml/ClassicKeyboardLayout.qml b/qml/ClassicKeyboardLayout.qml
index d265424de0637baad66845fe61915655b169aa7f..8be203c419d9ad07bc9414f6a035b52cfb95c93c 100644
--- a/qml/ClassicKeyboardLayout.qml
+++ b/qml/ClassicKeyboardLayout.qml
@@ -27,76 +27,76 @@ Column {
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: virtualKeyboard.keySpacing
- ActionKey{ label: "Esc"; height: virtualKeyboard.keyHeight * 3/4; keycode: Keycode.KEY_ESC}
- SymbolKey{ label: "`"; shiftedText: "~"; height: virtualKeyboard.firstRowKeyHeight; keycode: Keycode.KEY_GRAVE }
- FnSymbolKey{ label: "1"; shiftedText: "!"; fnValue:"F1"; fnKeycode: Keycode.KEY_F1; numberKeycode: Keycode.KEY_1 }
- FnSymbolKey{ label: "2"; shiftedText: "@"; fnValue:"F2"; fnKeycode: Keycode.KEY_F2; numberKeycode: Keycode.KEY_2 }
- FnSymbolKey{ label: "3"; shiftedText: "#"; fnValue:"F3"; fnKeycode: Keycode.KEY_F3; numberKeycode: Keycode.KEY_3 }
- FnSymbolKey{ label: "4"; shiftedText: "$"; fnValue:"F4"; fnKeycode: Keycode.KEY_F4; numberKeycode: Keycode.KEY_4 }
- FnSymbolKey{ label: "5"; shiftedText: "%"; fnValue:"F5"; fnKeycode: Keycode.KEY_F5; numberKeycode: Keycode.KEY_5 }
- FnSymbolKey{ label: "6"; shiftedText: "^"; fnValue:"F6"; fnKeycode: Keycode.KEY_F6; numberKeycode: Keycode.KEY_6 }
- FnSymbolKey{ label: "7"; shiftedText: "&"; fnValue:"F7"; fnKeycode: Keycode.KEY_F7; numberKeycode: Keycode.KEY_7 }
- FnSymbolKey{ label: "8"; shiftedText: "*"; fnValue:"F8"; fnKeycode: Keycode.KEY_F8; numberKeycode: Keycode.KEY_8 }
- FnSymbolKey{ label: "9"; shiftedText: "("; fnValue:"F9"; fnKeycode: Keycode.KEY_F9; numberKeycode: Keycode.KEY_9 }
- FnSymbolKey{ label: "0"; shiftedText: ")"; fnValue:"F10"; fnKeycode: Keycode.KEY_F10; numberKeycode: Keycode.KEY_0 }
- FnSymbolKey{ label: "-"; shiftedText: "_"; fnValue:"F11"; fnKeycode: Keycode.KEY_F11; numberKeycode: Keycode.KEY_MINUS }
- FnSymbolKey{ label: "="; shiftedText: "+"; fnValue:"F12"; fnKeycode: Keycode.KEY_F12; numberKeycode: Keycode.KEY_EQUAL }
- BackspaceKey{ keycode: Keycode.KEY_BACKSPACE }
+ ActionKey{ charKeyId_: "key_esc"; label: "Esc"; height: virtualKeyboard.keyHeight * 3/4; keycode: Keycode.KEY_ESC }
+ SymbolKey{ charKeyId_: "key_grave"; label: "`"; shiftedText: "~"; height: virtualKeyboard.firstRowKeyHeight; keycode: Keycode.KEY_GRAVE }
+ FnSymbolKey{ charKeyId_: "key_1"; label: "1"; shiftedText: "!"; fnValue:"F1"; fnKeycode: Keycode.KEY_F1; numberKeycode: Keycode.KEY_1 }
+ FnSymbolKey{ charKeyId_: "key_2"; label: "2"; shiftedText: "@"; fnValue:"F2"; fnKeycode: Keycode.KEY_F2; numberKeycode: Keycode.KEY_2 }
+ FnSymbolKey{ charKeyId_: "key_3"; label: "3"; shiftedText: "#"; fnValue:"F3"; fnKeycode: Keycode.KEY_F3; numberKeycode: Keycode.KEY_3 }
+ FnSymbolKey{ charKeyId_: "key_4"; label: "4"; shiftedText: "$"; fnValue:"F4"; fnKeycode: Keycode.KEY_F4; numberKeycode: Keycode.KEY_4 }
+ FnSymbolKey{ charKeyId_: "key_5"; label: "5"; shiftedText: "%"; fnValue:"F5"; fnKeycode: Keycode.KEY_F5; numberKeycode: Keycode.KEY_5 }
+ FnSymbolKey{ charKeyId_: "key_6"; label: "6"; shiftedText: "^"; fnValue:"F6"; fnKeycode: Keycode.KEY_F6; numberKeycode: Keycode.KEY_6 }
+ FnSymbolKey{ charKeyId_: "key_7"; label: "7"; shiftedText: "&"; fnValue:"F7"; fnKeycode: Keycode.KEY_F7; numberKeycode: Keycode.KEY_7 }
+ FnSymbolKey{ charKeyId_: "key_8"; label: "8"; shiftedText: "*"; fnValue:"F8"; fnKeycode: Keycode.KEY_F8; numberKeycode: Keycode.KEY_8 }
+ FnSymbolKey{ charKeyId_: "key_9"; label: "9"; shiftedText: "("; fnValue:"F9"; fnKeycode: Keycode.KEY_F9; numberKeycode: Keycode.KEY_9 }
+ FnSymbolKey{ charKeyId_: "key_0"; label: "0"; shiftedText: ")"; fnValue:"F10"; fnKeycode: Keycode.KEY_F10; numberKeycode: Keycode.KEY_0 }
+ FnSymbolKey{ charKeyId_: "key_minus"; label: "-"; shiftedText: "_"; fnValue:"F11"; fnKeycode: Keycode.KEY_F11; numberKeycode: Keycode.KEY_MINUS }
+ FnSymbolKey{ charKeyId_: "key_equal"; label: "="; shiftedText: "+"; fnValue:"F12"; fnKeycode: Keycode.KEY_F12; numberKeycode: Keycode.KEY_EQUAL }
+ BackspaceKey{ charKeyId_: "key_backspace"; keycode: Keycode.KEY_BACKSPACE }
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: virtualKeyboard.keySpacing
- ActionKey{ label: "Tab"; width: virtualKeyboard.keyWidth*1.5 + virtualKeyboard.keySpacing; alignment: Text.AlignLeft; keycode: Keycode.KEY_TAB }
- LetterKey{ label: "q"; shiftedText: "Q"; keycode: Keycode.KEY_Q }
- LetterKey{ label: "w"; shiftedText: "W"; keycode: Keycode.KEY_W }
- LetterKey{ label: "e"; shiftedText: "E"; keycode: Keycode.KEY_E }
- LetterKey{ label: "r"; shiftedText: "R"; keycode: Keycode.KEY_R }
- LetterKey{ label: "t"; shiftedText: "T"; keycode: Keycode.KEY_T }
- LetterKey{ label: "y"; shiftedText: "Y"; keycode: Keycode.KEY_Y }
- LetterKey{ label: "u"; shiftedText: "U"; keycode: Keycode.KEY_U }
- LetterKey{ label: "i"; shiftedText: "I"; keycode: Keycode.KEY_I }
- LetterKey{ label: "o"; shiftedText: "O"; keycode: Keycode.KEY_O }
- LetterKey{ label: "p"; shiftedText: "P"; keycode: Keycode.KEY_P }
- SymbolKey{ label: "["; shiftedText: "{"; keycode: Keycode.KEY_LEFTBRACE }
- SymbolKey{ label: "]"; shiftedText: "}"; keycode: Keycode.KEY_RIGHTBRACE }
- SymbolKey{ label: "\\"; shiftedText: "|"; keycode: Keycode.KEY_BACKSLASH }
- ActionKey{ label: "Del"; keycode: Keycode.KEY_DELETE }
+ ActionKey{ charKeyId_: "key_tab"; label: "Tab"; width: virtualKeyboard.keyWidth*1.5 + virtualKeyboard.keySpacing; alignment: Text.AlignLeft; keycode: Keycode.KEY_TAB }
+ LetterKey{ charKeyId_: "key_q"; label: "q"; shiftedText: "Q"; keycode: Keycode.KEY_Q }
+ LetterKey{ charKeyId_: "key_w"; label: "w"; shiftedText: "W"; keycode: Keycode.KEY_W }
+ LetterKey{ charKeyId_: "key_e"; label: "e"; shiftedText: "E"; keycode: Keycode.KEY_E }
+ LetterKey{ charKeyId_: "key_r"; label: "r"; shiftedText: "R"; keycode: Keycode.KEY_R }
+ LetterKey{ charKeyId_: "key_t"; label: "t"; shiftedText: "T"; keycode: Keycode.KEY_T }
+ LetterKey{ charKeyId_: "key_y"; label: "y"; shiftedText: "Y"; keycode: Keycode.KEY_Y }
+ LetterKey{ charKeyId_: "key_u"; label: "u"; shiftedText: "U"; keycode: Keycode.KEY_U }
+ LetterKey{ charKeyId_: "key_i"; label: "i"; shiftedText: "I"; keycode: Keycode.KEY_I }
+ LetterKey{ charKeyId_: "key_o"; label: "o"; shiftedText: "O"; keycode: Keycode.KEY_O }
+ LetterKey{ charKeyId_: "key_p"; label: "p"; shiftedText: "P"; keycode: Keycode.KEY_P }
+ SymbolKey{ charKeyId_: "key_leftBrace"; label: "["; shiftedText: "{"; keycode: Keycode.KEY_LEFTBRACE }
+ SymbolKey{ charKeyId_: "key_rightBrace"; label: "]"; shiftedText: "}"; keycode: Keycode.KEY_RIGHTBRACE }
+ SymbolKey{ charKeyId_: "key_backSlash"; label: "\\"; shiftedText: "|"; keycode: Keycode.KEY_BACKSLASH }
+ ActionKey{ charKeyId_: "key_delete"; label: "Del"; keycode: Keycode.KEY_DELETE }
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: virtualKeyboard.keySpacing
CapslockKey{width: virtualKeyboard.keyWidth*2 + virtualKeyboard.keySpacing; alignment: Text.AlignLeft; keycode: Keycode.KEY_CAPSLOCK }
- LetterKey{ label: "a"; shiftedText: "A"; keycode: Keycode.KEY_A }
- LetterKey{ label: "s"; shiftedText: "S"; keycode: Keycode.KEY_S }
- LetterKey{ label: "d"; shiftedText: "D"; keycode: Keycode.KEY_D }
- LetterKey{ label: "f"; shiftedText: "F"; keycode: Keycode.KEY_F }
- LetterKey{ label: "g"; shiftedText: "G"; keycode: Keycode.KEY_G }
- LetterKey{ label: "h"; shiftedText: "H"; keycode: Keycode.KEY_H }
- LetterKey{ label: "j"; shiftedText: "J"; keycode: Keycode.KEY_J }
- LetterKey{ label: "k"; shiftedText: "K"; keycode: Keycode.KEY_K }
- LetterKey{ label: "l"; shiftedText: "L"; keycode: Keycode.KEY_L }
- SymbolKey{ label: ";"; shiftedText: ":"; keycode: Keycode.KEY_SEMICOLON }
- SymbolKey{ label: "'"; shiftedText: "\""; keycode: Keycode.KEY_APOSTROPHE }
- EnterKey{ keycode: Keycode.KEY_ENTER }
+ LetterKey{ charKeyId_: "key_a"; label: "a"; shiftedText: "A"; keycode: Keycode.KEY_A }
+ LetterKey{ charKeyId_: "key_s"; label: "s"; shiftedText: "S"; keycode: Keycode.KEY_S }
+ LetterKey{ charKeyId_: "key_d"; label: "d"; shiftedText: "D"; keycode: Keycode.KEY_D }
+ LetterKey{ charKeyId_: "key_f"; label: "f"; shiftedText: "F"; keycode: Keycode.KEY_F }
+ LetterKey{ charKeyId_: "key_g"; label: "g"; shiftedText: "G"; keycode: Keycode.KEY_G }
+ LetterKey{ charKeyId_: "key_h"; label: "h"; shiftedText: "H"; keycode: Keycode.KEY_H }
+ LetterKey{ charKeyId_: "key_j"; label: "j"; shiftedText: "J"; keycode: Keycode.KEY_J }
+ LetterKey{ charKeyId_: "key_k"; label: "k"; shiftedText: "K"; keycode: Keycode.KEY_K }
+ LetterKey{ charKeyId_: "key_l"; label: "l"; shiftedText: "L"; keycode: Keycode.KEY_L }
+ SymbolKey{ charKeyId_: "key_semicolon"; label: ";"; shiftedText: ":"; keycode: Keycode.KEY_SEMICOLON }
+ SymbolKey{ charKeyId_: "key_apostrophe"; label: "'"; shiftedText: "\""; keycode: Keycode.KEY_APOSTROPHE }
+ EnterKey{ charKeyId_: "key_enter"; keycode: Keycode.KEY_ENTER }
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: virtualKeyboard.keySpacing
ShiftKey{width: virtualKeyboard.keyWidth*2.5 + virtualKeyboard.keySpacing*2; alignment: Text.AlignLeft; keycode: Keycode.KEY_LEFTSHIFT }
- LetterKey{ label: "z" ; shiftedText: "Z"; keycode: Keycode.KEY_Z }
- LetterKey{ label: "x" ; shiftedText: "X"; keycode: Keycode.KEY_X }
- LetterKey{ label: "c" ; shiftedText: "C"; keycode: Keycode.KEY_C }
- LetterKey{ label: "v" ; shiftedText: "V"; keycode: Keycode.KEY_V }
- LetterKey{ label: "b" ; shiftedText: "B"; keycode: Keycode.KEY_B }
- LetterKey{ label: "n" ; shiftedText: "N"; keycode: Keycode.KEY_N }
- LetterKey{ label: "m" ; shiftedText: "M"; keycode: Keycode.KEY_M }
- SymbolKey{ label: ", "; shiftedText: "<"; keycode: Keycode.KEY_COMMA }
- SymbolKey{ label: "."; shiftedText: ">"; keycode: Keycode.KEY_DOT }
- SymbolKey{ label: "/"; shiftedText: "?"; keycode: Keycode.KEY_SLASH }
- ActionKey{ label: "up"; actionKeyImgPath: "qrc:/img/up.svg"; keycode: Keycode.KEY_UP }
+ LetterKey{ charKeyId_: "key_z"; label: "z" ; shiftedText: "Z"; keycode: Keycode.KEY_Z }
+ LetterKey{ charKeyId_: "key_x"; label: "x" ; shiftedText: "X"; keycode: Keycode.KEY_X }
+ LetterKey{ charKeyId_: "key_c"; label: "c" ; shiftedText: "C"; keycode: Keycode.KEY_C }
+ LetterKey{ charKeyId_: "key_v"; label: "v" ; shiftedText: "V"; keycode: Keycode.KEY_V }
+ LetterKey{ charKeyId_: "key_b"; label: "b" ; shiftedText: "B"; keycode: Keycode.KEY_B }
+ LetterKey{ charKeyId_: "key_n"; label: "n" ; shiftedText: "N"; keycode: Keycode.KEY_N }
+ LetterKey{ charKeyId_: "key_m"; label: "m" ; shiftedText: "M"; keycode: Keycode.KEY_M }
+ SymbolKey{ charKeyId_: "key_comma"; label: ", "; shiftedText: "<"; keycode: Keycode.KEY_COMMA }
+ SymbolKey{ charKeyId_: "key_dot"; label: "."; shiftedText: ">"; keycode: Keycode.KEY_DOT }
+ SymbolKey{ charKeyId_: "key_slash"; label: "/"; shiftedText: "?"; keycode: Keycode.KEY_SLASH }
+ ActionKey{ charKeyId_: "key_up"; label: "up"; actionKeyImgPath: "qrc:/img/up.svg"; keycode: Keycode.KEY_UP }
ShiftKey{ width: virtualKeyboard.keyWidth*2 + virtualKeyboard.keySpacing; alignment: Text.AlignRight; keycode: Keycode.KEY_RIGHTSHIFT }
}
Row {
@@ -108,11 +108,11 @@ Column {
// WinKey{}
AltKey{ keycode: Keycode.KEY_LEFTALT }
ChangeImKey{}
- SpaceKey{ keycode: Keycode.KEY_SPACE }
+ SpaceKey{ charKeyId_: "key_space"; keycode: Keycode.KEY_SPACE }
AltKey{ keycode: Keycode.KEY_RIGHTALT }
- ActionKey{ label: "left"; actionKeyImgPath: "qrc:/img/left.svg"; keycode: Keycode.KEY_LEFT }
- ActionKey{ label: "down"; actionKeyImgPath: "qrc:/img/down.svg"; keycode: Keycode.KEY_DOWN }
- ActionKey{ label: "right"; actionKeyImgPath: "qrc:/img/right.svg"; keycode: Keycode.KEY_RIGHT }
+ ActionKey{ charKeyId_: "key_left"; label: "left"; actionKeyImgPath: "qrc:/img/left.svg"; keycode: Keycode.KEY_LEFT }
+ ActionKey{ charKeyId_: "key_down"; label: "down"; actionKeyImgPath: "qrc:/img/down.svg"; keycode: Keycode.KEY_DOWN }
+ ActionKey{ charKeyId_: "key_right"; label: "right"; actionKeyImgPath: "qrc:/img/right.svg"; keycode: Keycode.KEY_RIGHT }
CtrlKey{ keycode: Keycode.KEY_RIGHTCTRL }
}
}
diff --git a/qml/LongPressedKeyManager.qml b/qml/LongPressedKeyManager.qml
new file mode 100644
index 0000000000000000000000000000000000000000..c377316c0883dc55e597a204a6cf4c2d9a70cb8f
--- /dev/null
+++ b/qml/LongPressedKeyManager.qml
@@ -0,0 +1,50 @@
+/*
+* Copyright 2022 KylinSoft Co., Ltd.
+*
+* This program is free software: you can redistribute it and/or modify it under
+* the terms of the GNU General Public License as published by the Free Software
+* Foundation, either version 3 of the License, or (at your option) any later
+* version.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*/
+
+import QtQuick 2.0
+
+Item {
+ property bool isShiftKeyLongPressed: shiftState === "LONG_PRESSED" ||
+ shiftState === "OPEN_LONG_PRESSED"
+ property var charKeyId
+ property alias charKeyLongPressedTimer: charKeyLongPressedTimer_
+ property int keyEnterLongPressedStateInterval: 600
+
+ signal charKeyRelesed(var keyId)
+
+ onCharKeyRelesed: {
+ if (keyId === charKeyId) {
+ charKeyLongPressedTimer_.stop()
+ sendKeyEventTimer.stop()
+ }
+ }
+
+ Timer {
+ id: charKeyLongPressedTimer_
+ interval: keyEnterLongPressedStateInterval
+ onTriggered: sendKeyEventTimer.start()
+ }
+
+ Timer {
+ id: sendKeyEventTimer
+ interval: longPressInterval
+ repeat: true
+ onTriggered: {
+ charKeyId.sendKeyPressEvent()
+ }
+ }
+}
diff --git a/qml/VirtualKeyboard.qml b/qml/VirtualKeyboard.qml
index 92665fa588485219134eb434920c208a647eaea0..d98b8f2a4fed3a5693fbd9ce0929a9e3f6b56874 100644
--- a/qml/VirtualKeyboard.qml
+++ b/qml/VirtualKeyboard.qml
@@ -133,8 +133,9 @@ Rectangle {
property bool isAllLayoutListVisible: false
property string layout: "classic"
property bool isCurrentIMListVisible: false
- property bool isShiftKeyLongPressed: shiftState === "LONG_PRESSED" ||
- shiftState === "OPEN_LONG_PRESSED"
+
+ //长按键盘按键相关
+ property var longPressedKeyManager: longPressedKeyManager_
//内部使用
signal showToolbar()
@@ -241,7 +242,7 @@ Rectangle {
}
function updateShiftKeyNormalState() {
- if (!isShiftKeyLongPressed) {
+ if (!longPressedKeyManager.isShiftKeyLongPressed) {
shiftState = "NORMAL"
}
}
@@ -254,6 +255,10 @@ Rectangle {
}
}
+ LongPressedKeyManager {
+ id: longPressedKeyManager_
+ }
+
Rectangle {
id: virtualKeyboardContent
color: virtualKeyboard.virtualKeyboardColor
diff --git a/qml/key/CharKey.qml b/qml/key/CharKey.qml
index 72fb6fb4d2d306e3b13c060559bbfe74de1ae98e..8a9e5519d505b53a5c294dc020bc6e0ee9383d1b 100755
--- a/qml/key/CharKey.qml
+++ b/qml/key/CharKey.qml
@@ -20,11 +20,14 @@ import QtQuick.Controls 2.0
import "../js/utils.js" as Utils
BaseKey {
+ id: charKeyId_
+ property var charKeyId_
property string shiftedText
property color normalColor: virtualKeyboard.charKeyNormalColor
property color pressedColor: virtualKeyboard.charKeyPressedColor
property color hoverColor: virtualKeyboard.charKeyHoverColor
+
function sendKeyEvent(isRelease) {
var keysym = Utils.getKeysymByKeyLabel(keyLabel.text)
var modifierKeyState = Utils.getModifierKeyStates()
@@ -42,7 +45,7 @@ BaseKey {
MouseArea {
id: keyMouseArea
anchors.fill: parent
- hoverEnabled: !virtualKeyboard.isShiftKeyLongPressed
+ hoverEnabled: !longPressedKeyManager.isShiftKeyLongPressed
onEntered: {
keyBackground.state = "HOVER"
@@ -58,15 +61,18 @@ BaseKey {
maximumTouchPoints: 1
onReleased: {
keyBackground.state = "NORMAL"
- timer.stop()
sendKeyReleaseEvent()
+
+ longPressedKeyManager.charKeyRelesed(charKeyId_)
charKeyClicked()
}
onPressed: {
keyBackground.state = "PRESSED"
- timer.start()
sendKeyPressEvent()
+
+ longPressedKeyManager.charKeyId = charKeyId_
+ longPressedKeyManager.charKeyLongPressedTimer.start()
}
}
@@ -102,14 +108,4 @@ BaseKey {
}
}
]
-
-
- Timer {
- id:timer
- interval: virtualKeyboard.longPressInterval
- repeat: true
- onTriggered: {
- sendKeyPressEvent()
- }
- }
}
diff --git a/qml/key/SwitchKey.qml b/qml/key/SwitchKey.qml
index 72304758c509a78c2e70cff3421a3f77b80e0e76..1e34d69581ddd27bd36dddb7c91c633960e69cf4 100755
--- a/qml/key/SwitchKey.qml
+++ b/qml/key/SwitchKey.qml
@@ -117,7 +117,7 @@ BaseKey {
MouseArea {
id: keyMouseArea_
anchors.fill: parent
- hoverEnabled: !virtualKeyboard.isShiftKeyLongPressed
+ hoverEnabled: !longPressedKeyManager.isShiftKeyLongPressed
onEntered: {
if (switchKeyState == "NORMAL") {
keyBackground.state = "HOVER_NORMAL"