booru: fix image placement, gives single images big radius

the latter adds visual interest with some variation
This commit is contained in:
end-4
2025-05-24 09:51:39 +02:00
parent 1929b6dc8e
commit ac8314931f
2 changed files with 19 additions and 15 deletions
@@ -25,6 +25,7 @@ Button {
property string fileName: decodeURIComponent((imageData.file_url).substring((imageData.file_url).lastIndexOf('/') + 1)) property string fileName: decodeURIComponent((imageData.file_url).substring((imageData.file_url).lastIndexOf('/') + 1))
property string filePath: `${root.previewDownloadPath}/${root.fileName}` property string filePath: `${root.previewDownloadPath}/${root.fileName}`
property int maxTagStringLineLength: 50 property int maxTagStringLineLength: 50
property real imageRadius: Appearance.rounding.small
property bool showActions: false property bool showActions: false
Process { Process {
@@ -43,13 +44,13 @@ Button {
} }
padding: 0 padding: 0
implicitWidth: imageObject.width implicitWidth: root.rowHeight * modelData.aspect_ratio
implicitHeight: imageObject.height implicitHeight: root.rowHeight
background: Rectangle { background: Rectangle {
implicitWidth: imageObject.width implicitWidth: root.rowHeight * modelData.aspect_ratio
implicitHeight: imageObject.height implicitHeight: root.rowHeight
radius: Appearance.rounding.small radius: imageRadius
color: Appearance.colors.colLayer2 color: Appearance.colors.colLayer2
} }
@@ -59,21 +60,21 @@ Button {
Image { Image {
id: imageObject id: imageObject
anchors.fill: parent anchors.fill: parent
sourceSize.width: root.rowHeight * modelData.aspect_ratio
sourceSize.height: root.rowHeight
fillMode: Image.PreserveAspectFit
source: modelData.preview_url
width: root.rowHeight * modelData.aspect_ratio width: root.rowHeight * modelData.aspect_ratio
height: root.rowHeight height: root.rowHeight
visible: opacity > 0 visible: opacity > 0
opacity: status === Image.Ready ? 1 : 0 opacity: status === Image.Ready ? 1 : 0
fillMode: Image.PreserveAspectFit
source: modelData.preview_url
sourceSize.width: root.rowHeight * modelData.aspect_ratio
sourceSize.height: root.rowHeight
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
maskSource: Rectangle { maskSource: Rectangle {
width: imageObject.width width: root.rowHeight * modelData.aspect_ratio
height: imageObject.height height: root.rowHeight
radius: Appearance.rounding.small radius: imageRadius
} }
} }
@@ -86,9 +87,10 @@ Button {
id: menuButton id: menuButton
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
anchors.margins: 8 property real buttonSize: 30
implicitHeight: 30 anchors.margins: Math.max(root.imageRadius - buttonSize / 2, 8)
implicitWidth: 30 implicitHeight: buttonSize
implicitWidth: buttonSize
buttonRadius: Appearance.rounding.full buttonRadius: Appearance.rounding.full
colBackground: ColorUtils.transparentize(Appearance.m3colors.m3surface, 0.3) colBackground: ColorUtils.transparentize(Appearance.m3colors.m3surface, 0.3)
@@ -233,6 +233,7 @@ Rectangle {
} }
delegate: RowLayout { delegate: RowLayout {
id: imageRow id: imageRow
required property var modelData
property var rowHeight: modelData.height property var rowHeight: modelData.height
spacing: root.imageSpacing spacing: root.imageSpacing
@@ -242,6 +243,7 @@ Rectangle {
required property var modelData required property var modelData
imageData: modelData imageData: modelData
rowHeight: imageRow.rowHeight rowHeight: imageRow.rowHeight
imageRadius: imageRow.modelData.images.length == 1 ? 50 : Appearance.rounding.normal
manualDownload: ["danbooru", "waifu.im"].includes(root.responseData.provider) manualDownload: ["danbooru", "waifu.im"].includes(root.responseData.provider)
previewDownloadPath: root.previewDownloadPath previewDownloadPath: root.previewDownloadPath
downloadPath: root.downloadPath downloadPath: root.downloadPath