notification center: swipe-right dismiss, cascading clear-all
This commit is contained in:
parent
a6d95ffdaf
commit
f65bd90bfd
1 changed files with 73 additions and 12 deletions
|
|
@ -58,12 +58,42 @@ M.PopupPanel {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: M.NotifService.dismissAll()
|
onClicked: menuWindow._cascadeDismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var _delegates: []
|
||||||
|
|
||||||
|
function _cascadeDismiss() {
|
||||||
|
const dels = _delegates.filter(d => d && d.modelData && !d.modelData.closed);
|
||||||
|
for (let i = 0; i < dels.length; i++) {
|
||||||
|
const d = dels[i];
|
||||||
|
const delay = i * 60;
|
||||||
|
Qt.callLater(() => {
|
||||||
|
_cascadeTimer.createObject(menuWindow, {
|
||||||
|
_target: d,
|
||||||
|
_delay: delay
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property Component _cascadeTimer: Component {
|
||||||
|
Timer {
|
||||||
|
property var _target
|
||||||
|
property int _delay
|
||||||
|
interval: _delay
|
||||||
|
running: true
|
||||||
|
onTriggered: {
|
||||||
|
if (_target && _target._dismissAnim)
|
||||||
|
_target._dismissAnim.start();
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: menuWindow.panelWidth - 16
|
width: menuWindow.panelWidth - 16
|
||||||
|
|
@ -82,10 +112,23 @@ M.PopupPanel {
|
||||||
required property int index
|
required property int index
|
||||||
|
|
||||||
width: menuWindow.panelWidth
|
width: menuWindow.panelWidth
|
||||||
height: notifContent.height + 12
|
height: _targetHeight * _heightScale
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
readonly property real _targetHeight: notifContent.height + 12
|
||||||
|
property real _heightScale: 1
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
menuWindow._delegates.push(notifItem);
|
||||||
|
fadeIn.start();
|
||||||
|
}
|
||||||
|
Component.onDestruction: {
|
||||||
|
const idx = menuWindow._delegates.indexOf(notifItem);
|
||||||
|
if (idx >= 0)
|
||||||
|
menuWindow._delegates.splice(idx, 1);
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: fadeIn.start()
|
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
id: fadeIn
|
id: fadeIn
|
||||||
target: notifItem
|
target: notifItem
|
||||||
|
|
@ -93,8 +136,6 @@ M.PopupPanel {
|
||||||
to: 1
|
to: 1
|
||||||
duration: 150
|
duration: 150
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
// Stagger by index
|
|
||||||
Component.onCompleted: fadeIn.from = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
@ -242,14 +283,34 @@ M.PopupPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberAnimation {
|
SequentialAnimation {
|
||||||
id: _dismissAnim
|
id: _dismissAnim
|
||||||
target: notifItem
|
ParallelAnimation {
|
||||||
property: "opacity"
|
NumberAnimation {
|
||||||
to: 0
|
target: notifItem
|
||||||
duration: 150
|
property: "x"
|
||||||
easing.type: Easing.InCubic
|
to: menuWindow.panelWidth
|
||||||
onFinished: M.NotifService.dismiss(notifItem.modelData.id)
|
duration: 200
|
||||||
|
easing.type: Easing.InCubic
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
target: notifItem
|
||||||
|
property: "opacity"
|
||||||
|
to: 0
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.InCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
target: notifItem
|
||||||
|
property: "_heightScale"
|
||||||
|
to: 0
|
||||||
|
duration: 150
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
ScriptAction {
|
||||||
|
script: M.NotifService.dismiss(notifItem.modelData.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue