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
2 changes: 1 addition & 1 deletion plans/folio.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Done, tested, and verified offscreen:
- `/` searches this folder and every folder below it by name as you type: a live breadth-first walk, nearest first, that stays on the folder's drive and doesn't follow symlinked folders.
- Three views, remembered between launches: grid (Ctrl+1), list with name, size and date (Ctrl+2; no headings; the date then the size step aside when narrow), and Finder-style columns (Ctrl+3).
- Preview pane: large preview, the system's type name, size, modified, dimensions, opening lines of text files, Open.
- Sidebar: a Home section (its label goes home) listing every folder in home (XDG folders and Dropbox with their own glyphs, `omarchy` shown as Omarchy); Pinned folders (Ctrl+D or drag onto the sidebar) stored as GTK bookmarks; Dropbox (with `dropbox-cli` sync status), Trash, physical drives (removable and extra internal disks, not the system's own), online tailnet machines from `tailscale status --json`.
- Sidebar: a Home section holding Home, every folder in home (XDG folders and Dropbox with their own glyphs, `omarchy` shown as Omarchy), Recents and Trash; Pinned folders (Ctrl+D or drag onto the sidebar) stored as GTK bookmarks; Dropbox (with `dropbox-cli` sync status), physical drives (removable and extra internal disks, not the system's own), online tailnet machines from `tailscale status --json`.
- Tailnet machines open over SFTP through GIO, landing in the matching home folder; their host keys are accepted without asking (Tailscale already checked the peer), and a password, when keys aren't set up, is asked in the window.
- Mouse back/forward buttons move through history (in the preview: previous/next file).
- Space opens a large preview in its own process (`folio preview`), like Sushi: pictures at full size with zoom, animated GIF/WebP, video and audio playing (Qt Multimedia's FFmpeg backend), PDFs scrolling (Qt PDF), text and rendered Markdown, folders with their pictures, and the largest cached thumbnail for anything else. Arrows step through the folder and the grid follows; a crash in the preview is reported in the Folio window. Ctrl+I toggles the details pane.
Expand Down
1 change: 1 addition & 0 deletions src/Glyph.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Item {
case "audio": return "M4 10v4M8 7v10M12 4v16M16 8v8M20 11v2"
case "check": return "M5 12l5 5 9-10"
case "close": return "M6 6l12 12M18 6L6 18"
case "home": return "M4 10l8-6 8 6v10H4zM10 20v-6h4v6"
default: return page()
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/IconButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ AbstractButton {

property string glyph
property bool active: false
// An on/off switch: off draws in the secondary ink, so on and off differ by brightness alone.
property bool toggle: false
// Some themes set brightForeground dimmer than foreground; on takes whichever stands out more.
readonly property color onInk: (theme.brightForeground.hslLightness > theme.foreground.hslLightness) !== theme.light
? theme.brightForeground : theme.foreground

implicitWidth: 36
implicitHeight: 36
Expand All @@ -26,7 +31,8 @@ AbstractButton {

background: Rectangle {
radius: Math.min(4, theme.radius)
color: button.active ? Qt.alpha(theme.accent, 0.16)
// A toggle says on by its ink alone; any other active button keeps the plate.
color: button.active && !button.toggle ? Qt.alpha(theme.accent, 0.16)
: button.hovered && button.enabled ? Qt.alpha(theme.foreground, 0.08)
: "transparent"
}
Expand All @@ -36,6 +42,7 @@ AbstractButton {
anchors.centerIn: parent
name: button.glyph
color: !button.enabled ? Qt.alpha(theme.foreground, 0.35)
: button.toggle ? (button.active ? button.onInk : theme.secondaryForeground)
: button.active ? theme.brightForeground : theme.foreground
}
}
Expand Down
92 changes: 80 additions & 12 deletions src/PathBar.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

// The breadcrumb path from the left edge; view buttons on the right. Back and
Expand Down Expand Up @@ -85,6 +86,12 @@ Rectangle {
cursorPosition = text.length
}
onActiveFocusChanged: if (!activeFocus && bar.editing) bar.stopEditing()
// A double click on the empty bar lands its second click here: keep the whole path selected, not a word.
MouseArea {
anchors.fill: parent
onPressed: mouse => mouse.accepted = (mouse.flags & Qt.MouseEventCreatedDoubleClick) !== 0 && pathField.selectedText === pathField.text
onDoubleClicked: mouse => mouse.accepted = pressed
}
}

PlainField {
Expand Down Expand Up @@ -128,29 +135,79 @@ Rectangle {
Keys.onEscapePressed: bar.endSearch()
}

Flickable {
Item {
id: trail
visible: !bar.editing && !bar.searching
Layout.fillWidth: true
Layout.fillHeight: true
contentWidth: Math.max(width, crumbs.implicitWidth)
clip: true
boundsBehavior: Flickable.StopAtBounds
// Long paths keep their end in view; that's where you are.
// Mirrored, the end is on the left.
function revealEnd() { contentX = LayoutMirroring.enabled ? 0 : Math.max(0, contentWidth - width) }
onContentWidthChanged: revealEnd()
onWidthChanged: revealEnd()
LayoutMirroring.onEnabledChanged: revealEnd()
// The end stays in view; crumbs that don't fit whole fold into "…" at the reading start (the right, when mirrored).
property int first: 0
property real offset: 0
// Measured from each crumb's full width, so the current folder's own elide never changes what folds.
function fit() {
let rest = 0
for (let k = 0; k < crumbRepeater.count; ++k)
rest += crumbRepeater.itemAt(k).fullWidth + (k > 0 ? crumbs.spacing : 0)
let i = 0
if (rest > width)
while (i < crumbRepeater.count - 1 && rest > width - more.implicitWidth - crumbs.spacing)
rest -= crumbRepeater.itemAt(i++).fullWidth + crumbs.spacing
first = i
// How far the first shown crumb is from the row's start, which a mirrored Row puts at its right.
const shown = crumbRepeater.itemAt(i)
const lead = LayoutMirroring.enabled ? crumbs.width - shown.x - shown.width : shown.x
offset = i > 0 ? lead - more.implicitWidth - crumbs.spacing : 0
}
onWidthChanged: fit()
LayoutMirroring.onEnabledChanged: fit()

// A click on the empty part of the bar edits the path, as Ctrl+L does.
MouseArea {
anchors.fill: parent
onClicked: bar.editPath()
}

Text {
id: more
// Above the folded crumbs, which still lie under it and would take its hover.
z: 1
visible: trail.first > 0
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: "…"
color: moreMouse.containsMouse ? theme.foreground : theme.secondaryForeground
font.pixelSize: 14
// A crumb's hit margin, except toward the bar's edge, which would fall outside the clip.
MouseArea {
id: moreMouse
anchors.fill: parent
anchors.margins: -4
anchors.leftMargin: 0
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: backend.navigate(backend.crumbs[trail.first - 1].path)
// The folded path as the crumbs write it: "/" root, "~" home.
ToolTip {
visible: moreMouse.containsMouse
delay: 600
text: crumbRepeater.model.slice(0, trail.first).map(c => c.name).join("/").replace("//", "/")
enter: null
exit: null
}
}
}

Row {
id: crumbs
// A Row isn't placed by its Flickable, so it's moved to the
// right edge by hand when mirrored.
x: LayoutMirroring.enabled ? parent.width - width : 0
// A Row isn't placed by its parent, so it's moved to the right edge by hand when mirrored.
x: LayoutMirroring.enabled ? trail.width - width + trail.offset : -trail.offset
anchors.verticalCenter: parent.verticalCenter
spacing: 10
onPositioningComplete: trail.fit()

Repeater {
id: crumbRepeater
// Recents, Trash and plugins' views are named in C++, which
// retranslating QML doesn't redo.
model: { translator.language; return backend.crumbs }
Expand All @@ -159,15 +216,25 @@ Rectangle {
required property var modelData
required property int index
readonly property bool last: index === backend.crumbs.length - 1
readonly property real fullWidth: folderName.implicitWidth + (separator.visible ? separator.implicitWidth + spacing : 0)
// Folded crumbs keep their place so the others don't move.
opacity: index < trail.first ? 0 : 1
enabled: index >= trail.first
spacing: 10
Text {
id: separator
// No separator after / itself: "/ run", not "/ / run".
visible: crumb.index > 0 && !(crumb.index === 1 && backend.crumbs[0].name === "/")
text: "/"
color: Qt.alpha(theme.foreground, 0.35)
font.pixelSize: 14
}
Text {
id: folderName
// The current folder always shows; alone too wide, it elides.
width: crumb.last ? Math.max(0, Math.min(implicitWidth, trail.width - (separator.visible ? separator.implicitWidth + crumb.spacing : 0)
- (trail.first > 0 ? more.implicitWidth + crumbs.spacing : 0))) : implicitWidth
elide: Text.ElideRight
text: crumb.modelData.name
color: crumb.last ? theme.brightForeground : crumbMouse.containsMouse ? theme.foreground : theme.secondaryForeground
font.pixelSize: 14
Expand Down Expand Up @@ -209,6 +276,7 @@ Rectangle {
SortMenu { id: sortMenu }
IconButton {
glyph: "preview"
toggle: true
// Only where the window has room to show them.
visible: bar.previewFits
text: qsTr("Details")
Expand Down
70 changes: 38 additions & 32 deletions src/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ Rectangle {
// Each plugin section's rows, then the row for its view.
function sectionRows(section) { return section.view ? section.rows.concat([section.view]) : section.rows }
readonly property var pluginRows: plugins.sections.reduce((all, section) => all.concat(sectionRows(section)), [])
readonly property var rows: [].concat(places.places, places.pinned, places.views, places.devices, pluginRows)
readonly property int pinnedAt: places.places.length
readonly property int viewsAt: pinnedAt + places.pinned.length
readonly property int devicesAt: viewsAt + places.views.length
readonly property var rows: [].concat([homeRow], places.places, places.views, places.pinned, places.devices, pluginRows)
readonly property int pinnedAt: viewsAt + places.views.length
readonly property int viewsAt: 1 + places.places.length
readonly property int devicesAt: pinnedAt + places.pinned.length
readonly property int pluginsAt: devicesAt + places.devices.length
readonly property var homeRow: ({ path: places.home })
// Where a plugin section's rows start in `rows`.
function sectionAt(index) {
let at = pluginsAt
Expand Down Expand Up @@ -89,7 +90,7 @@ Rectangle {
// A pinned folder is unpinned, a plugin's item taken off the sidebar.
Keys.onDeletePressed: {
const row = rows[cursor]
if (cursor >= pinnedAt && cursor < viewsAt)
if (cursor >= pinnedAt && cursor < devicesAt)
places.unpin(row.path)
else if (row && row.forgettable)
plugins.forget(row.plugin, row.id)
Expand Down Expand Up @@ -125,7 +126,7 @@ Rectangle {
readonly property string activePath: {
let best = ""
const here = sidebar.target.path
for (const list of [places.places, places.pinned, places.views, places.devices,
for (const list of [[homeRow], places.places, places.pinned, places.views, places.devices,
plugins.sections.filter(section => section.view).map(section => section.view)]) {
for (const p of list) {
if (p.path !== "/" && (here === p.path || here.startsWith(p.path + "/")) && p.path.length > best.length)
Expand Down Expand Up @@ -183,7 +184,9 @@ Rectangle {

background: Rectangle {
radius: Math.min(4, theme.radius)
color: row.active || row.dropHover ? Qt.alpha(theme.accent, 0.16)
// Accent only while the sidebar holds the keyboard; grey while the files do.
color: row.dropHover || row.active && sidebar.activeFocus ? Qt.alpha(theme.accent, 0.16)
: row.active ? Qt.alpha(theme.foreground, 0.10)
: row.hovered && row.enabled ? Qt.alpha(theme.foreground, 0.06) : "transparent"
border.width: row.dropHover ? 2 : row.keyed ? 1 : 0
border.color: theme.accent
Expand Down Expand Up @@ -274,15 +277,19 @@ Rectangle {
width: sidebar.width - 24
spacing: 1

// The section's label is home itself: click it to go there.
SectionLabel {
Layout.topMargin: 0
text: qsTr("Home")
color: sidebar.target.path === places.home ? theme.accent
: homeHover.hovered ? theme.foreground : theme.secondaryForeground
Accessible.role: Accessible.Button
HoverHandler { id: homeHover; cursorShape: Qt.PointingHandCursor }
TapHandler { onTapped: sidebar.target.navigate(places.home) }
}
PlaceRow {
dropPath: places.home
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
keyed: sidebar.activeFocus && sidebar.cursor === 0
onKeyedChanged: if (keyed) sidebar.reveal(this)
text: qsTr("Home")
glyph: "home"
active: sidebar.activePath === places.home
onClicked: sidebar.target.navigate(places.home)
}
Repeater {
model: places.places
Expand All @@ -291,7 +298,7 @@ Rectangle {
required property int index
dropPath: modelData.path
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
keyed: sidebar.activeFocus && sidebar.cursor === 0 + index
keyed: sidebar.activeFocus && sidebar.cursor === 1 + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
text: modelData.name
glyph: modelData.icon
Expand All @@ -300,6 +307,23 @@ Rectangle {
}
}

// Views: lists that aren't a folder of their own.
Repeater {
model: places.views
PlaceRow {
required property var modelData
required property int index
dropTrashes: modelData.icon === "trash"
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
text: modelData.icon === "trash" ? qsTr("Trash") : qsTr("Recents")
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
keyed: sidebar.activeFocus && sidebar.cursor === sidebar.viewsAt + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
}
}

// Pinned folders from anywhere, kept in GTK's bookmarks. While a
// folder is dragged over the sidebar, the section shows (even
// empty) as the place to drop it.
Expand Down Expand Up @@ -364,24 +388,6 @@ Rectangle {
}
}

// Views: lists that aren't a folder of their own.
SectionLabel { text: qsTr("Views") }
Repeater {
model: places.views
PlaceRow {
required property var modelData
required property int index
dropTrashes: modelData.icon === "trash"
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
text: modelData.icon === "trash" ? qsTr("Trash") : qsTr("Recents")
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
keyed: sidebar.activeFocus && sidebar.cursor === sidebar.viewsAt + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
}
}

// Each drive says how much is free under its name, where there's
// room for it, and while it's hovered or has the keyboard its icon
// becomes the button that ejects it. Right-clicked, it has a menu
Expand Down
1 change: 0 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Untitled Folder",
"Untitled Folder %1": "Untitled Folder %1",
"User": "User",
"Views": "Views",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Works with Mac, Windows and Linux, and holds big files.",
"You don't have permission to open this folder.": "You don't have permission to open this folder.",
Expand Down
Loading