From a665ba7cc3ad5a2e234b423dcb16c0f8715b0946 Mon Sep 17 00:00:00 2001 From: zhaokexin Date: Fri, 26 Jan 2024 16:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=89=E9=94=AE=E9=95=BF?= =?UTF-8?q?=E6=8C=89=E7=AE=A1=E7=90=86=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qml.qrc | 1 + qml/LongPressedKeyManager.qml | 23 +++++++++++++++++++++++ qml/VirtualKeyboard.qml | 11 ++++++++--- qml/key/CharKey.qml | 2 +- qml/key/SwitchKey.qml | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 qml/LongPressedKeyManager.qml diff --git a/qml.qrc b/qml.qrc index dd2d1f2..da1792e 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 0000000..0c4637f --- /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 92665fa..d98b8f2 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 72fb6fb..711af14 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 7230475..1e34d69 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" -- Gitee