Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions panels/notification/bubble/bubblepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ void BubblePanel::invokeAction(int bubbleIndex, const QString &actionId)
onActionInvoked(bubble->id(), bubble->bubbleId(), actionId);
}

void BubblePanel::close(int bubbleIndex)
void BubblePanel::close(int bubbleIndex, int reason)
{
auto bubble = bubbleItem(bubbleIndex);
if (!bubble)
return;

m_bubbles->remove(bubbleIndex);
onBubbleClosed(bubble->id(), bubble->bubbleId(), NotifyEntity::Closed);
onBubbleClosed(bubble->id(), bubble->bubbleId(), reason);
}

void BubblePanel::delayProcess(int bubbleIndex)
Expand Down
2 changes: 1 addition & 1 deletion panels/notification/bubble/bubblepanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BubblePanel : public DS_NAMESPACE::DPanel

public Q_SLOTS:
void invokeAction(int bubbleIndex, const QString &actionId);
void close(int bubbleIndex);
void close(int bubbleIndex, int reason);
void delayProcess(int bubbleIndex);
void setEnabled(bool newEnabled);

Expand Down
31 changes: 6 additions & 25 deletions panels/notification/bubble/package/NormalBubble.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,22 @@ NotifyItemContent {
iconName: bubble.iconName
date: bubble.timeTip
actions: bubble.actions
defaultAction: bubble.defaultAction
title: bubble.summary
content: bubble.body
strongInteractive: bubble.urgency === 2
contentIcon: bubble.bodyImagePath
contentRowCount: bubble.contentRowCount
onRemove: function () {
console.log("remove notify", bubble.appName)
Applet.close(bubble.index)
Applet.close(bubble.index, NotifyItem.Closed)
}
onDismiss: function () {
console.log("dismiss notify", bubble.appName)
Applet.close(bubble.index, NotifyItem.Dismissed)
}
onActionInvoked: function (actionId) {
console.log("action notify", bubble.appName, actionId)
Applet.invokeAction(bubble.index, actionId)
}

MouseArea {
anchors.fill: parent
hoverEnabled: true
z: -1 // default action
onClicked: {
if (!bubble.defaultAction)
return

console.log("default action notify", bubble.appName, bubble.defaultAction)
Applet.invokeAction(bubble.index, bubble.defaultAction)
}
property bool longPressed
onPressAndHold: {
longPressed = true
}
onPositionChanged: {
if (longPressed) {
longPressed = false
console.log("delay process", bubble.index)
Applet.delayProcess(bubble.index)
}
}
}
}
17 changes: 15 additions & 2 deletions panels/notification/center/NormalNotify.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.deepin.ds.notificationcenter
NotifyItem {
id: root

property var removedCallback

states: [
State {
name: "removing"
Expand All @@ -26,8 +28,9 @@ NotifyItem {
NumberAnimation { properties: "opacity"; duration: 300; easing.type: Easing.Linear }
}
onRunningChanged: {
if (!running) {
root.remove()
if (!running && root.removedCallback) {
root.removedCallback()
root.removedCallback = undefined
}
}
}
Expand All @@ -40,12 +43,22 @@ NotifyItem {
title: root.title
date: root.date
actions: root.actions
defaultAction: root.defaultAction
closeVisible: root.hovered || root.activeFocus
strongInteractive: root.strongInteractive
contentIcon: root.contentIcon
contentRowCount: root.contentRowCount

onRemove: function () {
root.removedCallback = function () {
root.remove()
}
root.state = "removing"
}
onDismiss: function () {
root.removedCallback = function () {
root.dismiss()
}
root.state = "removing"
}
onActionInvoked: function (actionId) {
Expand Down
7 changes: 6 additions & 1 deletion panels/notification/center/NotifyStaging.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ FocusScope {
iconName: model.iconName
date: model.time
actions: model.actions
defaultAction: model.defaultAction
title: model.title
content: model.content
strongInteractive: model.strongInteractive
Expand All @@ -48,7 +49,11 @@ FocusScope {

onRemove: function () {
console.log("remove overlap", model.id)
notifyModel.closeNotify(model.id)
notifyModel.closeNotify(model.id, NotifyItem.Closed)
}
onDismiss: function () {
console.log("dismiss overlap", model.id)
notifyModel.closeNotify(model.id, NotifyItem.Dismissed)
}
onActionInvoked: function (actionId) {
console.log("action overlap", model.id, actionId)
Expand Down
22 changes: 8 additions & 14 deletions panels/notification/center/NotifyViewDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@ DelegateChooser {
strongInteractive: model.strongInteractive
contentIcon: model.contentIcon
contentRowCount: model.contentRowCount
property string defaultAction: model.defaultAction

function invokeAction(actionId) {
console.log("action normal", model.id, actionId)
notifyModel.invokeAction(model.id, actionId)
}
defaultAction: model.defaultAction

Loader {
anchors.fill: parent
Expand All @@ -98,13 +93,6 @@ DelegateChooser {
}
}

// default action
TapHandler {
enabled: model.defaultAction !== ""
acceptedButtons: Qt.LeftButton
onTapped: invokeAction(model.defaultAction)
}

onSetting: function (pos) {
let tmp = mapToItem(root.view, pos)
root.setting(tmp, {
Expand All @@ -116,8 +104,13 @@ DelegateChooser {
console.log("remove normal", model.id)
notifyModel.remove(model.id)
}
onDismiss: function () {
console.log("dismiss normal", model.id)
notifyModel.remove(model.id)
}
onActionInvoked: function (actionId) {
invokeAction(actionId)
console.log("action normal", model.id, actionId)
notifyModel.invokeAction(model.id, actionId)
}
}
}
Expand All @@ -141,6 +134,7 @@ DelegateChooser {
strongInteractive: model.strongInteractive
contentIcon: model.contentIcon
contentRowCount: model.contentRowCount
enableDismissed: false

Loader {
anchors.fill: parent
Expand Down
19 changes: 17 additions & 2 deletions panels/notification/center/OverlapNotify.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ NotifyItem {

property int count: 1
readonly property int overlapItemRadius: 12
property bool enableDismissed: true
property var removedCallback

signal expand()

Expand All @@ -31,8 +33,9 @@ NotifyItem {
NumberAnimation { properties: "opacity"; duration: 300; easing.type: Easing.Linear }
}
onRunningChanged: {
if (!running) {
root.remove()
if (!running && root.removedCallback) {
root.removedCallback()
root.removedCallback = undefined
}
}
}
Expand All @@ -49,12 +52,23 @@ NotifyItem {
title: root.title
date: root.date
actions: root.actions
defaultAction: root.defaultAction
closeVisible: root.hovered || root.activeFocus
strongInteractive: root.strongInteractive
contentIcon: root.contentIcon
contentRowCount: root.contentRowCount
enableDismissed: root.enableDismissed

onRemove: function () {
root.removedCallback = function () {
root.remove()
}
root.state = "removing"
}
onDismiss: function () {
root.removedCallback = function () {
root.dismiss()
}
root.state = "removing"
}
onActionInvoked: function (actionId) {
Expand All @@ -78,6 +92,7 @@ NotifyItem {

// expand
TapHandler {
enabled: !root.enableDismissed
acceptedButtons: Qt.LeftButton
onTapped: root.expand()
}
Expand Down
5 changes: 2 additions & 3 deletions panels/notification/center/notifyaccessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,13 @@ void NotifyAccessor::clear()
}
}

void NotifyAccessor::closeNotify(const NotifyEntity &entity)
void NotifyAccessor::closeNotify(const NotifyEntity &entity, NotifyEntity::ClosedReason reason)
{
if (!m_dataUpdater)
return;
const auto id = entity.id();
const auto bubbleId = entity.bubbleId();
QMetaObject::invokeMethod(m_dataUpdater, "notificationClosed", Qt::DirectConnection,
Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, NotifyEntity::Closed));
QMetaObject::invokeMethod(m_dataUpdater, "notificationClosed", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason));
}

void NotifyAccessor::invokeNotify(const NotifyEntity &entity, const QString &actionId)
Expand Down
2 changes: 1 addition & 1 deletion panels/notification/center/notifyaccessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class NotifyAccessor : public QObject
void removeEntityByApp(const QString &appName);
void clear();

void closeNotify(const NotifyEntity &entity);
void closeNotify(const NotifyEntity &entity, NotifyEntity::ClosedReason reason);
void invokeNotify(const NotifyEntity &entity, const QString &actionId);

signals:
Expand Down
4 changes: 2 additions & 2 deletions panels/notification/center/notifystagingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ void NotifyStagingModel::push(const NotifyEntity &entity)
}
}

void NotifyStagingModel::closeNotify(qint64 id)
void NotifyStagingModel::closeNotify(qint64 id, int reason)
{
auto entity = m_accessor->fetchEntity(id);
if (entity.isValid()) {
NotifyAccessor::instance()->closeNotify(entity);
NotifyAccessor::instance()->closeNotify(entity, static_cast<NotifyEntity::ClosedReason>(reason));
}
remove(id);
}
Expand Down
2 changes: 1 addition & 1 deletion panels/notification/center/notifystagingmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class NotifyStagingModel : public QAbstractListModel
};
NotifyStagingModel(QObject *parent = nullptr);

Q_INVOKABLE void closeNotify(qint64 id);
Q_INVOKABLE void closeNotify(qint64 id, int reason);
Q_INVOKABLE void invokeNotify(qint64 id, const QString &actionId);
Q_INVOKABLE void open();
Q_INVOKABLE void close();
Expand Down
9 changes: 9 additions & 0 deletions panels/notification/plugin/NotifyItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import org.deepin.ds.notification
Control {
id: root

enum CloseReason {
Expired = 1,
Dismissed = 2,
Closed = 3,
Unknown = 4
}

property string appName: "deepin-editor"
property string iconName: "deepin-editor"
property string content: "content"
Expand All @@ -21,11 +28,13 @@ Control {
{text: "close", id: "close"},
{text: "exec", id: "exec"}
]
property string defaultAction
property bool strongInteractive: false
property string contentIcon: "deepin-editor"
property int contentRowCount: 6

signal remove()
signal dismiss()
signal setting(var pos)
signal actionInvoked(var actionId)
signal linkActivated(var link)
Expand Down
26 changes: 26 additions & 0 deletions panels/notification/plugin/NotifyItemContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ NotifyItem {

property bool closeVisible: root.hovered || root.activeFocus
property int miniContentHeight: NotifyStyle.contentItem.miniHeight
property bool enableDismissed: true

Item {
anchors.fill: parent
z: -1
enabled: root.enableDismissed
TapHandler {
property bool isLongPressed
gesturePolicy: TapHandler.ReleaseWithinBounds
onCanceled: function () {
if (isLongPressed) {
console.log("Dissmiss notify", root.appName, isLongPressed)
root.dismiss()
}
isLongPressed = false
}
onLongPressed: isLongPressed = true
onTapped: function () {
if (!root.defaultAction)
return

console.log("Click default action notify", root.appName, root.defaultAction)
root.actionInvoked(root.defaultAction)
}
}
}

// placeHolder to receive MouseEvent
Control {
Expand Down
9 changes: 4 additions & 5 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,9 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
return 0;
}

QString tsAppName{appName};
auto appNameValue = m_setting->appValue(appId, NotificationSetting::AppName);
if (!appNameValue.isNull()) {
tsAppName = appNameValue.toString();
auto tsAppName = m_setting->appValue(appId, NotificationSetting::AppName).toString();
if (tsAppName.isEmpty()) {
tsAppName = appName;
}

QString strBody = body;
Expand Down Expand Up @@ -428,7 +427,7 @@ void NotificationManager::updateEntityProcessed(qint64 id, uint reason)
{
auto entity = m_persistence->fetchEntity(id);
if (entity.isValid()) {
if (reason == NotifyEntity::Closed && entity.processedType() == NotifyEntity::NotProcessed) {
if ((reason == NotifyEntity::Closed || reason == NotifyEntity::Dismissed) && entity.processedType() == NotifyEntity::NotProcessed) {
entity.setProcessedType(NotifyEntity::Removed);
} else {
entity.setProcessedType(NotifyEntity::Processed);
Expand Down
Loading