From 65a64674e5930a81653545a3f05e6d842719d905 Mon Sep 17 00:00:00 2001 From: yeshanshan Date: Wed, 16 Jul 2025 17:49:25 +0800 Subject: [PATCH] feat: add empty state for notification center MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Added "No recent notifications" message when notification center is empty 2. Created reusable DropShadowText component for consistent text styling 3. Added viewCount properties to track notification counts 4. Updated translation files for new empty state message 5. Improved header text styling by using DropShadowText component The changes provide better user feedback when there are no notifications and improve text consistency across the notification center. The empty state message helps users understand the current state of the application. feat: 为通知中心添加空状态提示 1. 当通知中心为空时添加"没有最近的通知"提示信息 2. 创建可复用的DropShadowText组件实现统一文本样式 3. 添加viewCount属性来跟踪通知数量 4. 更新翻译文件支持新的空状态提示 5. 使用DropShadowText组件改进标题文本样式 这些改动在通知中心为空时提供了更好的用户反馈,并改进了整个通知中心的文本 一致性。空状态提示帮助用户理解应用的当前状态。 Issue: https://bbs.deepin.org/post/289386 --- panels/notification/center/NotifyCenter.qml | 13 +++++++ .../center/NotifyHeaderTitleText.qml | 11 ++---- panels/notification/center/NotifyStaging.qml | 1 + panels/notification/center/NotifyView.qml | 1 + panels/notification/center/package/main.qml | 1 + .../org.deepin.ds.notificationcenter.ts | 23 ++++-------- .../org.deepin.ds.notificationcenter_az.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_bo.ts | 23 ++++-------- .../org.deepin.ds.notificationcenter_ca.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_es.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_fi.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_fr.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_hu.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_it.ts | 23 ++++-------- .../org.deepin.ds.notificationcenter_ja.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_ko.ts | 23 ++++-------- .../org.deepin.ds.notificationcenter_nb_NO.ts | 23 ++++-------- .../org.deepin.ds.notificationcenter_pl.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_pt_BR.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_ru.ts | 35 ++++++++----------- .../org.deepin.ds.notificationcenter_uk.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_zh_CN.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_zh_HK.ts | 29 ++++++--------- .../org.deepin.ds.notificationcenter_zh_TW.ts | 29 ++++++--------- panels/notification/plugin/CMakeLists.txt | 1 + panels/notification/plugin/DropShadowText.qml | 19 ++++++++++ 26 files changed, 230 insertions(+), 344 deletions(-) create mode 100644 panels/notification/plugin/DropShadowText.qml diff --git a/panels/notification/center/NotifyCenter.qml b/panels/notification/center/NotifyCenter.qml index c1c20c0db..c80d51dde 100644 --- a/panels/notification/center/NotifyCenter.qml +++ b/panels/notification/center/NotifyCenter.qml @@ -6,6 +6,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import org.deepin.dtk 1.0 +import org.deepin.ds.notification import org.deepin.ds.notificationcenter FocusScope { @@ -15,6 +16,7 @@ FocusScope { property alias model: notifyModel property int maxViewHeight: 400 + property int stagingViewCount: 0 NotifyModel { id: notifyModel @@ -48,5 +50,16 @@ FocusScope { height: Math.min(maxViewHeight, viewHeight) notifyModel: notifyModel } + + DropShadowText { + text: qsTr("No recent notifications") + visible: root.stagingViewCount === 0 && view.viewCount === 0 + anchors { + top: header.bottom + topMargin: 10 + horizontalCenter: parent.horizontalCenter + } + height: 40 + } } } diff --git a/panels/notification/center/NotifyHeaderTitleText.qml b/panels/notification/center/NotifyHeaderTitleText.qml index 9948a53a7..7ae5d4d3f 100644 --- a/panels/notification/center/NotifyHeaderTitleText.qml +++ b/panels/notification/center/NotifyHeaderTitleText.qml @@ -5,21 +5,14 @@ import QtQuick import Qt5Compat.GraphicalEffects import org.deepin.dtk 1.0 +import org.deepin.ds.notification import org.deepin.ds.notificationcenter -Text { +DropShadowText { property font tFont: DTK.fontManager.t4 font { pixelSize: tFont.pixelSize family: tFont.family bold: true } - color: Qt.rgba(1, 1, 1, 1) - layer.enabled: true - layer.effect: DropShadow { - color: Qt.rgba(0, 0, 0, 0.6) - radius: 4 - samples: 9 - verticalOffset: 1 - } } diff --git a/panels/notification/center/NotifyStaging.qml b/panels/notification/center/NotifyStaging.qml index 57f215d8d..01d750f27 100644 --- a/panels/notification/center/NotifyStaging.qml +++ b/panels/notification/center/NotifyStaging.qml @@ -14,6 +14,7 @@ FocusScope { implicitWidth: 360 implicitHeight: view.height property var model: notifyModel + readonly property int viewCount: view.count NotifyStagingModel { id: notifyModel diff --git a/panels/notification/center/NotifyView.qml b/panels/notification/center/NotifyView.qml index f5a93c641..f143cbce7 100644 --- a/panels/notification/center/NotifyView.qml +++ b/panels/notification/center/NotifyView.qml @@ -14,6 +14,7 @@ Control { required property NotifyModel notifyModel readonly property real viewHeight: view.contentHeight + readonly property int viewCount: view.count NotifySetting { id: notifySetting diff --git a/panels/notification/center/package/main.qml b/panels/notification/center/package/main.qml index 1eeeca6ce..e5a167b02 100644 --- a/panels/notification/center/package/main.qml +++ b/panels/notification/center/package/main.qml @@ -128,6 +128,7 @@ Window { implicitWidth: 360 maxViewHeight: root.height + stagingViewCount: notifyStaging.viewCount } } } diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter.ts index d8a5491e5..e603fb7aa 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter.ts @@ -8,6 +8,13 @@ + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -40,21 +47,5 @@ Just now - - %1 minutes ago - - - - 1 hour ago - - - - %1 hours ago - - - - Yesterday - - diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_az.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_az.ts index 295c227ea..5fadafcf9 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_az.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_az.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ مسح الكل + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now الآن - - %1 minutes ago - %1 دقيقة مضت - - - 1 hour ago - - - - %1 hours ago - %1 ساعة مضت - - - Yesterday - أمس - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_bo.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_bo.ts index d8a5491e5..e603fb7aa 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_bo.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_bo.ts @@ -8,6 +8,13 @@ + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -40,21 +47,5 @@ Just now - - %1 minutes ago - - - - 1 hour ago - - - - %1 hours ago - - - - Yesterday - - diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ca.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ca.ts index 425e67865..ad1de18d6 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ca.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ca.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Neteja-ho tot + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Ara mateix - - %1 minutes ago - Fa %1 minuts - - - 1 hour ago - Fa 1 hora - - - %1 hours ago - Fa %1 hores - - - Yesterday - Ahir - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_es.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_es.ts index 356b8a6ed..45416cfcf 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_es.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_es.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Limpiar todo + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Ahora mismo - - %1 minutes ago - Hace %1 minutos - - - 1 hour ago - Hace una hora - - - %1 hours ago - Hace %1 horas - - - Yesterday - Ayer - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_fi.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_fi.ts index 3be0f49c2..b451f50d7 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_fi.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_fi.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Tyhjennä kaikki + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Juuri nyt - - %1 minutes ago - %1 min sitten - - - 1 hour ago - 1 h sitten - - - %1 hours ago - %1 h sitten - - - Yesterday - Eilen - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_fr.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_fr.ts index 833ce6dec..f37fac632 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_fr.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_fr.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Tout effacer + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now À l'instant - - %1 minutes ago - Il y a %1 minutes - - - 1 hour ago - Il y a 1 heure - - - %1 hours ago - Il y a %1 heures - - - Yesterday - Hier - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_hu.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_hu.ts index 5a4ce4f47..b473e8c25 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_hu.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_hu.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Összes törlése + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Csak most - - %1 minutes ago - %1 perccel ezelőtt - - - 1 hour ago - - - - %1 hours ago - %1 órával ezelőtt - - - Yesterday - Tegnap - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_it.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_it.ts index d8a5491e5..e603fb7aa 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_it.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_it.ts @@ -8,6 +8,13 @@ + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -40,21 +47,5 @@ Just now - - %1 minutes ago - - - - 1 hour ago - - - - %1 hours ago - - - - Yesterday - - diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ja.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ja.ts index eaabf9c42..4cdc09f72 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ja.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ja.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ すべて消去 + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now たった今 - - %1 minutes ago - %1分前 - - - 1 hour ago - 1時間前 - - - %1 hours ago - %1時間前 - - - Yesterday - 昨日 - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ko.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ko.ts index d8a5491e5..e603fb7aa 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ko.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ko.ts @@ -8,6 +8,13 @@ + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -40,21 +47,5 @@ Just now - - %1 minutes ago - - - - 1 hour ago - - - - %1 hours ago - - - - Yesterday - - diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_nb_NO.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_nb_NO.ts index d8a5491e5..e603fb7aa 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_nb_NO.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_nb_NO.ts @@ -8,6 +8,13 @@ + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -40,21 +47,5 @@ Just now - - %1 minutes ago - - - - 1 hour ago - - - - %1 hours ago - - - - Yesterday - - diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_pl.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_pl.ts index 08490b2bf..a2d630832 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_pl.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_pl.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Wyczyść wszystko + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Właśnie teraz - - %1 minutes ago - %1 minut temu - - - 1 hour ago - 1 godzinę temu - - - %1 hours ago - %1 godzin temu - - - Yesterday - Wczoraj - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_pt_BR.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_pt_BR.ts index 824b48e63..a2ffea59e 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_pt_BR.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_pt_BR.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Limpar tudo + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Há pouco - - %1 minutes ago - %1 minutos atrás - - - 1 hour ago - 1 hora atrás - - - %1 hours ago - %1 horas atrás - - - Yesterday - Ontem - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ru.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ru.ts index abc8db105..007eeeaa3 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_ru.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_ru.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,11 +8,18 @@ Очистить всё + + NotifyCenter + + No recent notifications + + + NotifyHeader Notification Center - + Clear All @@ -21,7 +30,7 @@ NotifySetting Unpin - + Pin @@ -29,7 +38,7 @@ Notification Setting - + @@ -38,21 +47,5 @@ Just now Сейчас - - %1 minutes ago - %1 минут назад - - - 1 hour ago - - - - %1 hours ago - 1% часов назад - - - Yesterday - Вчера - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_uk.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_uk.ts index 6488f93e0..acc91068c 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_uk.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_uk.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ Вилучити все + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now Щойно - - %1 minutes ago - %1 хвилин тому - - - 1 hour ago - 1 годину тому - - - %1 hours ago - %1 годин тому - - - Yesterday - Вчора - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_CN.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_CN.ts index 86a2afb6d..88f41ce92 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_CN.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_CN.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ 全部清除 + + NotifyCenter + + No recent notifications + 没有最近的通知 + + NotifyHeader @@ -38,21 +47,5 @@ Just now 刚刚 - - %1 minutes ago - %1分钟前 - - - 1 hour ago - 1小时前 - - - %1 hours ago - %1小时前 - - - Yesterday - 昨天 - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_HK.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_HK.ts index eda637142..15eaba582 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_HK.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_HK.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ 全部清除 + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now 剛剛 - - %1 minutes ago - %1分鐘前 - - - 1 hour ago - 1小時前 - - - %1 hours ago - %1小時前 - - - Yesterday - - - \ No newline at end of file + diff --git a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_TW.ts b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_TW.ts index 8ad1ebf97..2934fba3c 100644 --- a/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_TW.ts +++ b/panels/notification/center/translations/org.deepin.ds.notificationcenter_zh_TW.ts @@ -1,4 +1,6 @@ - + + + GroupNotify @@ -6,6 +8,13 @@ 全部清除 + + NotifyCenter + + No recent notifications + + + NotifyHeader @@ -38,21 +47,5 @@ Just now 剛剛 - - %1 minutes ago - %1分鐘前 - - - 1 hour ago - 1小時前 - - - %1 hours ago - %1小時前 - - - Yesterday - - - \ No newline at end of file + diff --git a/panels/notification/plugin/CMakeLists.txt b/panels/notification/plugin/CMakeLists.txt index 469cede7f..79025890c 100644 --- a/panels/notification/plugin/CMakeLists.txt +++ b/panels/notification/plugin/CMakeLists.txt @@ -18,6 +18,7 @@ qt_add_qml_module(notificationplugin NotifyAction.qml SettingActionButton.qml OverlapIndicator.qml + DropShadowText.qml OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/notification/ ) diff --git a/panels/notification/plugin/DropShadowText.qml b/panels/notification/plugin/DropShadowText.qml new file mode 100644 index 000000000..4a96d5f6a --- /dev/null +++ b/panels/notification/plugin/DropShadowText.qml @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +import Qt5Compat.GraphicalEffects +import org.deepin.dtk 1.0 +import org.deepin.ds.notificationcenter + +Text { + color: Qt.rgba(1, 1, 1, 1) + layer.enabled: true + layer.effect: DropShadow { + color: Qt.rgba(0, 0, 0, 0.6) + radius: 4 + samples: 9 + verticalOffset: 1 + } +}