From 040eb2dbe66f272f2d9f83cd0af567e6fce503fe Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 17 Nov 2026 15:41:41 +0100 Subject: [PATCH 1/3] Group the keyboard shortcuts, with keys as keycaps The shortcuts were one long list in no order, with descriptions running onto second lines and keys written out as text. They're now in groups (Moving around, Selecting, Files, View, Window), each with a small heading as the sidebar's sections have. Each shortcut says what it does in a line, with its keys as keycaps on the right; the ways to do it are set apart by a slash, and what's done with the mouse (click, drag) is a word rather than a key. The groups flow into two or three columns as the window allows, about as long as each other, and "Escape closes" sits in the corner. The descriptions are shorter, new strings; other languages show them in English until the next translation sync. Co-Authored-By: Claude Opus 5.5 --- src/HelpOverlay.qml | 264 +++++++++++++++++++++++++++++++++----------- src/i18n/en.json | 47 ++++---- 2 files changed, 222 insertions(+), 89 deletions(-) diff --git a/src/HelpOverlay.qml b/src/HelpOverlay.qml index ec0e0f03..c074b4f2 100644 --- a/src/HelpOverlay.qml +++ b/src/HelpOverlay.qml @@ -1,10 +1,11 @@ import QtQuick import QtQuick.Layouts import QtQuick.Controls -import "Format.js" as Format -// Every shortcut, one keypress away (?). It has the keyboard while it's -// shown, so the arrows scroll it rather than move through the files behind. +// Every shortcut, one keypress away (?), in groups: what it does on the +// left, its keys as keycaps on the right. The groups flow into as many +// columns as the window has room for. It has the keyboard while it's shown, +// so the arrows scroll it rather than move through the files behind. Rectangle { id: overlay @@ -12,9 +13,9 @@ Rectangle { color: Qt.rgba(0, 0, 0, 0.55) - // ↑ ↓, Page Up, Page Down, Home and End, for a list the window is too - // short for. Tab stays here too, rather than going on to a button - // behind the overlay. + // ↑ ↓, Page Up, Page Down, Home and End, for a window too short for it + // all. Tab stays here too, rather than going on to a button behind the + // overlay. Keys.onPressed: (event) => { if (event.key === Qt.Key_Tab || event.key === Qt.Key_Backtab) { event.accepted = true @@ -29,58 +30,92 @@ Rectangle { event.accepted = true } - property var shortcuts: [ - ["← ↑ → ↓", qsTr("Move the selection")], - [LayoutMirroring.enabled ? "← / →" : "→ / ←", qsTr("In list and columns: into a folder / back out")], - // The keys in these few are mixed with words; the key names (Shift, - // Alt, ⏎) stay as they are in every language. - [qsTr("Shift+click / Shift+arrows"), qsTr("Select a range")], - ["Page Up / Page Down", qsTr("A screenful up or down (Shift selects)")], - [qsTr("Alt+click"), qsTr("Add or remove one from the selection")], - [qsTr("Drag on empty space"), qsTr("Select with a rectangle (Alt adds)")], - ["Ctrl+A", qsTr("Select everything")], - ["Tab / Shift+Tab", qsTr("Move between the sidebar, the panes and the details")], - [qsTr("Delete in the sidebar"), qsTr("Unpin the folder, or take the item off the sidebar")], - ["⏎", qsTr("Open")], - ["Backspace", qsTr("Go to the parent folder")], - ["Alt+← / Alt+→", qsTr("Back / forward (or the mouse's thumb buttons)")], - ["Alt+Home", qsTr("Go home")], - ["Ctrl+L", qsTr("Type a path, or a server's address like sftp://host/ (Tab completes)")], - ["/", qsTr("Search this folder and below")], - ["Ctrl+1 / 2 / 3", qsTr("Columns, grid or list")], - ["Ctrl+= / Ctrl+- / Ctrl+0", qsTr("Bigger, smaller or normal tiles (or Ctrl+scroll)")], - ["Space", qsTr("Preview the selected file")], - ["Ctrl+P", qsTr("Pin or unpin the folder (or drag it to the sidebar)")], - ["Ctrl+C / X / V", qsTr("Copy, cut, paste files")], - ["Ctrl+Shift+C", qsTr("Copy the path as text")], - ["F2 / Ctrl+Shift+D", qsTr("Rename / duplicate")], - ["Ctrl+N", qsTr("New window")], - ["Ctrl+Shift+N", qsTr("New folder")], - ["Ctrl+Alt+N / Ctrl+W", qsTr("Split into two panes / close the right one")], - ["Delete", qsTr("Move to the trash")], - ["Shift+Delete", qsTr("Delete permanently (asks first)")], - ["Ctrl+Z / Ctrl+Shift+Z", qsTr("Undo / redo the last change to files (or Ctrl+Y)")], - ["Escape", qsTr("Stop the file work under way, or dismiss what went wrong")], - [qsTr("Right-click / Alt+⏎ / Menu"), qsTr("Everything else, for files and for drives in the sidebar")], - ["S / Shift+S", qsTr("Sort: name, kind, newest, oldest, size")], - ["Ctrl+H", qsTr("Show hidden files")], - ["F5", qsTr("Reload")], - ["?", qsTr("Show these shortcuts")], - ["Q", qsTr("Close the window")] + // Each shortcut is what it does, then its keys: the ways to do it, each + // a list of keys pressed together. A word starting with ~ is something + // done with the mouse ("click"), said rather than drawn as a key. Key + // names (Shift, Alt, Ctrl) stay as they are in every language. + readonly property bool mirrored: LayoutMirroring.enabled + readonly property var groups: [ + { title: qsTr("Moving around"), shortcuts: [ + [qsTr("Move the selection"), [["←", "↑", "→", "↓"]]], + [qsTr("Into a folder / back out"), mirrored ? [["←"], ["→"]] : [["→"], ["←"]]], + [qsTr("A screenful up or down"), [["Page Up"], ["Page Down"]]], + [qsTr("Open"), [["⏎"]]], + [qsTr("Go to the parent folder"), [["Backspace"]]], + [qsTr("Back / forward"), [["Alt", "←"], ["Alt", "→"]]], + [qsTr("Go home"), [["Alt", "Home"]]], + [qsTr("Type a path or a server's address"), [["Ctrl", "L"]]], + [qsTr("Search this folder and below"), [["/"]]], + [qsTr("Sidebar, panes and details"), [["Tab"], ["Shift", "Tab"]]] + ]}, + { title: qsTr("Selecting"), shortcuts: [ + [qsTr("Select a range"), [["Shift", "~" + qsTr("click")], ["Shift", "↑↓"]]], + [qsTr("Add or remove one"), [["Alt", "~" + qsTr("click")]]], + [qsTr("Select with a rectangle"), [["~" + qsTr("drag on empty space")]]], + [qsTr("Select everything"), [["Ctrl", "A"]]] + ]}, + { title: qsTr("Files"), shortcuts: [ + [qsTr("Copy, cut, paste"), [["Ctrl", "C"], ["X"], ["V"]]], + [qsTr("Copy the path as text"), [["Ctrl", "Shift", "C"]]], + [qsTr("Rename"), [["F2"]]], + [qsTr("Duplicate"), [["Ctrl", "Shift", "D"]]], + [qsTr("New folder"), [["Ctrl", "Shift", "N"]]], + [qsTr("Preview the selected file"), [["Space"]]], + [qsTr("Move to the trash"), [["Delete"]]], + [qsTr("Delete permanently (asks first)"), [["Shift", "Delete"]]], + [qsTr("Undo / redo"), [["Ctrl", "Z"], ["Ctrl", "Shift", "Z"]]], + [qsTr("Pin or unpin the folder"), [["Ctrl", "P"]]], + [qsTr("Everything else"), [["~" + qsTr("right-click")], ["Alt", "⏎"]]], + [qsTr("Stop the work under way"), [["Escape"]]] + ]}, + { title: qsTr("View"), shortcuts: [ + [qsTr("Columns, grid or list"), [["Ctrl", "1"], ["2"], ["3"]]], + [qsTr("Bigger, smaller or normal tiles"), [["Ctrl", "="], ["-"], ["0"]]], + [qsTr("Next or previous sort order"), [["S"], ["Shift", "S"]]], + [qsTr("Show hidden files"), [["Ctrl", "H"]]], + [qsTr("Reload"), [["F5"]]] + ]}, + { title: qsTr("Window"), shortcuts: [ + [qsTr("New window"), [["Ctrl", "N"]]], + [qsTr("Split into two panes"), [["Ctrl", "Alt", "N"]]], + [qsTr("Close the right pane"), [["Ctrl", "W"]]], + [qsTr("Unpin from the sidebar"), [["Delete"]]], + [qsTr("Show these shortcuts"), [["?"]]], + [qsTr("Close the window"), [["Q"]]] + ]} ] + // As many columns as fit, and the groups dealt out among them in turn + // to whichever is shortest, so they come out about as long. + readonly property int columnWidth: 400 + readonly property int columnGap: 48 + readonly property int columnCount: Math.max(1, Math.min(3, Math.floor((width - 64 - 56 + columnGap) / (columnWidth + columnGap)))) + readonly property var columns: { + const columns = [], lengths = [] + for (let i = 0; i < columnCount; ++i) { + columns.push([]) + lengths.push(0) + } + for (const group of groups) { + const shortest = lengths.indexOf(Math.min(...lengths)) + columns[shortest].push(group) + lengths[shortest] += group.shortcuts.length + 2 + } + return columns + } + MouseArea { anchors.fill: parent; onClicked: overlay.dismissed() } - // Sized to what it holds: two columns of shortcuts side by side when - // the window is wide enough, and scrolling when it's too short for them. Rectangle { anchors.centerIn: parent width: Math.min(parent.width - 64, content.implicitWidth + 56) height: Math.min(parent.height - 64, content.implicitHeight + 56) color: theme.background border.width: 1 - border.color: theme.accent + border.color: Qt.alpha(theme.foreground, 0.16) radius: theme.radius + // Clicks inside don't dismiss it. + MouseArea { anchors.fill: parent } Flickable { id: flick @@ -94,35 +129,130 @@ Rectangle { ColumnLayout { id: content - width: parent.width - spacing: 14 + width: Math.max(implicitWidth, parent.width) + spacing: 20 - Text { text: qsTr("Keyboard shortcuts"); color: theme.brightForeground; font.pixelSize: 16; font.weight: Font.DemiBold } + RowLayout { + Layout.fillWidth: true + Text { + Layout.fillWidth: true + horizontalAlignment: Text.AlignLeft + text: qsTr("Keyboard shortcuts") + color: theme.brightForeground + font.pixelSize: 16 + font.weight: Font.DemiBold + } + Text { text: qsTr("Escape closes"); color: theme.secondaryForeground; font.pixelSize: 12 } + } - GridLayout { - // Pairs of key and description, two pairs a row when the - // window has room for them. - columns: overlay.width >= 1500 ? 4 : 2 - rowSpacing: 10 - columnSpacing: 28 - // Each key, then what it does: the grid fills its columns - // in order. (QML's JavaScript has no Array.flat.) + RowLayout { + spacing: overlay.columnGap Repeater { - model: [].concat(...overlay.shortcuts) - delegate: Text { + model: overlay.columns + ColumnLayout { + id: column + required property var modelData + Layout.preferredWidth: overlay.columnWidth + Layout.alignment: Qt.AlignTop + spacing: 22 + Repeater { + model: column.modelData + Group { } + } + } + } + } + } + } + } + + // A group: its title, then a row for each shortcut. + component Group: ColumnLayout { + id: group + required property var modelData + Layout.fillWidth: true + spacing: 2 + Text { + Layout.bottomMargin: 6 + text: group.modelData.title + color: theme.secondaryForeground + font.pixelSize: 11 + font.letterSpacing: 1.3 + font.capitalization: Font.AllUppercase + } + Repeater { + model: group.modelData.shortcuts + RowLayout { + id: shortcut + required property var modelData + Layout.fillWidth: true + Layout.preferredHeight: 28 + spacing: 16 + // Aligned explicitly, so that it's mirrored with the rest. + Text { + Layout.fillWidth: true + horizontalAlignment: Text.AlignLeft + text: shortcut.modelData[0] + color: theme.foreground + elide: Text.ElideRight + } + Row { + spacing: 6 + Repeater { + model: shortcut.modelData[1] + Row { + id: way required property var modelData required property int index - Layout.maximumWidth: index % 2 ? 340 : -1 - // Set, so that it's mirrored: left as it is, an - // English description would follow its own script. - horizontalAlignment: Text.AlignLeft - text: index % 2 ? modelData : Format.keys(modelData) - wrapMode: Text.WordWrap - color: index % 2 ? theme.foreground : theme.accent + spacing: 4 + Text { + visible: way.index > 0 + anchors.verticalCenter: parent.verticalCenter + text: "/" + color: theme.secondaryForeground + font.pixelSize: 12 + } + Repeater { + model: way.modelData + Key { } + } } } } } } } + + // A key as a keycap, or something done with the mouse as a word. + component Key: Item { + id: key + required property string modelData + readonly property bool word: modelData.startsWith("~") + implicitWidth: word ? said.implicitWidth : Math.max(24, cap.implicitWidth + 14) + implicitHeight: 22 + Rectangle { + visible: !key.word + anchors.fill: parent + radius: Math.min(4, theme.radius) + color: Qt.alpha(theme.foreground, 0.06) + border.width: 1 + border.color: Qt.alpha(theme.foreground, 0.18) + } + Text { + id: cap + visible: !key.word + anchors.centerIn: parent + text: key.modelData + color: theme.accent + font.pixelSize: 12 + } + Text { + id: said + visible: key.word + anchors.verticalCenter: parent.verticalCenter + text: key.modelData.slice(1) + color: theme.secondaryForeground + font.pixelSize: 12 + } + } } diff --git a/src/i18n/en.json b/src/i18n/en.json index f46d43ca..1fe5fa2d 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -43,13 +43,12 @@ "A folder here is already called %1.": "A folder here is already called %1.", "A folder, or a server's address like sftp://host/": "A folder, or a server's address like sftp://host/", "A name can't contain \"/\".": "A name can't contain \"/\".", - "A screenful up or down (Shift selects)": "A screenful up or down (Shift selects)", - "Add or remove one from the selection": "Add or remove one from the selection", - "Alt+click": "Alt+click", + "A screenful up or down": "A screenful up or down", + "Add or remove one": "Add or remove one", "Archive": "Archive", "Back / ahead 5 seconds": "Back / ahead 5 seconds", - "Back / forward (or the mouse's thumb buttons)": "Back / forward (or the mouse's thumb buttons)", - "Bigger, smaller or normal tiles (or Ctrl+scroll)": "Bigger, smaller or normal tiles (or Ctrl+scroll)", + "Back / forward": "Back / forward", + "Bigger, smaller or normal tiles": "Bigger, smaller or normal tiles", "Biggest first": "Biggest first", "Burn": "Burn", "Burn %1?": "Burn %1?", @@ -67,6 +66,7 @@ "Check the server": "Check the server", "Choose": "Choose", "Close": "Close", + "Close the right pane": "Close the right pane", "Close the window": "Close the window", "Close this pane": "Close this pane", "Columns, grid or list": "Columns, grid or list", @@ -84,7 +84,7 @@ "Copy": "Copy", "Copy Path": "Copy Path", "Copy the path as text": "Copy the path as text", - "Copy, cut, paste files": "Copy, cut, paste files", + "Copy, cut, paste": "Copy, cut, paste", "Copying %1: %2 of %3…": "Copying %1: %2 of %3…", "Copying %L1 of %Ln items…": { "one": "Copying %L1 of %Ln item…", @@ -133,7 +133,6 @@ "Cut": "Cut", "Delete": "Delete", "Delete for good?": "Delete for good?", - "Delete in the sidebar": "Delete in the sidebar", "Delete permanently (asks first)": "Delete permanently (asks first)", "Deleted": "Deleted", "Delete…": "Delete…", @@ -152,7 +151,6 @@ "one": "Do this for the other %Ln clash", "other": "Do this for the other %Ln clashes" }, - "Drag on empty space": "Drag on empty space", "Drives can't be changed without udisks2.": "Drives can't be changed without udisks2.", "Drop to pin": "Drop to pin", "Duplicate": "Duplicate", @@ -171,7 +169,8 @@ "other": "Emptying the trash: %L1 of %Ln items…" }, "Emptying the trash…": "Emptying the trash…", - "Everything else, for files and for drives in the sidebar": "Everything else, for files and for drives in the sidebar", + "Escape closes": "Escape closes", + "Everything else": "Everything else", "Everything on this drive will be erased. This can't be undone.": "Everything on this drive will be erased. This can't be undone.", "Extract": "Extract", "Extracting %1: %Ln items…": { @@ -214,7 +213,7 @@ "Hide": "Hide", "Hide Hidden Files": "Hide Hidden Files", "Home": "Home", - "In list and columns: into a folder / back out": "In list and columns: into a folder / back out", + "Into a folder / back out": "Into a folder / back out", "Keep Both": "Keep Both", "Keyboard shortcuts": "Keyboard shortcuts", "Kind": "Kind", @@ -223,7 +222,6 @@ "Merging adds what's in this folder to the one there. What has the same name inside is replaced, and the replaced items go to the trash.": "Merging adds what's in this folder to the one there. What has the same name inside is replaced, and the replaced items go to the trash.", "Modified": "Modified", "Mount": "Mount", - "Move between the sidebar, the panes and the details": "Move between the sidebar, the panes and the details", "Move the selection": "Move the selection", "Move to the trash": "Move to the trash", "Moved only part of %1: %2": "Moved only part of %1: %2", @@ -244,6 +242,7 @@ "one": "Moving %Ln item…", "other": "Moving %Ln items…" }, + "Moving around": "Moving around", "Name": "Name", "New Folder": "New Folder", "New folder": "New folder", @@ -251,6 +250,7 @@ "Newest": "Newest", "Newest first": "Newest first", "Next (%1)": "Next (%1)", + "Next or previous sort order": "Next or previous sort order", "No USB drives or SD cards": "No USB drives or SD cards", "No app is set up to open %1.": "No app is set up to open %1.", "No items": "No items", @@ -279,7 +279,7 @@ "Pause (K)": "Pause (K)", "Permission was refused.": "Permission was refused.", "Pin": "Pin", - "Pin or unpin the folder (or drag it to the sidebar)": "Pin or unpin the folder (or drag it to the sidebar)", + "Pin or unpin the folder": "Pin or unpin the folder", "Pinned": "Pinned", "Play (K)": "Play (K)", "Play or pause": "Play or pause", @@ -320,7 +320,6 @@ "Reload": "Reload", "Remove from the sidebar": "Remove from the sidebar", "Rename": "Rename", - "Rename / duplicate": "Rename / duplicate", "Rename…": "Rename…", "Replace": "Replace", "Replace %1?": "Replace %1?", @@ -349,7 +348,6 @@ "one": "Restoring %Ln item…", "other": "Restoring %Ln items…" }, - "Right-click / Alt+⏎ / Menu": "Right-click / Alt+⏎ / Menu", "Save": "Save", "Scroll": "Scroll", "Search %1": "Search %1", @@ -358,9 +356,9 @@ "Select All": "Select All", "Select a range": "Select a range", "Select everything": "Select everything", - "Select with a rectangle (Alt adds)": "Select with a rectangle (Alt adds)", + "Select with a rectangle": "Select with a rectangle", + "Selecting": "Selecting", "Share": "Share", - "Shift+click / Shift+arrows": "Shift+click / Shift+arrows", "Show Hidden Files": "Show Hidden Files", "Show as columns": "Show as columns", "Show as grid": "Show as grid", @@ -368,15 +366,15 @@ "Show hidden files": "Show hidden files", "Show in Home": "Show in Home", "Show these shortcuts": "Show these shortcuts", + "Sidebar, panes and details": "Sidebar, panes and details", "Sign in": "Sign in", "Size": "Size", "Skip": "Skip", "Something is still using it.": "Something is still using it.", - "Sort: name, kind, newest, oldest, size": "Sort: name, kind, newest, oldest, size", "Sorted by kind": "Sorted by kind", "Sorted by name": "Sorted by name", - "Split into two panes / close the right one": "Split into two panes / close the right one", - "Stop the file work under way, or dismiss what went wrong": "Stop the file work under way, or dismiss what went wrong", + "Split into two panes": "Split into two panes", + "Stop the work under way": "Stop the work under way", "Stopped after %L1 of %Ln items.": { "one": "Stopped after %L1 of %Ln item.", "other": "Stopped after %L1 of %Ln items." @@ -405,7 +403,7 @@ "This folder no longer exists.": "This folder no longer exists.", "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)", + "Type a path or a server's address": "Type a path or a server's address", "Undid compressing into %1.": "Undid compressing into %1.", "Undid copying %Ln items.": { "one": "Undid copying %Ln item.", @@ -428,7 +426,7 @@ }, "Undid renaming %1.": "Undid renaming %1.", "Undo": "Undo", - "Undo / redo the last change to files (or Ctrl+Y)": "Undo / redo the last change to files (or Ctrl+Y)", + "Undo / redo": "Undo / redo", "Undo Compress": "Undo Compress", "Undo Copy": "Undo Copy", "Undo Delete": "Undo Delete", @@ -444,19 +442,24 @@ "Undoing…": "Undoing…", "Unmount": "Unmount", "Unpin": "Unpin", - "Unpin the folder, or take the item off the sidebar": "Unpin the folder, or take the item off the sidebar", + "Unpin from the sidebar": "Unpin from the sidebar", "Untitled Folder": "Untitled Folder", "Untitled Folder %1": "Untitled Folder %1", "User": "User", + "View": "View", "Views": "Views", + "Window": "Window", "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.", "Zoom in / out": "Zoom in / out", + "click": "click", "data not yet available": "data not yet available", + "drag on empty space": "drag on empty space", "file not found": "file not found", "incorrect password": "incorrect password", "invalid file format": "invalid file format", + "right-click": "right-click", "unknown error": "unknown error", "unsupported security scheme": "unsupported security scheme", "“%1” already exists in %2.": "“%1” already exists in %2." From 2d06fcf9bd4e9cd1cc5e649f95d5d9667b297a84 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 17 Nov 2026 16:05:14 +0100 Subject: [PATCH 2/3] Give the preview's shortcuts the grouped form, and Ctrl to every key that needs it The preview window's shortcuts were still given in the old form, so QML refused the window ("Cannot assign to non-existent property 'shortcuts'") and no file could be previewed. They're now a group of the same form, and a new test loads the preview window as the app does, shortcuts shown. Cut, paste, the views and the tile sizes showed bare X, V, 2, 3, - and 0 after the first Ctrl, keys that do nothing alone. Every way shown now has its Ctrl. Co-Authored-By: Claude Opus 5.5 --- src/HelpOverlay.qml | 9 +++++---- src/PreviewWindow.qml | 20 ++++++++++---------- tests/folio_tests.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/HelpOverlay.qml b/src/HelpOverlay.qml index c074b4f2..69046fae 100644 --- a/src/HelpOverlay.qml +++ b/src/HelpOverlay.qml @@ -34,8 +34,9 @@ Rectangle { // a list of keys pressed together. A word starting with ~ is something // done with the mouse ("click"), said rather than drawn as a key. Key // names (Shift, Alt, Ctrl) stay as they are in every language. + // The preview window gives its own, in the same form. readonly property bool mirrored: LayoutMirroring.enabled - readonly property var groups: [ + property var groups: [ { title: qsTr("Moving around"), shortcuts: [ [qsTr("Move the selection"), [["←", "↑", "→", "↓"]]], [qsTr("Into a folder / back out"), mirrored ? [["←"], ["→"]] : [["→"], ["←"]]], @@ -55,7 +56,7 @@ Rectangle { [qsTr("Select everything"), [["Ctrl", "A"]]] ]}, { title: qsTr("Files"), shortcuts: [ - [qsTr("Copy, cut, paste"), [["Ctrl", "C"], ["X"], ["V"]]], + [qsTr("Copy, cut, paste"), [["Ctrl", "C"], ["Ctrl", "X"], ["Ctrl", "V"]]], [qsTr("Copy the path as text"), [["Ctrl", "Shift", "C"]]], [qsTr("Rename"), [["F2"]]], [qsTr("Duplicate"), [["Ctrl", "Shift", "D"]]], @@ -69,8 +70,8 @@ Rectangle { [qsTr("Stop the work under way"), [["Escape"]]] ]}, { title: qsTr("View"), shortcuts: [ - [qsTr("Columns, grid or list"), [["Ctrl", "1"], ["2"], ["3"]]], - [qsTr("Bigger, smaller or normal tiles"), [["Ctrl", "="], ["-"], ["0"]]], + [qsTr("Columns, grid or list"), [["Ctrl", "1"], ["Ctrl", "2"], ["Ctrl", "3"]]], + [qsTr("Bigger, smaller or normal tiles"), [["Ctrl", "="], ["Ctrl", "-"], ["Ctrl", "0"]]], [qsTr("Next or previous sort order"), [["S"], ["Shift", "S"]]], [qsTr("Show hidden files"), [["Ctrl", "H"]]], [qsTr("Reload"), [["F5"]]] diff --git a/src/PreviewWindow.qml b/src/PreviewWindow.qml index eb7530e3..71ed54ea 100644 --- a/src/PreviewWindow.qml +++ b/src/PreviewWindow.qml @@ -181,16 +181,16 @@ ApplicationWindow { anchors.fill: parent visible: win.helpVisible onDismissed: win.helpVisible = false - shortcuts: [ - [win.rtl ? "→ / ←" : "← / →", qsTr("Previous / next file")], - ["⏎", qsTr("Open in its app")], - ["↑ ↓ PgUp PgDn", qsTr("Scroll")], - ["Ctrl+= / Ctrl+-", qsTr("Zoom in / out")], - ["Ctrl+0", qsTr("Fit to the window")], - ["K", qsTr("Play or pause")], - ["Shift+← / Shift+→", qsTr("Back / ahead 5 seconds")], - ["Space / Esc", qsTr("Close")] - ] + groups: [{ title: qsTr("Preview"), shortcuts: [ + [qsTr("Previous / next file"), win.rtl ? [["→"], ["←"]] : [["←"], ["→"]]], + [qsTr("Open in its app"), [["⏎"]]], + [qsTr("Scroll"), [["↑", "↓"], ["Page Up"], ["Page Down"]]], + [qsTr("Zoom in / out"), [["Ctrl", "="], ["Ctrl", "-"]]], + [qsTr("Fit to the window"), [["Ctrl", "0"]]], + [qsTr("Play or pause"), [["K"]]], + [qsTr("Back / ahead 5 seconds"), [["Shift", "←"], ["Shift", "→"]]], + [qsTr("Close"), [["Space"], ["Escape"]]] + ]}] } } diff --git a/tests/folio_tests.cpp b/tests/folio_tests.cpp index 15ce0155..f0c391c7 100644 --- a/tests/folio_tests.cpp +++ b/tests/folio_tests.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -6216,6 +6217,34 @@ private slots: QTRY_COMPARE(previewer.viewer(), QString("other")); } + // The preview window loads as the app loads it, its shortcuts with it. + void previewWindowLoads() + { + QTemporaryDir dir; + write(dir.filePath("notes.txt"), "hello\n"); + Theme theme(dir.filePath("theme")); + Translator translator(dir.filePath("language"), dir.path()); + Thumbnails thumbnails(dir.filePath("cache"), {dir.filePath("none")}); + Previewer previewer; + previewer.start(dir.filePath("notes.txt"), false, "name"); + QQmlApplicationEngine engine; + engine.addImageProvider("thumb", new ThumbnailProvider(&thumbnails)); + engine.rootContext()->setContextProperty("translator", &translator); + engine.rootContext()->setContextProperty("theme", &theme); + engine.rootContext()->setContextProperty("previewer", &previewer); + QStringList problems; + QObject::connect(&engine, &QQmlApplicationEngine::warnings, [&](const QList &warnings) { + for (const QQmlError &warning : warnings) + problems << warning.toString(); + }); + engine.load(QUrl("qrc:/PreviewWindow.qml")); + QVERIFY2(!engine.rootObjects().isEmpty(), qPrintable(problems.join("\n"))); + QObject *window = engine.rootObjects().first(); + window->setProperty("helpVisible", true); + QCoreApplication::processEvents(); + QVERIFY2(problems.isEmpty(), qPrintable(problems.join("\n"))); + } + void previewerShowsOnlyWhatLaysOutQuickly() { // The preview lays out all it's given on its UI thread, about a From 08a404524aa4d6e4ddf4064e0615fb19647a7b1e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 17 Nov 2026 16:22:19 +0100 Subject: [PATCH 3/3] Fit the shortcuts to a narrow window A column of shortcuts was 400 wide whatever the window, and the preview window can be 480 wide, leaving 360: the keycaps at the right were cut off, with no way to scroll to them. A column now narrows to the room there is (to 240 at the least), its descriptions eliding first, and what still doesn't fit scrolls. Co-Authored-By: Claude Opus 5.5 --- src/HelpOverlay.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/HelpOverlay.qml b/src/HelpOverlay.qml index 69046fae..b0012f04 100644 --- a/src/HelpOverlay.qml +++ b/src/HelpOverlay.qml @@ -87,8 +87,10 @@ Rectangle { ] // As many columns as fit, and the groups dealt out among them in turn - // to whichever is shortest, so they come out about as long. - readonly property int columnWidth: 400 + // to whichever is shortest, so they come out about as long. A column + // narrows to fit a small window (the preview's can be 480 wide), its + // descriptions eliding first, and what still doesn't fit scrolls. + readonly property int columnWidth: Math.min(400, Math.max(240, width - 64 - 56)) readonly property int columnGap: 48 readonly property int columnCount: Math.max(1, Math.min(3, Math.floor((width - 64 - 56 + columnGap) / (columnWidth + columnGap)))) readonly property var columns: { @@ -122,7 +124,7 @@ Rectangle { id: flick anchors.fill: parent anchors.margins: 28 - contentWidth: width + contentWidth: Math.max(width, content.implicitWidth) contentHeight: content.implicitHeight clip: true boundsBehavior: Flickable.StopAtBounds @@ -154,6 +156,7 @@ Rectangle { id: column required property var modelData Layout.preferredWidth: overlay.columnWidth + Layout.maximumWidth: overlay.columnWidth Layout.alignment: Qt.AlignTop spacing: 22 Repeater {