Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/FileRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ Item {
implicitHeight: 20
Image {
id: thumb
anchors.fill: parent
// A fitted picture is laid out at its own shape, as on a tile, so its corners can round.
readonly property real fit: Format.filled(row.kind) || implicitWidth <= 0 ? 0 : Math.min(parent.width / implicitWidth, parent.height / implicitHeight)
width: fit > 0 ? implicitWidth * fit : parent.width
height: fit > 0 ? implicitHeight * fit : parent.height
anchors.centerIn: parent
layer.enabled: theme.radius > 0 && status === Image.Ready
layer.effect: MultiEffect {
maskEnabled: true
Expand All @@ -89,14 +93,14 @@ Item {
maskSpreadAtMin: 1
}
asynchronous: true
fillMode: Image.PreserveAspectCrop
source: row.kind === "image" || row.kind === "video" ? Format.thumb(row.path, row.mime, 128, row.modified) : ""
fillMode: Format.filled(row.kind) ? Image.PreserveAspectCrop : Image.Stretch
source: Format.pictured(row.isDir, row.kind) ? Format.thumb(row.path, row.mime, 128, row.modified) : ""
visible: status === Image.Ready
}
Rectangle {
id: rowMask
width: 20
height: 20
width: thumb.width
height: thumb.height
radius: Math.min(4, theme.radius)
visible: false
layer.enabled: true
Expand Down
2 changes: 1 addition & 1 deletion src/FileTile.qml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Item {
Item {
// The picture is laid out at its own shape (cropped to fill for
// photos and video, fitted for pages), so its corners can round.
readonly property bool crop: tile.kind === "image" || tile.kind === "video"
readonly property bool crop: Format.filled(tile.kind)
readonly property size natural: thumb.implicitWidth > 0 ? Qt.size(thumb.implicitWidth, thumb.implicitHeight) : Qt.size(1, 1)
readonly property real fit: Math.min(width / natural.width, height / natural.height)
Image {
Expand Down
10 changes: 10 additions & 0 deletions src/Format.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,13 @@ function page(path, px, modified, paper, ink) {
function keys(text) {
return text.replace(/(\S)\+(?=\S)/g, "$1 + ")
}

// Whether a row asks for an item's thumbnail, as its tile does: every file but text, which a tile draws as a page and a row leaves to its icon.
function pictured(isDir, kind) {
return !isDir && kind !== "text" && kind !== "item"
}

// Photos and video fill their frame; a page or a cover is fitted whole.
function filled(kind) {
return kind === "image" || kind === "video"
}
10 changes: 10 additions & 0 deletions src/PreviewPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ Rectangle {
font.pixelSize: 12
elide: Text.ElideRight
}
// A type nothing installed can draw: which package would.
Text {
readonly property string missing: big.status === Image.Error ? thumbnails.missingPackage(pane.item.mime) : ""
visible: missing.length > 0
Layout.fillWidth: true
text: qsTr("Thumbnails of this type need the %1 package.").arg(missing)
color: theme.secondaryForeground
font.pixelSize: 12
wrapMode: Text.Wrap
}
}

GridLayout {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
"This computer can't make %1 drives.": "This computer can't make %1 drives.",
"This folder is empty": "This folder is empty",
"This folder no longer exists.": "This folder no longer exists.",
"Thumbnails of this type need the %1 package.": "Thumbnails of this type need the %1 package.",
"Trash": "Trash",
"Try again once the work under way is done.": "Try again once the work under way is done.",
"Type a path, or a server's address like sftp://host/ (Tab completes)": "Type a path, or a server's address like sftp://host/ (Tab completes)",
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ int main(int argc, char *argv[]) {
engine.rootContext()->setContextProperty("theme", &theme);
engine.rootContext()->setContextProperty("places", &places);
engine.rootContext()->setContextProperty("plugins", &plugins);
engine.rootContext()->setContextProperty("thumbnails", &thumbnails);

Windows windows(&engine, &plugins);
if (!windows.open(start, select))
Expand Down
Loading