fix: prevent IME from activating when echo mode is Normal#746
fix: prevent IME from activating when echo mode is Normal#746MyLeeJiEun wants to merge 1 commit into
Conversation
|
Hi @MyLeeJiEun. Thanks for your PR. 😃 |
|
Hi @MyLeeJiEun. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
1. Add event filter to intercept InputMethod and InputMethodQuery events on the line edit widget in Qt6 2. This works around a Qt6 bug where switching EchoMode to Normal invalidates WA_InputMethodEnabled and causes IME to reactivate 3. The filter is conditionally compiled only for Qt6 builds Log: Fix IME reactivation issue in DPasswordEdit on Qt6 when password is visible fix: 修复密码可见时输入法被意外激活的问题 1. 在 Qt6 构建中为 line edit 添加事件过滤器,拦截输入法相关事件 2. 解决 Qt6 切换 EchoMode 为 Normal 时 WA_InputMethodEnabled 失效 导致输入法被重新激活的问题 3. 该过滤仅在 Qt6 编译条件下生效 Log: 修复 Qt6 下 DPasswordEdit 密码可见时输入法被意外重新激活的问题 PMS: BUG-361783
c4c47d5 to
d073b05
Compare
|
/ok-to-test |
deepin pr auto review你好!我是CodeGeeX。我已仔细审查了你提供的Git Diff代码。这段代码的主要目的是修复在Qt6环境下, 以下是我对这段代码在语法逻辑、代码质量、代码性能和代码安全方面的审查意见及改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
💡 改进建议与重构代码核心改进:应该仅在密码处于隐藏状态时拦截输入法事件,在明文状态下应放行,以保证用户体验。 改进后的代码如下: diff --git a/src/widgets/dpasswordedit.cpp b/src/widgets/dpasswordedit.cpp
index 8f08360a3..90c9e90ee 100644
--- a/src/widgets/dpasswordedit.cpp
+++ b/src/widgets/dpasswordedit.cpp
@@ -1,4 +1,4 @@
-// SPDX-FileCopyrightText: 2015 - 2023 UnionTech Software Technology Co., Ltd.
+// SPDX-FileCopyrightText: 2015 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
@@ -120,6 +120,24 @@ void DPasswordEdit::changeEvent(QEvent *event)
bool DPasswordEdit::eventFilter(QObject* watcher, QEvent* event)
{
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ // Qt6 的输入法子系统会在切换 EchoMode 为 Normal 时会导致设置 WA_InputMethodEnabled失效,
+ // 导致输入法重新激活,因此通过事件过滤器拦截输入法事件来兜底。
+ // 修复:仅在密码隐藏状态下拦截输入法,明文状态下应允许使用输入法
+ if (watcher == lineEdit() && echoMode() != QLineEdit::Normal) {
+ switch (event->type()) {
+ case QEvent::InputMethod:
+ case QEvent::InputMethodQuery:
+ return true;
+ default:
+ break;
+ }
+ }
+#endif
return DLineEdit::eventFilter(watcher, event);
}详细解释:
如果你有关于这段代码的更多上下文(例如为什么要在明文模式下也禁用输入法),欢迎提供,我可以做进一步的针对性分析! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, MyLeeJiEun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| bool DPasswordEdit::eventFilter(QObject* watcher, QEvent* event) | ||
| { | ||
| #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) | ||
| // Qt6 的输入法子系统会在切换 EchoMode 为 Normal 时会导致设置 WA_InputMethodEnabled失效, |
There was a problem hiding this comment.
qt6增加了对Qt::ImEnabled 的特殊处理。这个查询项是在 Qt 5.3后逐步加入的
只有在Qt::ImEnabled查询项无效时,再去查询WA_InputMethodEnabled
而QLineEdit的Qt::ImEnabled查询查询返回是
case Qt::ImEnabled:
return isEnabled() && !isReadOnly();
Log: Fix IME reactivation issue in DPasswordEdit on Qt6 when password is visible
fix: 修复密码可见时输入法被意外激活的问题
Log: 修复 Qt6 下 DPasswordEdit 密码可见时输入法被意外重新激活的问题
PMS: BUG-361783