Skip to content

Commit 4c11f38

Browse files
committed
fix: improve OSD panel timeout behavior with modifier key
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
1 parent f7a8f50 commit 4c11f38

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

panels/notification/osd/osdpanel.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool OsdPanel::init()
4747
m_osdTimer = new QTimer(this);
4848
m_osdTimer->setInterval(m_interval);
4949
m_osdTimer->setSingleShot(true);
50-
QObject::connect(m_osdTimer, &QTimer::timeout, this, &OsdPanel::hideOsd);
50+
QObject::connect(m_osdTimer, &QTimer::timeout, this, &OsdPanel::doneSetting);
5151
return DPanel::init();
5252
}
5353

@@ -74,6 +74,20 @@ void OsdPanel::ShowOSD(const QString &text)
7474
});
7575
}
7676

77+
void OsdPanel::doneSetting()
78+
{
79+
if (qApp->queryKeyboardModifiers().testFlag(Qt::MetaModifier)) {
80+
m_osdTimer->start();
81+
return;
82+
}
83+
84+
int delay = m_osdTimer->interval() - m_osdTimer->remainingTime();
85+
if (delay < 0) delay = 0;
86+
QTimer::singleShot(delay,this, [this](){
87+
hideOsd();
88+
});
89+
}
90+
7791
void OsdPanel::hideOsd()
7892
{
7993
m_osdTimer->stop();

panels/notification/osd/osdpanel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public Q_SLOTS:
3535

3636
private Q_SLOTS:
3737
void hideOsd();
38+
void doneSetting();
39+
3840
private:
3941
void showOsd();
4042
void setVisible(const bool visible);

0 commit comments

Comments
 (0)