mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
booru: next button/command
This commit is contained in:
@@ -19,6 +19,7 @@ Item {
|
||||
property string previewDownloadPath: `${StandardPaths.standardLocations(StandardPaths.CacheLocation)[0]}/media/waifus`.replace("file://", "")
|
||||
property string downloadPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework").replace("file://", "")
|
||||
property string nsfwPath: (StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + "/homework/🌶️").replace("file://", "")
|
||||
property real scrollOnNewResponse: 100
|
||||
|
||||
Component.onCompleted: {
|
||||
Hyprland.dispatch(`exec rm -rf ${previewDownloadPath}`)
|
||||
@@ -46,7 +47,18 @@ Item {
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (inputText.trim() == "+") {
|
||||
if (Booru.responses.length > 0) {
|
||||
const lastResponse = Booru.responses[Booru.responses.length - 1]
|
||||
root.handleInput(lastResponse.tags.join(" ") + ` ${parseInt(lastResponse.page) + 1}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Create tag list
|
||||
@@ -92,7 +104,9 @@ Item {
|
||||
ListView { // Booru responses
|
||||
id: booruResponseListView
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
|
||||
property int lastResponseLength: 0
|
||||
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Rectangle {
|
||||
@@ -112,7 +126,14 @@ Item {
|
||||
|
||||
spacing: 10
|
||||
model: ScriptModel {
|
||||
values: Booru.responses
|
||||
values: {
|
||||
if(Booru.responses.length > booruResponseListView.lastResponseLength) {
|
||||
if (booruResponseListView.lastResponseLength > 0 && Booru.responses[booruResponseListView.lastResponseLength].provider != "system")
|
||||
booruResponseListView.contentY = booruResponseListView.contentY + root.scrollOnNewResponse
|
||||
booruResponseListView.lastResponseLength = Booru.responses.length
|
||||
}
|
||||
return Booru.responses
|
||||
}
|
||||
}
|
||||
delegate: BooruResponse {
|
||||
responseData: modelData
|
||||
@@ -197,6 +218,11 @@ Item {
|
||||
|
||||
background: Item {}
|
||||
|
||||
function accept() {
|
||||
root.handleInput(text)
|
||||
text = ""
|
||||
}
|
||||
|
||||
Keys.onPressed: (event) => {
|
||||
if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
|
||||
if (event.modifiers & Qt.ShiftModifier) {
|
||||
|
||||
@@ -91,9 +91,9 @@ Button {
|
||||
PointingHandInteraction {}
|
||||
|
||||
background: Rectangle {
|
||||
color: menuButton.down ? Appearance.mix(Appearance.colors.colScrim, Appearance.m3colors.m3onSurface, 0.6) :
|
||||
menuButton.hovered ? Appearance.mix(Appearance.colors.colScrim, Appearance.m3colors.m3onSurface, 0.8) :
|
||||
Appearance.colors.colScrim
|
||||
color: menuButton.down ? Appearance.transparentize(Appearance.mix(Appearance.m3colors.m3surface, Appearance.m3colors.m3onSurface, 0.6), 0.1) :
|
||||
menuButton.hovered ? Appearance.transparentize(Appearance.mix(Appearance.m3colors.m3surface, Appearance.m3colors.m3onSurface, 0.8), 0.2) :
|
||||
Appearance.transparentize(Appearance.m3colors.m3surface, 0.3)
|
||||
radius: Appearance.rounding.full
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ Button {
|
||||
buttonText: "Open file link"
|
||||
onClicked: {
|
||||
root.showActions = false
|
||||
Hyprland.dispatch("global quickshell:sidebarLeftClose")
|
||||
// Hyprland.dispatch("global quickshell:sidebarLeftClose")
|
||||
Hyprland.dispatch(`exec xdg-open '${root.imageData.file_url}'`)
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ Button {
|
||||
buttonText: "Download"
|
||||
onClicked: {
|
||||
root.showActions = false
|
||||
Hyprland.dispatch("global quickshell:sidebarLeftClose")
|
||||
// Hyprland.dispatch("global quickshell:sidebarLeftClose")
|
||||
Hyprland.dispatch(`exec curl '${root.imageData.file_url}' -o '${root.imageData.is_nsfw ? root.nsfwPath : root.downloadPath}/${root.fileName}' && notify-send 'Download complete' '${root.downloadPath}/${root.fileName}'`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,5 +218,44 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button { // Next page button
|
||||
id: button
|
||||
property string buttonText
|
||||
visible: root.responseData.page != "" && root.responseData.page > 0
|
||||
|
||||
Layout.alignment: Qt.AlignRight
|
||||
implicitHeight: 30
|
||||
leftPadding: 10
|
||||
rightPadding: 10
|
||||
|
||||
PointingHandInteraction {}
|
||||
onClicked: {
|
||||
tagInputField.text = `${responseData.tags.join(" ")} ${parseInt(root.responseData.page) + 1}`
|
||||
tagInputField.accept()
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
radius: Appearance.rounding.small
|
||||
color: (button.down ? Appearance.colors.colSurfaceContainerHighestActive :
|
||||
button.hovered ? Appearance.colors.colSurfaceContainerHighestHover :
|
||||
Appearance.m3colors.m3surfaceContainerHighest)
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: 0
|
||||
StyledText {
|
||||
Layout.alignment: Text.AlignVCenter
|
||||
text: "Next page"
|
||||
color: Appearance.m3colors.m3onSurface
|
||||
}
|
||||
MaterialSymbol {
|
||||
Layout.alignment: Text.AlignVCenter
|
||||
font.pixelSize: Appearance.font.pixelSize.larger
|
||||
color: Appearance.m3colors.m3onSurface
|
||||
text: "chevron_right"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user