From 87bf44b1f5e7268b23423d4aebdef7e55da5a656 Mon Sep 17 00:00:00 2001 From: iaom Date: Tue, 11 Jul 2023 16:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E7=B4=A7=E6=80=A5=E7=A8=8B=E5=BA=A6=E5=AF=B9=E5=BA=94=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=A1=8C=E4=B8=BA=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libukui-notification/popup-notification.cpp | 22 ++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libukui-notification/popup-notification.cpp b/libukui-notification/popup-notification.cpp index 1e02f14..c8cf8a4 100644 --- a/libukui-notification/popup-notification.cpp +++ b/libukui-notification/popup-notification.cpp @@ -284,14 +284,18 @@ void PopupNotification::setHints(const QVariantMap &hints) if(ok) { switch (urgency) { default: - case 0: + case 0: //低等级,不弹窗 setUrgency(Urgency::LowUrgency); + d->m_popupTimeout = 0; break; - case 1: + case 1: //中等级,弹窗时间默认6秒 setUrgency(Urgency::NormalUrgency); + d->m_popupTimeout = 6; break; - case 2: + case 2: //高等级,默认弹窗常驻,不可折叠 setUrgency(Urgency::CriticalUrgency); + d->m_popupTimeout = -1; + d->m_noFold = true; break; } } @@ -324,10 +328,14 @@ void PopupNotification::setHints(const QVariantMap &hints) d->m_suppressSound = hints.value(QStringLiteral("suppress-sound")).toBool(); d->m_display = hints.value(QStringLiteral("x-ukui-display")).toString(); d->m_actionState = hints.value(QStringLiteral("x-ukui-action-state")).toStringList(); - d->m_noFold = hints.value(QStringLiteral("x-ukui-no-fold")).toBool(); - d->m_popupTimeout = hints.value(QStringLiteral("x-ukui-popup-timeout")).toInt(); - if(d->m_popupTimeout == 0) { - d->m_popupTimeout = 6; + + QVariant tmp = hints.value(QStringLiteral("x-ukui-no-fold")); + if(!tmp.isNull()) { + d->m_noFold = tmp.toBool(); + } + tmp = hints.value(QStringLiteral("x-ukui-popup-timeout")); + if(!tmp.isNull()) { + d->m_popupTimeout = tmp.toInt(); } }