Skip to content

Commit f50737a

Browse files
committed
fix: missing dismissed to close notify for notication
Dismissed notify doesn't move to notification center. Disable dismissed of overlap notification for notification center. pms: TASK-366403
1 parent 3b73293 commit f50737a

14 files changed

+100
-59
lines changed

panels/notification/bubble/bubblepanel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ void BubblePanel::invokeAction(int bubbleIndex, const QString &actionId)
7676
onActionInvoked(bubble->id(), bubble->bubbleId(), actionId);
7777
}
7878

79-
void BubblePanel::close(int bubbleIndex)
79+
void BubblePanel::close(int bubbleIndex, int reason)
8080
{
8181
auto bubble = bubbleItem(bubbleIndex);
8282
if (!bubble)
8383
return;
8484

8585
m_bubbles->remove(bubbleIndex);
86-
onBubbleClosed(bubble->id(), bubble->bubbleId(), NotifyEntity::Closed);
86+
onBubbleClosed(bubble->id(), bubble->bubbleId(), reason);
8787
}
8888

8989
void BubblePanel::delayProcess(int bubbleIndex)

panels/notification/bubble/bubblepanel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BubblePanel : public DS_NAMESPACE::DPanel
3636

3737
public Q_SLOTS:
3838
void invokeAction(int bubbleIndex, const QString &actionId);
39-
void close(int bubbleIndex);
39+
void close(int bubbleIndex, int reason);
4040
void delayProcess(int bubbleIndex);
4141
void setEnabled(bool newEnabled);
4242

panels/notification/bubble/package/NormalBubble.qml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,22 @@ NotifyItemContent {
1818
iconName: bubble.iconName
1919
date: bubble.timeTip
2020
actions: bubble.actions
21+
defaultAction: bubble.defaultAction
2122
title: bubble.summary
2223
content: bubble.body
2324
strongInteractive: bubble.urgency === 2
2425
contentIcon: bubble.bodyImagePath
2526
contentRowCount: bubble.contentRowCount
2627
onRemove: function () {
2728
console.log("remove notify", bubble.appName)
28-
Applet.close(bubble.index)
29+
Applet.close(bubble.index, NotifyItem.Closed)
30+
}
31+
onDismiss: function () {
32+
console.log("dismiss notify", bubble.appName)
33+
Applet.close(bubble.index, NotifyItem.Dismissed)
2934
}
3035
onActionInvoked: function (actionId) {
3136
console.log("action notify", bubble.appName, actionId)
3237
Applet.invokeAction(bubble.index, actionId)
3338
}
34-
35-
MouseArea {
36-
anchors.fill: parent
37-
hoverEnabled: true
38-
z: -1 // default action
39-
onClicked: {
40-
if (!bubble.defaultAction)
41-
return
42-
43-
console.log("default action notify", bubble.appName, bubble.defaultAction)
44-
Applet.invokeAction(bubble.index, bubble.defaultAction)
45-
}
46-
property bool longPressed
47-
onPressAndHold: {
48-
longPressed = true
49-
}
50-
onPositionChanged: {
51-
if (longPressed) {
52-
longPressed = false
53-
console.log("delay process", bubble.index)
54-
Applet.delayProcess(bubble.index)
55-
}
56-
}
57-
}
5839
}

panels/notification/center/NormalNotify.qml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import org.deepin.ds.notificationcenter
1212
NotifyItem {
1313
id: root
1414

15+
property var removedCallback
16+
1517
states: [
1618
State {
1719
name: "removing"
@@ -26,8 +28,9 @@ NotifyItem {
2628
NumberAnimation { properties: "opacity"; duration: 300; easing.type: Easing.Linear }
2729
}
2830
onRunningChanged: {
29-
if (!running) {
30-
root.remove()
31+
if (!running && root.removedCallback) {
32+
root.removedCallback()
33+
root.removedCallback = undefined
3134
}
3235
}
3336
}
@@ -40,12 +43,22 @@ NotifyItem {
4043
title: root.title
4144
date: root.date
4245
actions: root.actions
46+
defaultAction: root.defaultAction
4347
closeVisible: root.hovered || root.activeFocus
4448
strongInteractive: root.strongInteractive
4549
contentIcon: root.contentIcon
4650
contentRowCount: root.contentRowCount
4751

4852
onRemove: function () {
53+
root.removedCallback = function () {
54+
root.remove()
55+
}
56+
root.state = "removing"
57+
}
58+
onDismiss: function () {
59+
root.removedCallback = function () {
60+
root.dismiss()
61+
}
4962
root.state = "removing"
5063
}
5164
onActionInvoked: function (actionId) {

panels/notification/center/NotifyStaging.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ FocusScope {
4040
iconName: model.iconName
4141
date: model.time
4242
actions: model.actions
43+
defaultAction: model.defaultAction
4344
title: model.title
4445
content: model.content
4546
strongInteractive: model.strongInteractive
@@ -48,7 +49,11 @@ FocusScope {
4849

4950
onRemove: function () {
5051
console.log("remove overlap", model.id)
51-
notifyModel.closeNotify(model.id)
52+
notifyModel.closeNotify(model.id, NotifyItem.Closed)
53+
}
54+
onDismiss: function () {
55+
console.log("dismiss overlap", model.id)
56+
notifyModel.closeNotify(model.id, NotifyItem.Dismissed)
5257
}
5358
onActionInvoked: function (actionId) {
5459
console.log("action overlap", model.id, actionId)

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ DelegateChooser {
7373
strongInteractive: model.strongInteractive
7474
contentIcon: model.contentIcon
7575
contentRowCount: model.contentRowCount
76-
property string defaultAction: model.defaultAction
77-
78-
function invokeAction(actionId) {
79-
console.log("action normal", model.id, actionId)
80-
notifyModel.invokeAction(model.id, actionId)
81-
}
76+
defaultAction: model.defaultAction
8277

8378
Loader {
8479
anchors.fill: parent
@@ -98,13 +93,6 @@ DelegateChooser {
9893
}
9994
}
10095

101-
// default action
102-
TapHandler {
103-
enabled: model.defaultAction !== ""
104-
acceptedButtons: Qt.LeftButton
105-
onTapped: invokeAction(model.defaultAction)
106-
}
107-
10896
onSetting: function (pos) {
10997
let tmp = mapToItem(root.view, pos)
11098
root.setting(tmp, {
@@ -116,8 +104,13 @@ DelegateChooser {
116104
console.log("remove normal", model.id)
117105
notifyModel.remove(model.id)
118106
}
107+
onDismiss: function () {
108+
console.log("dismiss normal", model.id)
109+
notifyModel.remove(model.id)
110+
}
119111
onActionInvoked: function (actionId) {
120-
invokeAction(actionId)
112+
console.log("action normal", model.id, actionId)
113+
notifyModel.invokeAction(model.id, actionId)
121114
}
122115
}
123116
}
@@ -141,6 +134,7 @@ DelegateChooser {
141134
strongInteractive: model.strongInteractive
142135
contentIcon: model.contentIcon
143136
contentRowCount: model.contentRowCount
137+
enableDismissed: false
144138

145139
Loader {
146140
anchors.fill: parent

panels/notification/center/OverlapNotify.qml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ NotifyItem {
1414

1515
property int count: 1
1616
readonly property int overlapItemRadius: 12
17+
property bool enableDismissed: true
18+
property var removedCallback
1719

1820
signal expand()
1921

@@ -31,8 +33,9 @@ NotifyItem {
3133
NumberAnimation { properties: "opacity"; duration: 300; easing.type: Easing.Linear }
3234
}
3335
onRunningChanged: {
34-
if (!running) {
35-
root.remove()
36+
if (!running && root.removedCallback) {
37+
root.removedCallback()
38+
root.removedCallback = undefined
3639
}
3740
}
3841
}
@@ -49,12 +52,23 @@ NotifyItem {
4952
title: root.title
5053
date: root.date
5154
actions: root.actions
55+
defaultAction: root.defaultAction
5256
closeVisible: root.hovered || root.activeFocus
5357
strongInteractive: root.strongInteractive
5458
contentIcon: root.contentIcon
5559
contentRowCount: root.contentRowCount
60+
enableDismissed: root.enableDismissed
5661

5762
onRemove: function () {
63+
root.removedCallback = function () {
64+
root.remove()
65+
}
66+
root.state = "removing"
67+
}
68+
onDismiss: function () {
69+
root.removedCallback = function () {
70+
root.dismiss()
71+
}
5872
root.state = "removing"
5973
}
6074
onActionInvoked: function (actionId) {
@@ -78,6 +92,7 @@ NotifyItem {
7892

7993
// expand
8094
TapHandler {
95+
enabled: !root.enableDismissed
8196
acceptedButtons: Qt.LeftButton
8297
onTapped: root.expand()
8398
}

panels/notification/center/notifyaccessor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,13 @@ void NotifyAccessor::clear()
170170
}
171171
}
172172

173-
void NotifyAccessor::closeNotify(const NotifyEntity &entity)
173+
void NotifyAccessor::closeNotify(const NotifyEntity &entity, NotifyEntity::ClosedReason reason)
174174
{
175175
if (!m_dataUpdater)
176176
return;
177177
const auto id = entity.id();
178178
const auto bubbleId = entity.bubbleId();
179-
QMetaObject::invokeMethod(m_dataUpdater, "notificationClosed", Qt::DirectConnection,
180-
Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, NotifyEntity::Closed));
179+
QMetaObject::invokeMethod(m_dataUpdater, "notificationClosed", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason));
181180
}
182181

183182
void NotifyAccessor::invokeNotify(const NotifyEntity &entity, const QString &actionId)

panels/notification/center/notifyaccessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class NotifyAccessor : public QObject
5252
void removeEntityByApp(const QString &appName);
5353
void clear();
5454

55-
void closeNotify(const NotifyEntity &entity);
55+
void closeNotify(const NotifyEntity &entity, NotifyEntity::ClosedReason reason);
5656
void invokeNotify(const NotifyEntity &entity, const QString &actionId);
5757

5858
signals:

panels/notification/center/notifystagingmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ void NotifyStagingModel::push(const NotifyEntity &entity)
6868
}
6969
}
7070

71-
void NotifyStagingModel::closeNotify(qint64 id)
71+
void NotifyStagingModel::closeNotify(qint64 id, int reason)
7272
{
7373
auto entity = m_accessor->fetchEntity(id);
7474
if (entity.isValid()) {
75-
NotifyAccessor::instance()->closeNotify(entity);
75+
NotifyAccessor::instance()->closeNotify(entity, static_cast<NotifyEntity::ClosedReason>(reason));
7676
}
7777
remove(id);
7878
}

0 commit comments

Comments
 (0)