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/LongPressedKeyManager.qml b/qml/LongPressedKeyManager.qml new file mode 100644 index 0000000000000000000000000000000000000000..0c4637fc6cc86738311d4d5dfafa360765e425d9 --- /dev/null +++ b/qml/LongPressedKeyManager.qml @@ -0,0 +1,23 @@ +/* +* 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" +} 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..711af1466f6c370fde904d94d76bdd3dd3fb9e3b 100755 --- a/qml/key/CharKey.qml +++ b/qml/key/CharKey.qml @@ -42,7 +42,7 @@ BaseKey { MouseArea { id: keyMouseArea anchors.fill: parent - hoverEnabled: !virtualKeyboard.isShiftKeyLongPressed + hoverEnabled: !longPressedKeyManager.isShiftKeyLongPressed onEntered: { keyBackground.state = "HOVER" 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"