-
Notifications
You must be signed in to change notification settings - Fork 61
feat: add hover protection for notification bubbles #1502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
|
|
@@ -347,6 +347,21 @@ QVariant NotificationManager::GetSystemInfo(uint configItem) | |
| return m_setting->systemValue(static_cast<NotificationSetting::SystemConfigItem>(configItem)); | ||
| } | ||
|
|
||
| void NotificationManager::setBlockClosedId(qint64 id) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (complexity): Consider clarifying which id is used in the timeout search and extracting the common 1000ms postponement logic into a helper to make the behavior more explicit and maintainable. You can keep the feature as‑is but reduce the cognitive load a bit by (1) avoiding hidden state in the 1. Make it clear which id
|
||
| { | ||
| auto findIter = std::find_if(m_pendingTimeoutEntities.begin(), m_pendingTimeoutEntities.end(), [this](const NotifyEntity &entity) { | ||
| return entity.id() == m_blockClosedId; | ||
| }); | ||
| const auto current = QDateTime::currentMSecsSinceEpoch(); | ||
| if(m_blockClosedId != NotifyEntity::InvalidId && findIter != m_pendingTimeoutEntities.end() && current > findIter.key()) { | ||
| qDebug(notifyLog) << "Block close bubble id:" << m_blockClosedId << "for the new block bubble id:" << id; | ||
| m_pendingTimeoutEntities.insert(QDateTime::currentMSecsSinceEpoch() + 1000, findIter.value()); | ||
| m_pendingTimeoutEntities.erase(findIter); | ||
| } | ||
| m_blockClosedId = id; | ||
| onHandingPendingEntities(); | ||
| } | ||
|
|
||
| bool NotificationManager::isDoNotDisturb() const | ||
| { | ||
| if (!m_setting->systemValue(NotificationSetting::DNDMode).toBool()) | ||
|
|
@@ -673,6 +688,12 @@ void NotificationManager::onHandingPendingEntities() | |
| continue; | ||
| } | ||
|
|
||
| if (item.id() == m_blockClosedId) { | ||
| qDebug(notifyLog) << "bubble id:" << item.bubbleId() << "entity id:" << item.id(); | ||
| m_pendingTimeoutEntities.insert(current + 1000, item); | ||
| continue; | ||
| } | ||
|
|
||
| qDebug(notifyLog) << "Expired for the notification " << item.id() << item.appName(); | ||
| notificationClosed(item.id(), item.bubbleId(), NotifyEntity::Expired); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Using
Qt::DirectConnectionhere could be unsafe ifm_notificationServerlives in another thread.QMetaObject::invokeMethodwithQt::DirectConnectionwill runsetBlockClosedIdin the caller’s thread. IfBubblePanelandm_notificationServerever end up in different threads, this will break Qt’s threading rules and can cause race conditions.If cross-thread calls are possible (now or later), prefer the default connection type or
Qt::QueuedConnection. If they are guaranteed to share a thread, either call the slot directly or add a short comment documenting that assumption to avoid future misuse.