Skip to content
Merged
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 src/FileMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ FolioMenu {
// A selected item in the folder being shown stands for the whole
// selection, so Copy, Compress or Delete act on all of it.
readonly property bool forSelection: forItem && target.selected === true && backend.folder.selectedCount > 1
&& backend.folder.indexOf(target.name) >= 0
&& backend.folder.indexOfPath(target.path) >= 0
readonly property var paths: !forItem ? [] : forSelection ? backend.folder.selectedPaths() : [target.path]
// One disk image, and the drives it could be burned to, asked of udisks
// as the menu opens rather than on every binding.
Expand Down
32 changes: 31 additions & 1 deletion src/FileRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ Item {
required property int itemCount
required property string icon
required property bool selected
required property int depth
required property bool expanded

property bool current: false
// In a column to the left: the folder the next column is showing.
property bool trail: false
property bool detailed: false
property bool chevron: false
// In the list, a tree: each level indented, and a folder's arrow opens
// it in place (or closes it).
property bool tree: false

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

implicitHeight: 32

Expand Down Expand Up @@ -71,10 +77,34 @@ Item {

RowLayout {
anchors.fill: parent
anchors.leftMargin: 14
anchors.leftMargin: row.tree ? 4 + row.depth * 20 : 14
anchors.rightMargin: 14
spacing: 12

// The folder's arrow: pointing on (with the reading direction)
// while it's closed, down while it's open.
Item {
visible: row.tree
Layout.rightMargin: -8
implicitWidth: 18
implicitHeight: 32
Glyph {
visible: row.isDir
anchors.centerIn: parent
name: row.LayoutMirroring.enabled ? "back" : "forward"
size: 12
rotation: row.expanded ? (row.LayoutMirroring.enabled ? -90 : 90) : 0
color: arrowHover.hovered ? theme.foreground : theme.secondaryForeground
}
HoverHandler { id: arrowHover; enabled: row.isDir }
TapHandler {
enabled: row.isDir
// Before the row's own tap, which would select it instead.
grabPermissions: PointerHandler.CanTakeOverFromAnything
onTapped: row.toggled()
}
}

Item {
implicitWidth: 20
implicitHeight: 20
Expand Down
47 changes: 39 additions & 8 deletions src/FolderList.qml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import QtQuick
import QtQuick.Controls

// The folder as a list: name, size and date (the date, then the size, step
// aside in a narrow window). No headings: the sort menu and S sort it.
// The folder as a list, and a tree, as in the Finder: name, size and date
// (the date, then the size, step aside in a narrow window), and an arrow on
// each folder that opens it in place, its items listed under it a level
// in. No headings: the sort menu and S sort it.
FileListView {
id: list

Expand All @@ -24,15 +26,42 @@ FileListView {
rectOf: (i) => Qt.rect(0, i * 32, list.width, 32)
}

// → goes into the selected folder and ← back up, as in the columns;
// mirrored, the other way round, with the reading direction.
function enter() {
// → opens the selected folder in place, and on one open already steps
// to its first item; ← closes it, or steps out to the folder the item
// is in, and from the top goes up a folder. Where nothing opens in
// place (a search, Recents, the trash), → goes into the folder. Mirrored,
// the other way round, with the reading direction. ⏎ or a double click
// goes into a folder anywhere.
function deeper() {
const item = backend.folder.get(currentIndex)
if (item.isDir)
if (!item.isDir)
return
if (!backend.folder.expandable)
backend.navigate(item.path)
else if (!item.expanded)
backend.folder.setExpanded(currentIndex, true)
else if (currentIndex + 1 < count && backend.folder.get(currentIndex + 1).depth > item.depth)
currentIndex = currentIndex + 1
}
Keys.onRightPressed: LayoutMirroring.enabled ? backend.goUp() : enter()
Keys.onLeftPressed: LayoutMirroring.enabled ? enter() : backend.goUp()
function shallower() {
const item = backend.folder.get(currentIndex)
if (item.expanded)
backend.folder.setExpanded(currentIndex, false)
else if (item.depth > 0)
currentIndex = backend.folder.parentRow(currentIndex)
else
backend.goUp()
}
Keys.onRightPressed: LayoutMirroring.enabled ? shallower() : deeper()
Keys.onLeftPressed: LayoutMirroring.enabled ? deeper() : shallower()
// A folder that couldn't be opened in place says why.
Connections {
target: backend.folder
function onExpandFailed(message) { backend.showMessage(message) }
}
// Open folders close on going to another view; coming back, the list
// starts closed.
Component.onDestruction: backend.folder.collapseAll()

// Right-click on an item (selecting it) or on empty space.
signal contextMenu(var item, string folder, point at)
Expand All @@ -52,7 +81,9 @@ FileListView {
delegate: FileRow {
width: list.width
detailed: true
tree: backend.folder.expandable
current: selected
onToggled: backend.folder.setExpanded(index, !expanded)
onClicked: (modifiers) => { selecting.click(index, modifiers); list.forceActiveFocus() }
onActivated: backend.open(path)
}
Expand Down
16 changes: 15 additions & 1 deletion src/FolderPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,22 @@ FocusScope {
// through a rename, and through undoing and redoing one.
function onRenamed(from, to) { places.renamed(from, to) }
function onDone(folder, name) {
if (folder !== backend.path)
// Done inside a folder opened in place (the list's tree): its
// item is found by its whole path, now or once the folder's
// been read again.
if (folder !== backend.path) {
if (!backend.folder.expandable || !folder.startsWith(backend.path + "/"))
return
const path = folder + "/" + name
const inside = backend.folder.indexOfPath(path)
if (inside >= 0 && view.item) {
view.item.select(inside, false)
} else {
pane.lastPath = path
pane.cursorLetGo = false
}
return
}
const row = backend.folder.indexOf(name)
if (row >= 0 && view.item)
view.item.select(row, false)
Expand Down
40 changes: 34 additions & 6 deletions src/Selecting.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ QtObject {
// The ListView or GridView whose currentIndex is the cursor.
required property var view
property int anchor: -1
// The anchor's item, so its row is found again when rows come or go
// above it (a folder opening in the list's tree): it can be on the
// other side of them from the cursor.
property string anchorPath: ""
function setAnchor(row) {
anchor = row
anchorPath = row >= 0 ? (backend.folder.get(row).path || "") : ""
}
// Set while the cursor is moved on purpose, so moving it doesn't also
// reset the selection.
property bool quiet: false
Expand All @@ -16,15 +24,35 @@ QtObject {
quiet = true
view.currentIndex = index
quiet = false
placed()
}

// The item the cursor is on, and its row. Rows coming or going above it
// (a folder opening in the list's tree) move the cursor's row without
// moving the cursor: that isn't a move, and leaves the selection alone.
property string cursorPath: ""
property int cursorRow: -1
function placed() {
cursorPath = view.currentIndex >= 0 ? (backend.folder.get(view.currentIndex).path || "") : ""
cursorRow = view.currentIndex
}

// The cursor moved by the keyboard (or the view itself).
function cursorMoved() {
if (quiet)
return
const path = view.currentIndex >= 0 ? (backend.folder.get(view.currentIndex).path || "") : ""
if (path.length > 0 && path === cursorPath) {
// Still on its item: the anchor stays on its own item too.
if (anchorPath.length > 0)
anchor = backend.folder.indexOfPath(anchorPath)
cursorRow = view.currentIndex
return
}
backend.folder.selectOnly(view.currentIndex)
anchor = view.currentIndex
setAnchor(view.currentIndex)
view.positionViewAtIndex(view.currentIndex, ListView.Contain)
placed()
}

function click(index, modifiers) {
Expand All @@ -34,10 +62,10 @@ QtObject {
backend.folder.selectRange(anchor < 0 ? index : anchor, index, (modifiers & Qt.AltModifier) !== 0)
} else if (modifiers & Qt.AltModifier) {
backend.folder.toggleSelected(index)
anchor = index
setAnchor(index)
} else {
backend.folder.selectOnly(index)
anchor = index
setAnchor(index)
}
moveTo(index)
}
Expand Down Expand Up @@ -80,7 +108,7 @@ QtObject {
// With no cursor (let go of by a click on empty space), the range
// starts at the first item, where a step from no cursor starts.
if (anchor < 0)
anchor = Math.max(0, view.currentIndex)
setAnchor(Math.max(0, view.currentIndex))
moveTo(index)
backend.folder.selectRange(anchor, index, false)
view.positionViewAtIndex(index, ListView.Contain)
Expand All @@ -90,7 +118,7 @@ QtObject {
// Ctrl+A or the rubber band since) stays selected.
function letGo() {
moveTo(-1)
anchor = -1
setAnchor(-1)
}

// Puts the cursor on `row` (or, for -1, the first item). `keep` leaves a
Expand All @@ -100,7 +128,7 @@ QtObject {
moveTo(index)
if (!(keep && backend.folder.selectedCount > 0)) {
backend.folder.selectOnly(index)
anchor = index
setAnchor(index)
}
if (index >= 0)
view.positionViewAtIndex(index, ListView.Contain)
Expand Down
Loading
Loading