feat: better notification storage and image caching + blobs
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 11s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 10s
Python / static (pull_request) Failing after 27s
Rust / build (pull_request) Successful in 54s
Python / verify (pull_request) Failing after 1m26s
Rust / fmt (pull_request) Successful in 46s
Rust / clippy (pull_request) Successful in 1m6s
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 11s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 10s
Python / static (pull_request) Failing after 27s
Rust / build (pull_request) Successful in 54s
Python / verify (pull_request) Failing after 1m26s
Rust / fmt (pull_request) Successful in 46s
Rust / clippy (pull_request) Successful in 1m6s
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import ZShell.Config
|
||||
import qs.Components
|
||||
|
||||
MouseArea {
|
||||
id: root
|
||||
|
||||
required property bool expanded
|
||||
property bool expandable: true
|
||||
property bool dragExpand: expandable
|
||||
property bool hoveringLink
|
||||
property int startY
|
||||
property real lastX
|
||||
property real lastMoveTime
|
||||
property real velocity
|
||||
|
||||
signal swiped
|
||||
signal dismissed
|
||||
signal requestExpand(expand: bool)
|
||||
|
||||
hoverEnabled: true
|
||||
cursorShape: hoveringLink ? Qt.PointingHandCursor : pressedButtons === Qt.LeftButton ? Qt.ClosedHandCursor : undefined
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
preventStealing: dragExpand
|
||||
|
||||
drag.target: pressedButtons === Qt.LeftButton ? this : null
|
||||
drag.axis: Drag.XAxis
|
||||
|
||||
onPressed: event => {
|
||||
startY = event.y;
|
||||
lastX = x;
|
||||
lastMoveTime = Date.now();
|
||||
velocity = 0;
|
||||
if (event.button === Qt.RightButton && expandable)
|
||||
requestExpand(!expanded);
|
||||
else if (event.button === Qt.MiddleButton)
|
||||
dismissed();
|
||||
}
|
||||
onPositionChanged: event => {
|
||||
if (pressedButtons !== Qt.LeftButton)
|
||||
return;
|
||||
|
||||
const now = Date.now();
|
||||
const dt = now - lastMoveTime;
|
||||
if (dt > 0) {
|
||||
velocity = (velocity + (x - lastX) / dt * 1000) / 2;
|
||||
lastX = x;
|
||||
lastMoveTime = now;
|
||||
}
|
||||
|
||||
if (dragExpand) {
|
||||
const diffY = event.y - startY;
|
||||
if (Math.abs(diffY) > Config.notifs.expandThreshold)
|
||||
requestExpand(diffY > 0);
|
||||
}
|
||||
}
|
||||
onReleased: {
|
||||
const flung = Date.now() - lastMoveTime < 100 && Math.sign(velocity) === Math.sign(x) && Math.abs(velocity) > Config.notifs.clearVelocity;
|
||||
if (!flung && Math.abs(x) < width * Config.notifs.clearThreshold)
|
||||
x = 0;
|
||||
else
|
||||
swiped();
|
||||
}
|
||||
|
||||
Behavior on x {
|
||||
Anim {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user