LinkPreviewComponent: Fix a few bugs, restore the image preview
We realized that images don't display in link previews anymore, because QML is terrible and this property is a QUrl, so when we call .length it silently fails and never loads the image. This is easily fixed by calling .toString(). There's also another bug where the title ie elided way too greedily, but we can simplify the elision check and fix the bug at the same time. No more "Hom..."!
This commit is contained in:
@@ -31,7 +31,7 @@ QQC2.Control {
|
||||
* - description - the description of the URL preview.
|
||||
* - imageSource - a source URL for the preview image.
|
||||
*/
|
||||
required property var linkPreviewer
|
||||
required property LinkPreviewer linkPreviewer
|
||||
|
||||
/**
|
||||
* @brief Standard height for the link preview.
|
||||
@@ -72,7 +72,9 @@ QQC2.Control {
|
||||
id: previewImage
|
||||
Layout.preferredWidth: root.defaultHeight
|
||||
Layout.preferredHeight: root.defaultHeight
|
||||
visible: root.linkPreviewer.imageSource.length > 0
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: root.linkPreviewer.imageSource.toString().length > 0
|
||||
source: root.linkPreviewer.imageSource
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
@@ -80,6 +82,7 @@ QQC2.Control {
|
||||
id: column
|
||||
implicitWidth: Math.max(linkPreviewTitle.implicitWidth, linkPreviewDescription.implicitWidth)
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
visible: root.linkPreviewer.title.length > 0 || root.linkPreviewer.description.length > 0
|
||||
Kirigami.Heading {
|
||||
id: linkPreviewTitle
|
||||
Layout.fillWidth: true
|
||||
@@ -98,12 +101,7 @@ QQC2.Control {
|
||||
text: root.linkPreviewer.title
|
||||
font: linkPreviewTitle.font
|
||||
elide: Text.ElideRight
|
||||
elideWidth: (linkPreviewTitle.availableWidth()) * 3
|
||||
}
|
||||
|
||||
function availableWidth() {
|
||||
let previewImageWidth = (previewImage.visible ? previewImage.width + contentRow.spacing : 0);
|
||||
return root.maxContentWidth - contentRow.spacing - separator.width - previewImageWidth;
|
||||
elideWidth: linkPreviewTitle.width
|
||||
}
|
||||
}
|
||||
QQC2.Label {
|
||||
|
||||
Reference in New Issue
Block a user