From 5df4b554d9322e71c140871152df32e957d65062 Mon Sep 17 00:00:00 2001 From: wjyrich Date: Tue, 21 Oct 2025 12:20:14 +0800 Subject: [PATCH] fix: improve OSD panel timeout behavior with modifier key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Changed timer connection from hideOsd to doneSetting to handle modifier key detection 2. Added doneSetting method that checks for MetaModifier key state 3. When Meta key is pressed, restarts timer instead of hiding OSD immediately 4. Creates additional hide timer when Meta key is not pressed to ensure proper timeout after key release 5. This prevents OSD from disappearing while user is holding modifier keys for shortcuts fix: 改进 OSD 面板超时行为以支持修饰键 1. 将定时器连接从 hideOsd 改为 doneSetting 以处理修饰键检测 2. 添加 doneSetting 方法检查 MetaModifier 键状态 3. 当 Meta 键按下时,重新启动定时器而不是立即隐藏 OSD 4. 当 Meta 键未按下时,创建额外的隐藏定时器确保按键释放后正确超时 5. 防止用户在按住修饰键进行快捷操作时 OSD 意外消失 PMS: BUG-294169 BUG-294165 --- panels/notification/osd/osdpanel.cpp | 16 +++++++++++++++- panels/notification/osd/osdpanel.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/panels/notification/osd/osdpanel.cpp b/panels/notification/osd/osdpanel.cpp index b97edb614..94d3c6f52 100644 --- a/panels/notification/osd/osdpanel.cpp +++ b/panels/notification/osd/osdpanel.cpp @@ -47,7 +47,7 @@ bool OsdPanel::init() m_osdTimer = new QTimer(this); m_osdTimer->setInterval(m_interval); m_osdTimer->setSingleShot(true); - QObject::connect(m_osdTimer, &QTimer::timeout, this, &OsdPanel::hideOsd); + QObject::connect(m_osdTimer, &QTimer::timeout, this, &OsdPanel::doneSetting); return DPanel::init(); } @@ -74,6 +74,20 @@ void OsdPanel::ShowOSD(const QString &text) }); } +void OsdPanel::doneSetting() +{ + if (qApp->queryKeyboardModifiers().testFlag(Qt::MetaModifier)) { + m_osdTimer->start(); + return; + } + + int delay = m_osdTimer->interval() - m_osdTimer->remainingTime(); + if (delay < 0) delay = 0; + QTimer::singleShot(delay,this, [this](){ + hideOsd(); + }); +} + void OsdPanel::hideOsd() { m_osdTimer->stop(); diff --git a/panels/notification/osd/osdpanel.h b/panels/notification/osd/osdpanel.h index e2b0e908c..d01334189 100644 --- a/panels/notification/osd/osdpanel.h +++ b/panels/notification/osd/osdpanel.h @@ -35,6 +35,8 @@ public Q_SLOTS: private Q_SLOTS: void hideOsd(); + void doneSetting(); + private: void showOsd(); void setVisible(const bool visible);