forked from Shinonome/dots-hyprland
booru: proper danbooru support, fix gelbooru
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import "root:/"
|
||||
import "root:/modules/common"
|
||||
import "root:/modules/common/widgets"
|
||||
import Qt.labs.platform
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Io
|
||||
import Quickshell.Hyprland
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
@@ -11,10 +13,31 @@ Button {
|
||||
id: root
|
||||
property var imageData
|
||||
property var rowHeight
|
||||
property bool manualDownload: false
|
||||
property string previewDownloadPath
|
||||
property string downloadPath
|
||||
property string nsfwPath
|
||||
property string fileName: decodeURIComponent((imageData.file_url).substring((imageData.file_url).lastIndexOf('/') + 1))
|
||||
|
||||
// onImageDataChanged: {
|
||||
// console.log("Image data changed:", imageData)
|
||||
// }
|
||||
Process {
|
||||
id: downloadProcess
|
||||
running: false
|
||||
command: ["bash", "-c", `curl '${imageData.preview_url}' -o '${previewDownloadPath}/${root.fileName}' && echo 'done'`]
|
||||
stdout: SplitParser {
|
||||
onRead: (data) => {
|
||||
console.log("Download output:", data)
|
||||
if(data.includes("done")) {
|
||||
imageObject.source = `${previewDownloadPath}/${root.fileName}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.manualDownload) {
|
||||
downloadProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
padding: 0
|
||||
implicitWidth: imageObject.width
|
||||
|
||||
@@ -17,11 +17,15 @@ Rectangle {
|
||||
property var responseData
|
||||
property var tagInputField
|
||||
|
||||
property string previewDownloadPath
|
||||
property string downloadPath
|
||||
property string nsfwPath
|
||||
|
||||
onResponseDataChanged: {
|
||||
console.log("Response data changed:", responseData)
|
||||
}
|
||||
|
||||
property real availableWidth: parent?.width
|
||||
property real availableWidth: parent.width ?? 0
|
||||
property real rowTooShortThreshold: 100
|
||||
property real imageSpacing: 5
|
||||
property real responsePadding: 5
|
||||
@@ -65,7 +69,7 @@ Rectangle {
|
||||
visible: root.responseData.page != "" && root.responseData.page > 0
|
||||
implicitWidth: Math.max(pageNumber.implicitWidth + 10 * 2, 30)
|
||||
implicitHeight: pageNumber.implicitHeight + 5 * 2
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
StyledText {
|
||||
id: pageNumber
|
||||
@@ -205,6 +209,10 @@ Rectangle {
|
||||
delegate: BooruImage {
|
||||
imageData: modelData
|
||||
rowHeight: imageRow.rowHeight
|
||||
manualDownload: root.responseData.provider == "danbooru"
|
||||
previewDownloadPath: root.previewDownloadPath
|
||||
downloadPath: root.downloadPath
|
||||
nsfwPath: root.nsfwPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user