animations: new curve

This commit is contained in:
end-4
2025-05-03 18:12:06 +02:00
parent 4a44d78389
commit 3284e41545
35 changed files with 442 additions and 236 deletions
@@ -38,32 +38,64 @@ Item {
Hyprland.dispatch(`exec mkdir -p ${previewDownloadPath}`)
}
property var allCommands: [
{
name: "clear",
description: qsTr("Clear the current list of images"),
execute: () => {
Booru.clearResponses();
}
},
{
name: "mode",
description: qsTr("Set the current API provider"),
execute: (args) => {
Booru.setProvider(args[0]);
}
},
{
name: "nsfw",
description: qsTr("Toggle NSFW mode"),
execute: () => {
ConfigOptions.sidebar.booru.allowNsfw = !ConfigOptions.sidebar.booru.allowNsfw;
}
},
{
name: "safe",
description: qsTr("Set NSFW mode to false"),
execute: () => {
ConfigOptions.sidebar.booru.allowNsfw = false;
}
},
{
name: "lewd",
description: qsTr("Set NSFW mode to true"),
execute: () => {
ConfigOptions.sidebar.booru.allowNsfw = true;
}
},
{
name: "next",
description: qsTr("Get the next page of results"),
execute: () => {
if (Booru.responses.length > 0) {
const lastResponse = Booru.responses[Booru.responses.length - 1];
root.handleInput(lastResponse.tags.join(" ") + ` ${parseInt(lastResponse.page) + 1}`);
}
}
}
]
function handleInput(inputText) {
if (inputText.startsWith(root.commandPrefix)) {
// Handle special commands
const command = inputText.split(" ")[0].substring(1);
const args = inputText.split(" ").slice(1);
if (command === "clear") {
Booru.clearResponses();
}
else if (command === "mode") {
const newProvider = args[0];
Booru.setProvider(newProvider);
}
else if (command == "nsfw") {
ConfigOptions.sidebar.booru.allowNsfw = !ConfigOptions.sidebar.booru.allowNsfw
}
else if (command == "safe") {
ConfigOptions.sidebar.booru.allowNsfw = false
}
else if (command == "lewd") {
ConfigOptions.sidebar.booru.allowNsfw = true
}
else if (command == "next") {
if (Booru.responses.length > 0) {
const lastResponse = Booru.responses[Booru.responses.length - 1]
root.handleInput(lastResponse.tags.join(" ") + ` ${parseInt(lastResponse.page) + 1}`);
}
const commandObj = root.allCommands.find(cmd => cmd.name === `${command}`);
if (commandObj) {
commandObj.execute(args);
} else {
root.addSystemMessage(qsTr("Unknown command: ") + command);
}
}
else if (inputText.trim() == "+") {
@@ -132,8 +164,9 @@ Item {
Behavior on contentY {
NumberAnimation {
id: scrollAnim
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.scroll.duration
easing.type: Appearance.animation.scroll.type
easing.bezierCurve: Appearance.animation.scroll.bezierCurve
}
}
@@ -164,8 +197,9 @@ Item {
Behavior on opacity {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
@@ -217,8 +251,9 @@ Item {
Behavior on color {
ColorAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
}
@@ -278,8 +313,9 @@ Item {
Behavior on implicitHeight {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
@@ -324,6 +360,15 @@ Item {
root.suggestionList = []
return
}
if(tagInputField.text.startsWith(root.commandPrefix)) {
root.suggestionQuery = ""
root.suggestionList = root.allCommands.filter(cmd => cmd.name.startsWith(tagInputField.text.substring(1))).map(cmd => {
return {
name: `${root.commandPrefix}${cmd.name}`,
}
})
return
}
searchTimer.restart();
}
@@ -383,8 +428,9 @@ Item {
Behavior on color {
ColorAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
}
@@ -409,13 +455,13 @@ Item {
anchors.rightMargin: 5
spacing: 5
property var commands: [
property var commandsShown: [
{
name: "/mode",
name: "mode",
sendDirectly: false,
},
{
name: "/clear",
name: "clear",
sendDirectly: true,
},
]
@@ -493,10 +539,11 @@ Item {
Repeater { // Command buttons
id: commandRepeater
model: commandButtonsRow.commands
model: commandButtonsRow.commandsShown
delegate: BooruTagButton {
id: tagButton
buttonText: modelData.name
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
background: Rectangle {
radius: Appearance.rounding.small
color: tagButton.down ? Appearance.colors.colLayer2Active :
@@ -505,16 +552,17 @@ Item {
Behavior on color {
ColorAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
}
onClicked: {
if(modelData.sendDirectly) {
root.handleInput(modelData.name)
root.handleInput(commandRepresentation)
} else {
tagInputField.text = modelData.name + " "
tagInputField.text = commandRepresentation + " "
tagInputField.cursorPosition = tagInputField.text.length
tagInputField.forceActiveFocus()
}
@@ -69,6 +69,8 @@ Button {
source: modelData.preview_url
width: root.rowHeight * modelData.aspect_ratio
height: root.rowHeight
visible: opacity > 0
opacity: status === Image.Ready ? 1 : 0
layer.enabled: true
layer.effect: OpacityMask {
@@ -78,6 +80,14 @@ Button {
radius: Appearance.rounding.small
}
}
Behavior on opacity {
NumberAnimation {
duration: Appearance.animation.elementMoveFast.duration
easing.type: Appearance.animation.elementMoveFast.type
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
}
}
}
Button {
@@ -111,7 +121,8 @@ Button {
Rectangle {
id: contextMenu
visible: root.showActions
opacity: root.showActions ? 1 : 0
visible: opacity > 0
radius: Appearance.rounding.small
color: Appearance.m3colors.m3surfaceContainer
anchors.top: menuButton.bottom
@@ -120,6 +131,14 @@ Button {
implicitHeight: contextMenuColumnLayout.implicitHeight + radius * 2
implicitWidth: contextMenuColumnLayout.implicitWidth
Behavior on opacity {
NumberAnimation {
duration: Appearance.animation.elementMoveFast.duration
easing.type: Appearance.animation.elementMoveFast.type
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
}
}
ColumnLayout {
id: contextMenuColumnLayout
anchors.centerIn: parent
@@ -159,5 +178,25 @@ Button {
}
}
DropShadow {
opacity: root.showActions ? 1 : 0
visible: opacity > 0
anchors.fill: contextMenu
source: contextMenu
radius: Appearance.sizes.elevationMargin
samples: radius * 2 + 1
color: Appearance.colors.colShadow
verticalOffset: 2
horizontalOffset: 0
Behavior on opacity {
NumberAnimation {
duration: Appearance.animation.elementMoveFast.duration
easing.type: Appearance.animation.elementMoveFast.type
easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve
}
}
}
}
}
@@ -105,14 +105,16 @@ Rectangle {
Behavior on height {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}
Behavior on implicitHeight {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
duration: Appearance.animation.elementMove.duration
easing.type: Appearance.animation.elementMove.type
easing.bezierCurve: Appearance.animation.elementMove.bezierCurve
}
}