Skip to content

Commit c06f1bc

Browse files
wjyrichdeepin-bot[bot]
authored andcommitted
feat: add clean all button for overlap notifications
Added a "Clean All" button to overlap notification items to allow users to remove all notifications from a specific app at once The button is implemented as a custom button component in OverlapNotify with proper translation support Modified NotifyModel to handle removal of overlap type notifications and added warning logging for missing apps Updated translation files across multiple languages to include the new "Clean All" text feat: 为重叠通知添加清除全部按钮 在重叠通知项中添加"清除全部"按钮,允许用户一次性移除特定应用的所有通知 该按钮作为自定义按钮组件在 OverlapNotify 中实现,并支持多语言翻译 修改 NotifyModel 以处理重叠类型通知的移除,并为不存在的应用添加警告日志 更新了多个语言的翻译文件以包含新的"清除全部"文本
1 parent c3bb9dd commit c06f1bc

27 files changed

+326
-122
lines changed

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ DelegateChooser {
166166
})
167167
}
168168
onRemove: function () {
169-
console.log("remove overlap", model.id)
170-
notifyModel.remove(model.id)
169+
console.log("remove overlap", model.appName)
170+
notifyModel.removeByApp(model.appName)
171171
}
172172
onActionInvoked: function (actionId) {
173173
console.log("action overlap", model.id, actionId)

panels/notification/center/OverlapNotify.qml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ NotifyItem {
6464
contentIcon: root.contentIcon
6565
contentRowCount: root.contentRowCount
6666
enableDismissed: root.enableDismissed
67-
68-
onRemove: function () {
69-
root.removedCallback = function () {
70-
root.remove()
67+
clearButton: AnimationSettingButton {
68+
icon.name: "clean-alone"
69+
text: qsTr("Clean All")
70+
onClicked: function () {
71+
root.removedCallback = function() {
72+
root.remove()
73+
}
74+
root.state = "removing"
7175
}
72-
root.state = "removing"
7376
}
7477
onDismiss: function () {
7578
root.removedCallback = function () {

panels/notification/center/notifymodel.cpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -546,38 +546,41 @@ void NotifyModel::removeByApp(const QString &appName)
546546
int row = -1;
547547
for (int i = 0; i < m_appNotifies.size(); i++) {
548548
auto item = m_appNotifies[i];
549-
if (item->appName() == appName && item->type() == NotifyType::Group) {
549+
if (item->appName() == appName && (item->type() == NotifyType::Group || item->type() == NotifyType::Overlap)) {
550550
row = i;
551551
break;
552552
}
553553
}
554-
555-
if (row >= 0) {
556-
auto notify = m_appNotifies[row];
557-
beginRemoveRows(QModelIndex(), row, row);
558-
m_appNotifies.removeOne(notify);
559-
endRemoveRows();
560-
notify->deleteLater();
554+
if (row < 0) {
555+
qWarning(notifyLog) << "No notify for the app" << appName;
556+
return;
561557
}
558+
auto notify = m_appNotifies[row];
559+
beginRemoveRows(QModelIndex(), row, row);
560+
m_appNotifies.removeOne(notify);
561+
endRemoveRows();
562562

563-
QList<AppNotifyItem *> notifies;
564-
for (int i = row; i < m_appNotifies.size(); i++) {
565-
auto item = m_appNotifies[i];
566-
if (item->appName() == appName && item->type() == NotifyType::Normal) {
567-
notifies.append(item);
563+
if(notify->type() == NotifyType::Group) {
564+
QList<AppNotifyItem *> notifies;
565+
for (int i = row; i < m_appNotifies.size(); i++) {
566+
auto item = m_appNotifies[i];
567+
if (item->appName() == appName && item->type() == NotifyType::Normal) {
568+
notifies.append(item);
569+
}
568570
}
569-
}
570571

571-
const auto start = row;
572-
beginRemoveRows(QModelIndex(), start, start + notifies.size() - 1);
573-
for (int i = 0; i < notifies.size(); i++) {
574-
auto item = notifies[i];
575-
m_appNotifies.removeOne(item);
576-
item->deleteLater();
577-
}
578-
endRemoveRows();
572+
const auto start = row;
573+
beginRemoveRows(QModelIndex(), start, start + notifies.size() - 1);
574+
for (int i = 0; i < notifies.size(); i++) {
575+
auto item = notifies[i];
576+
m_appNotifies.removeOne(item);
577+
item->deleteLater();
578+
}
579+
endRemoveRows();
579580

581+
}
580582
m_accessor->removeEntityByApp(appName);
583+
notify->deleteLater();
581584
}
582585

583586
void NotifyModel::clear()

panels/notification/center/translations/org.deepin.ds.notificationcenter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
<translation type="unfinished"></translation>
5858
</message>
5959
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
6067
<context>
6168
<name>notifycenter::AppNotifyItem</name>
6269
<message>

panels/notification/center/translations/org.deepin.ds.notificationcenter_ar.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ar">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="ar">
24
<context>
35
<name>GroupNotify</name>
46
<message>
@@ -7,18 +9,18 @@
79
</message>
810
<message>
911
<source>Fold</source>
10-
<translation type="unfinished"/>
12+
<translation type="unfinished"></translation>
1113
</message>
1214
<message>
1315
<source>More</source>
14-
<translation type="unfinished"/>
16+
<translation type="unfinished"></translation>
1517
</message>
1618
</context>
1719
<context>
1820
<name>NotifyCenter</name>
1921
<message>
2022
<source>No recent notifications</source>
21-
<translation type="unfinished"/>
23+
<translation type="unfinished"></translation>
2224
</message>
2325
</context>
2426
<context>
@@ -33,11 +35,11 @@
3335
</message>
3436
<message>
3537
<source>Fold</source>
36-
<translation type="unfinished"/>
38+
<translation type="unfinished"></translation>
3739
</message>
3840
<message>
3941
<source>More</source>
40-
<translation type="unfinished"/>
42+
<translation type="unfinished"></translation>
4143
</message>
4244
</context>
4345
<context>
@@ -55,11 +57,18 @@
5557
<translation>إعداد الإخطارات</translation>
5658
</message>
5759
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
5867
<context>
5968
<name>notifycenter::AppNotifyItem</name>
6069
<message>
6170
<source>Just now</source>
6271
<translation>قبل دقيقة واحدة</translation>
6372
</message>
6473
</context>
65-
</TS>
74+
</TS>

panels/notification/center/translations/org.deepin.ds.notificationcenter_az.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="az">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="az">
24
<context>
35
<name>GroupNotify</name>
46
<message>
@@ -7,18 +9,18 @@
79
</message>
810
<message>
911
<source>Fold</source>
10-
<translation type="unfinished"/>
12+
<translation type="unfinished"></translation>
1113
</message>
1214
<message>
1315
<source>More</source>
14-
<translation type="unfinished"/>
16+
<translation type="unfinished"></translation>
1517
</message>
1618
</context>
1719
<context>
1820
<name>NotifyCenter</name>
1921
<message>
2022
<source>No recent notifications</source>
21-
<translation type="unfinished"/>
23+
<translation type="unfinished"></translation>
2224
</message>
2325
</context>
2426
<context>
@@ -33,11 +35,11 @@
3335
</message>
3436
<message>
3537
<source>Fold</source>
36-
<translation type="unfinished"/>
38+
<translation type="unfinished"></translation>
3739
</message>
3840
<message>
3941
<source>More</source>
40-
<translation type="unfinished"/>
42+
<translation type="unfinished"></translation>
4143
</message>
4244
</context>
4345
<context>
@@ -55,11 +57,18 @@
5557
<translation>إعداد الإشعارات</translation>
5658
</message>
5759
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
5867
<context>
5968
<name>notifycenter::AppNotifyItem</name>
6069
<message>
6170
<source>Just now</source>
6271
<translation>الآن</translation>
6372
</message>
6473
</context>
65-
</TS>
74+
</TS>

panels/notification/center/translations/org.deepin.ds.notificationcenter_bo.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
<translation type="unfinished"></translation>
5858
</message>
5959
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
6067
<context>
6168
<name>notifycenter::AppNotifyItem</name>
6269
<message>

panels/notification/center/translations/org.deepin.ds.notificationcenter_ca.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="ca">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="ca">
24
<context>
35
<name>GroupNotify</name>
46
<message>
@@ -55,11 +57,18 @@
5557
<translation>Configuració de les notificacions</translation>
5658
</message>
5759
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
5867
<context>
5968
<name>notifycenter::AppNotifyItem</name>
6069
<message>
6170
<source>Just now</source>
6271
<translation>Ara mateix</translation>
6372
</message>
6473
</context>
65-
</TS>
74+
</TS>

panels/notification/center/translations/org.deepin.ds.notificationcenter_de.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" ?><!DOCTYPE TS><TS version="2.1" language="de">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!DOCTYPE TS>
3+
<TS version="2.1" language="de">
24
<context>
35
<name>GroupNotify</name>
46
<message>
@@ -7,18 +9,18 @@
79
</message>
810
<message>
911
<source>Fold</source>
10-
<translation type="unfinished"/>
12+
<translation type="unfinished"></translation>
1113
</message>
1214
<message>
1315
<source>More</source>
14-
<translation type="unfinished"/>
16+
<translation type="unfinished"></translation>
1517
</message>
1618
</context>
1719
<context>
1820
<name>NotifyCenter</name>
1921
<message>
2022
<source>No recent notifications</source>
21-
<translation type="unfinished"/>
23+
<translation type="unfinished"></translation>
2224
</message>
2325
</context>
2426
<context>
@@ -33,11 +35,11 @@
3335
</message>
3436
<message>
3537
<source>Fold</source>
36-
<translation type="unfinished"/>
38+
<translation type="unfinished"></translation>
3739
</message>
3840
<message>
3941
<source>More</source>
40-
<translation type="unfinished"/>
42+
<translation type="unfinished"></translation>
4143
</message>
4244
</context>
4345
<context>
@@ -55,11 +57,18 @@
5557
<translation>Benachrichtigungseinstellung</translation>
5658
</message>
5759
</context>
60+
<context>
61+
<name>OverlapNotify</name>
62+
<message>
63+
<source>Clean All</source>
64+
<translation type="unfinished"></translation>
65+
</message>
66+
</context>
5867
<context>
5968
<name>notifycenter::AppNotifyItem</name>
6069
<message>
6170
<source>Just now</source>
6271
<translation>Gerade eben</translation>
6372
</message>
6473
</context>
65-
</TS>
74+
</TS>

0 commit comments

Comments
 (0)