sidebar: anime: fix loading indicator showing when navigating w/ keys

This commit is contained in:
end-4
2025-10-29 11:04:00 +01:00
parent 7b278aeff7
commit 8b10ec2cfb
5 changed files with 17 additions and 15 deletions
@@ -13,13 +13,14 @@ Item {
text: Qt.locale().toString(DateTime.clock.date, root.isMonth ? "MM" : "d") text: Qt.locale().toString(DateTime.clock.date, root.isMonth ? "MM" : "d")
MaterialCookie { MaterialShape {
id: bubble
z: 5 z: 5
sides: root.isMonth ? 1 : 4 // sides: root.isMonth ? 1 : 4
shape: root.isMonth ? MaterialShape.Shape.Pill : MaterialShape.Shape.Pentagon
anchors.centerIn: parent anchors.centerIn: parent
color: root.isMonth ? Appearance.colors.colPrimaryContainer : Appearance.colors.colTertiaryContainer color: root.isMonth ? Appearance.colors.colPrimaryContainer : Appearance.colors.colTertiaryContainer
implicitSize: targetSize implicitSize: targetSize
constantlyRotate: Config.options.background.clock.cookie.constantlyRotate
} }
StyledText { StyledText {
@@ -16,8 +16,8 @@ Rectangle {
implicitHeight: implicitSize implicitHeight: implicitSize
radius: Math.min(width, height) / 2 radius: Math.min(width, height) / 2
color: Appearance.colors.colPrimaryContainer color: Appearance.colors.colPrimaryContainer
property double baseShapeSize: root.implicitSize * 1.3 property double baseShapeSize: root.implicitSize * 0.7
property double leapZoomSize: root.baseShapeSize * 1.3 property double leapZoomSize: root.baseShapeSize * 1.2
property double leapZoomProgress: 0 property double leapZoomProgress: 0
// Shape // Shape
@@ -80,7 +80,6 @@ Rectangle {
const leapZoomDiff = root.leapZoomSize - root.baseShapeSize const leapZoomDiff = root.leapZoomSize - root.baseShapeSize
const progressFirstHalf = Math.min(root.leapZoomProgress, 0.5) * 2; const progressFirstHalf = Math.min(root.leapZoomProgress, 0.5) * 2;
const progressSecondHalf = Math.max(root.leapZoomProgress - 0.5, 0) * 2; const progressSecondHalf = Math.max(root.leapZoomProgress - 0.5, 0) * 2;
print("progress", root.leapZoomProgress, "zoom", root.baseShapeSize + leapZoomDiff * progressFirstHalf - leapZoomDiff * progressSecondHalf)
return root.baseShapeSize + leapZoomDiff * progressFirstHalf - leapZoomDiff * progressSecondHalf; return root.baseShapeSize + leapZoomDiff * progressFirstHalf - leapZoomDiff * progressSecondHalf;
} }
color: Appearance.colors.colOnPrimaryContainer color: Appearance.colors.colOnPrimaryContainer
@@ -75,7 +75,7 @@ StyledFlickable {
NumberAnimation { NumberAnimation {
target: materialShape target: materialShape
properties: "implicitSize" properties: "implicitSize"
to: 34 to: 18
easing.type: Easing.BezierSpline easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.animationCurves.expressiveFastSpatial easing.bezierCurve: Appearance.animationCurves.expressiveFastSpatial
} }
@@ -25,7 +25,7 @@ Item {
property bool pullLoading: false property bool pullLoading: false
property int pullLoadingGap: 80 property int pullLoadingGap: 80
property real normalizedPullDistance: Math.max(0, (1 - Math.exp(-booruResponseListView.verticalOvershoot / 50))) property real normalizedPullDistance: Math.max(0, (1 - Math.exp(-booruResponseListView.verticalOvershoot / 50)) * booruResponseListView.dragging)
Connections { Connections {
target: Booru target: Booru
@@ -96,10 +96,7 @@ Item {
} }
} }
else if (inputText.trim() == "+") { else if (inputText.trim() == "+") {
if (root.responses.length > 0) { root.handleInput(`${root.commandPrefix}next`);
const lastResponse = root.responses[root.responses.length - 1]
root.handleInput(lastResponse.tags.join(" ") + ` ${parseInt(lastResponse.page) + 1}`);
}
} }
else { else {
// Create tag list // Create tag list
@@ -126,13 +123,18 @@ Item {
tagInputField.forceActiveFocus() tagInputField.forceActiveFocus()
if (event.modifiers === Qt.NoModifier) { if (event.modifiers === Qt.NoModifier) {
if (event.key === Qt.Key_PageUp) { if (event.key === Qt.Key_PageUp) {
if (booruResponseListView.atYBeginning) return;
booruResponseListView.contentY = Math.max(0, booruResponseListView.contentY - booruResponseListView.height / 2) booruResponseListView.contentY = Math.max(0, booruResponseListView.contentY - booruResponseListView.height / 2)
event.accepted = true event.accepted = true
} else if (event.key === Qt.Key_PageDown) { } else if (event.key === Qt.Key_PageDown) {
if (booruResponseListView.atYEnd) return;
booruResponseListView.contentY = Math.min(booruResponseListView.contentHeight - booruResponseListView.height / 2, booruResponseListView.contentY + booruResponseListView.height / 2) booruResponseListView.contentY = Math.min(booruResponseListView.contentHeight - booruResponseListView.height / 2, booruResponseListView.contentY + booruResponseListView.height / 2)
event.accepted = true event.accepted = true
} }
} }
if ((event.modifiers & Qt.ControlModifier) && (event.modifiers & Qt.ShiftModifier) && event.key === Qt.Key_O) {
Booru.clearResponses()
}
} }
@@ -217,7 +219,7 @@ Item {
anchors { anchors {
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
bottom: parent.bottom bottom: parent.bottom
bottomMargin: 20 + (root.pullLoading ? 0 : Math.max(0, (root.normalizedPullDistance - 0.5) * 36)) bottomMargin: 20 + (root.pullLoading ? 0 : Math.max(0, (root.normalizedPullDistance - 0.5) * 50))
Behavior on bottomMargin { Behavior on bottomMargin {
NumberAnimation { NumberAnimation {
duration: 200 duration: 200
@@ -227,7 +229,7 @@ Item {
} }
} }
loading: root.pullLoading || Booru.runningRequests > 0 loading: root.pullLoading || Booru.runningRequests > 0
pullProgress: Math.min(1, booruResponseListView.verticalOvershoot / root.pullLoadingGap) pullProgress: Math.min(1, booruResponseListView.verticalOvershoot / root.pullLoadingGap * booruResponseListView.dragging)
scale: root.pullLoading ? 1 : Math.min(1, root.normalizedPullDistance * 2) scale: root.pullLoading ? 1 : Math.min(1, root.normalizedPullDistance * 2)
} }
} }