Skip to content
Open
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
24 changes: 17 additions & 7 deletions src/FileRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ Item {
// In the list, a tree: each level indented, and a folder's arrow opens
// it in place (or closes it).
property bool tree: false
// How much bigger than the columns' rows this one is: its height and
// its picture grow, the name and details don't, as with the grid's
// tiles. The list sets it from its size step.
property real zoom: 1

signal clicked(int modifiers)
signal activated()
signal toggled()

implicitHeight: 32
implicitHeight: Math.round(32 * zoom)

// The name always gets room: in a narrow window the date goes first,
// then the size. (The icon says what kind a file is; there's no column
Expand Down Expand Up @@ -77,7 +81,13 @@ Item {

RowLayout {
anchors.fill: parent
anchors.leftMargin: row.tree ? 4 + row.depth * 20 : 14
// Each level is indented by half the picture's width plus a fixed
// 10: an open folder's items have their arrow under the folder's
// own picture at any size. (The arrow is a fixed 18 wide, so
// indenting by the picture's whole width, which grows twice as
// fast as the picture's middle moves, left the arrows drifting
// further out with every size step.)
anchors.leftMargin: row.tree ? 4 + row.depth * (Math.round(10 * row.zoom) + 10) : 14
anchors.rightMargin: 14
spacing: 12

Expand Down Expand Up @@ -106,8 +116,8 @@ Item {
}

Item {
implicitWidth: 20
implicitHeight: 20
implicitWidth: Math.round(20 * row.zoom)
implicitHeight: Math.round(20 * row.zoom)
Image {
id: thumb
anchors.fill: parent
Expand All @@ -129,8 +139,8 @@ Item {
}
Rectangle {
id: rowMask
width: 20
height: 20
width: Math.round(20 * row.zoom)
height: Math.round(20 * row.zoom)
radius: Math.min(4, theme.radius)
visible: false
layer.enabled: true
Expand All @@ -139,7 +149,7 @@ Item {
anchors.centerIn: parent
visible: !thumb.visible
name: row.glyph
size: 16
size: Math.round(16 * row.zoom)
color: row.isDir ? theme.accent : theme.secondaryForeground
}
}
Expand Down
17 changes: 1 addition & 16 deletions src/FolderGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,7 @@ GridView {
property real zoom: 1
readonly property real tileZoom: Math.max(0.5, Math.min(zoom, (width - 40) / 128))
signal zoomRequested(int step)
WheelHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
acceptedModifiers: Qt.ControlModifier
// A touchpad sends many small deltas: a step per notch's worth
// (120), and nothing for an event that doesn't move up or down.
property real pending: 0
onWheel: (event) => {
// Every whole notch is a step; the rest waits for the next event.
pending += event.angleDelta.y
while (Math.abs(pending) >= 120) {
const step = pending > 0 ? 1 : -1
grid.zoomRequested(step)
pending -= step * 120
}
}
}
ZoomWheel { onZoomRequested: (step) => grid.zoomRequested(step) }
// The rows reflow, so bring the cursor's tile back into view.
onTileZoomChanged: Qt.callLater(() => { if (currentIndex >= 0) { forceLayout(); positionViewAtIndex(currentIndex, GridView.Contain) } })
readonly property int columns: Math.max(1, Math.floor(width / (40 + 128 * tileZoom)))
Expand Down
16 changes: 14 additions & 2 deletions src/FolderList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,24 @@ FileListView {
// Where the keyboard's menu (Alt+Return) opens: beside the cursor's item.
function menuAnchor() { return currentItem }

Selecting { id: selecting; view: list; pageStep: Math.max(1, Math.floor(list.height / 32) - 1) }
// Rows grow with the size step, as the grid's tiles do with theirs: their
// height and picture, not the name and details. A value outside the
// steps (a hand-edited setting) is held to the ends.
property real zoom: 1
readonly property real rowZoom: Math.max(1, Math.min(zoom, 2))
readonly property int rowHeight: Math.round(32 * rowZoom)
signal zoomRequested(int step)
ZoomWheel { onZoomRequested: (step) => list.zoomRequested(step) }
// The rows reflow, so bring the cursor's row back into view.
onRowHeightChanged: Qt.callLater(() => { if (currentIndex >= 0) { forceLayout(); positionViewAtIndex(currentIndex, ListView.Contain) } })

Selecting { id: selecting; view: list; pageStep: Math.max(1, Math.floor(list.height / list.rowHeight) - 1) }
onCurrentIndexChanged: selecting.cursorMoved()
Keys.onPressed: (event) => selecting.page(event) || selecting.extendBy(event, event.key === Qt.Key_Up ? -1 : event.key === Qt.Key_Down ? 1 : 0)

Band {
view: list
rectOf: (i) => Qt.rect(0, i * 32, list.width, 32)
rectOf: (i) => Qt.rect(0, i * list.rowHeight, list.width, list.rowHeight)
}

// → opens the selected folder in place, and on one open already steps
Expand Down Expand Up @@ -82,6 +93,7 @@ FileListView {

delegate: FileRow {
width: list.width
zoom: list.rowZoom
detailed: true
tree: backend.folder.expandable
current: selected
Expand Down
30 changes: 26 additions & 4 deletions src/FolderPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,31 @@ FocusScope {
property real zoom: host ? host.zoom : 1
onZoomChanged: if (host && !closable) host.zoom = zoom
readonly property var zoomSteps: [0.75, 1, 1.25, 1.5, 2]
// The list's rows have steps of their own, three: its normal size, and
// two bigger. They're kept apart from the grid's, so each view is
// remembered at the size it was left at.
property real listZoom: host ? host.listZoom : 1
onListZoomChanged: if (host && !closable) host.listZoom = listZoom
readonly property var listZoomSteps: [1, 1.5, 2]
// The step `step` away from `current` among `steps`, held to the ends; a
// value that's none of them (a hand-edited setting) counts as normal.
function stepped(steps, current, step) {
const at = steps.indexOf(current)
return steps[Math.max(0, Math.min(steps.length - 1, (at < 0 ? steps.indexOf(1) : at) + step))]
}
// The keys and the wheel size what's showing: the list's rows, or else
// the grid's tiles.
function zoomBy(step) {
const at = zoomSteps.indexOf(zoom)
zoom = zoomSteps[Math.max(0, Math.min(zoomSteps.length - 1, (at < 0 ? 1 : at) + step))]
if (viewMode === "list")
listZoom = stepped(listZoomSteps, listZoom, step)
else
zoom = stepped(zoomSteps, zoom, step)
}
function resetZoom() {
if (viewMode === "list")
listZoom = 1
else
zoom = 1
}
function cycleView() {
viewMode = viewMode === "columns" ? "list" : viewMode === "list" ? "grid" : "columns"
Expand Down Expand Up @@ -205,7 +227,7 @@ FocusScope {
Shortcut { sequence: "Ctrl+3"; enabled: pane.active; onActivated: pane.viewMode = "grid" }
Shortcut { sequences: [StandardKey.ZoomIn, "Ctrl+="]; enabled: pane.active; onActivated: pane.zoomBy(1) }
Shortcut { sequences: [StandardKey.ZoomOut]; enabled: pane.active; onActivated: pane.zoomBy(-1) }
Shortcut { sequence: "Ctrl+0"; enabled: pane.active; onActivated: pane.zoom = 1 }
Shortcut { sequence: "Ctrl+0"; enabled: pane.active; onActivated: pane.resetZoom() }
Shortcut { sequences: ["Return", "Enter"]; enabled: pane.keys; onActivated: if (pane.current.path) backend.open(pane.current.path) }
Shortcut { sequences: ["Backspace", "Alt+Up"]; enabled: pane.keys; onActivated: backend.goUp() }
Shortcut { sequences: ["Alt+Left", "Back"]; enabled: pane.active; onActivated: backend.back() }
Expand Down Expand Up @@ -483,7 +505,7 @@ FocusScope {
}
}
Component { id: gridView; FolderGrid { zoom: pane.zoom; onZoomRequested: (step) => pane.zoomBy(step) } }
Component { id: listView; FolderList { } }
Component { id: listView; FolderList { zoom: pane.listZoom; onZoomRequested: (step) => pane.zoomBy(step) } }
Component { id: columnsView; FolderColumns { detailsPane: pane } }
}

Expand Down
2 changes: 1 addition & 1 deletion src/HelpOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Rectangle {
]},
{ title: qsTr("View"), shortcuts: [
[qsTr("Columns, list or grid"), [["Ctrl", "1"], ["Ctrl", "2"], ["Ctrl", "3"]]],
[qsTr("Bigger, smaller or normal tiles"), [["Ctrl", "="], ["Ctrl", "-"], ["Ctrl", "0"]]],
[qsTr("Bigger, smaller or normal tiles and rows"), [["Ctrl", "="], ["Ctrl", "-"], ["Ctrl", "0"]]],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Help text loses its translations. This changes the lookup key, but only the English catalog gets the new key. Other languages still translate the old text, so this help entry now appears in English. Update the other catalogs to include the new wording.

Fix in Cursor

[qsTr("Next or previous sort order"), [["S"], ["Shift", "S"]]],
[qsTr("Show hidden files"), [["Ctrl", "H"]]],
[qsTr("Reload"), [["F5"]]]
Expand Down
4 changes: 4 additions & 0 deletions src/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ ApplicationWindow {
// Columns on a first launch; after that, whichever view was used last.
property string viewMode: "columns"
property real zoom: 1
// The list's own size step, apart from the grid's.
property real listZoom: 1

// The pane keys, the sidebar and the details go to.
property var activePane: leftPane
Expand All @@ -78,6 +80,7 @@ ApplicationWindow {
Settings {
property alias viewMode: win.viewMode
property alias zoom: win.zoom
property alias listZoom: win.listZoom
}

// Ctrl+Alt+N: a second pane on the right, starting where the active
Expand All @@ -92,6 +95,7 @@ ApplicationWindow {
rightPane.closable = true
rightPane.viewMode = activePane.viewMode
rightPane.zoom = activePane.zoom
rightPane.listZoom = activePane.listZoom
rightPane.closeRequested.connect(closeSplit)
}
rightPane.focusView()
Expand Down
23 changes: 23 additions & 0 deletions src/ZoomWheel.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import QtQuick

// Ctrl+scroll over a view asks for a size step, the way Ctrl+= and Ctrl+-
// do: one step per notch of the wheel, up for bigger. The view says what
// a step means (the grid's tiles, the list's rows).
WheelHandler {
signal zoomRequested(int step)

acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
acceptedModifiers: Qt.ControlModifier
// A touchpad sends many small deltas: a step per notch's worth
// (120), and nothing for an event that doesn't move up or down.
property real pending: 0
onWheel: (event) => {
// Every whole notch is a step; the rest waits for the next event.
pending += event.angleDelta.y
while (Math.abs(pending) >= 120) {
const step = pending > 0 ? 1 : -1
zoomRequested(step)
pending -= step * 120
}
}
}
2 changes: 1 addition & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"Archive": "Archive",
"Back / ahead 5 seconds": "Back / ahead 5 seconds",
"Back / forward": "Back / forward",
"Bigger, smaller or normal tiles": "Bigger, smaller or normal tiles",
"Bigger, smaller or normal tiles and rows": "Bigger, smaller or normal tiles and rows",
"Biggest first": "Biggest first",
"Burn": "Burn",
"Burn %1?": "Burn %1?",
Expand Down
1 change: 1 addition & 0 deletions src/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<file>HelpOverlay.qml</file>
<file>Selecting.qml</file>
<file>Band.qml</file>
<file>ZoomWheel.qml</file>
<file>FolioMenu.qml</file>
<file>FolioMenuItem.qml</file>
<file>MenuLine.qml</file>
Expand Down
3 changes: 3 additions & 0 deletions tests/folio_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ private slots:
width: 900; height: 620; visible: true
property string viewMode: "columns"
property real zoom: 1
property real listZoom: 1
property bool split: false
property bool helpVisible: false
property var activePane: null
Expand Down Expand Up @@ -1211,6 +1212,7 @@ private slots:
width: 900; height: 620; visible: true
property string viewMode: "columns"
property real zoom: 1
property real listZoom: 1
property bool split: false
property bool helpVisible: false
property var activePane: null
Expand Down Expand Up @@ -7351,6 +7353,7 @@ private slots:
width: 900; height: 620; visible: true
property string viewMode: "list"
property real zoom: 1
property real listZoom: 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 New sizes have no tests. The test changes only add listZoom to existing windows; none changes it or checks the new controls. Add a test that steps through heights 32, 48, and 64, checks the end stops and Ctrl+0, and confirms that switching views leaves the grid size unchanged. Otherwise the suite can pass even if the new controls stop resizing rows.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Cursor

property bool split: false
property bool helpVisible: false
property var activePane: null
Expand Down