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: 2 additions & 0 deletions src/DriveMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ FolioMenu {
popup(near, Math.min(near.width / 2, 120), near.height / 2)
else
popup()
// The first entry is highlighted already, as in the folders' menu.
currentIndex = 0
}

FolioMenuItem {
Expand Down
6 changes: 6 additions & 0 deletions src/FileMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ FolioMenu {
keys: "Ctrl+P"
onTriggered: fileMenu.pinRequested(fileMenu.target.path)
}
// A folder of home's hidden from its sidebar section goes back there.
FolioMenuItem {
shown: fileMenu.forFolder && places.hiddenFromHome(fileMenu.target.path)
text: qsTr("Show in Home")
onTriggered: places.showInHome(fileMenu.target.path)
}
MenuLine { shown: fileMenu.forItem && fileMenu.forFiles }
FolioMenuItem {
shown: !fileMenu.trashView && fileMenu.forItem && fileMenu.forFiles
Expand Down
8 changes: 8 additions & 0 deletions src/FolderPane.qml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ FocusScope {
// follow.
onActiveFocusChanged: if (activeFocus && host) host.activePane = pane
function focusView() { if (view.item) view.item.focusView() }
// Rename… in a sidebar folder's menu.
function renameFolder(path) { rename.open({ path: path, isDir: true }) }
// A place picked in the sidebar: the columns start at it.
function startAt(path) { if (view.item && view.item.startAt) view.item.startAt(path) }

Expand Down Expand Up @@ -264,6 +266,9 @@ FocusScope {

Connections {
target: fileOps
// A pinned folder's pin, or a folder hidden from Home, follows it
// 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)
return
Expand All @@ -275,6 +280,9 @@ FocusScope {
}
function onFailed(message) { backend.showMessage(message) }
function onNotice(notice) { backend.showNotice(notice) }
// Work done (a folder of home's trashed, say) shows in the sidebar
// at once, not at its next look in 15 seconds.
function onBusyChanged() { if (!fileOps.busy) places.refresh() }
// A drive about to be formatted or burned is left first, by every
// pane, and the sidebar shows it as it is afterwards.
function onReleasing(root) { places.leave(root) }
Expand Down
3 changes: 3 additions & 0 deletions src/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ ApplicationWindow {
target: win.activePane ? win.activePane.paneBackend : backend
onFinished: win.activePane.focusView()
onPlaceChosen: (path) => win.activePane.startAt(path)
onRenameRequested: (path) => win.activePane.renameFolder(path)
onDeleteRequested: (path) => win.activePane.confirmDelete([path])
onTrashRequested: (path) => win.activePane.paneFileOps.trash([path])
onFormatRequested: (disk) => win.activePane.formatDrive(disk)
Layout.topMargin: parent.parent.barHeight
Layout.preferredWidth: 190
Expand Down
55 changes: 55 additions & 0 deletions src/PlaceMenu.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import QtQuick

// The menu of a folder in the sidebar's Home or Pinned section: Rename…,
// Hide (taking it out of Home, until Show in Home in its own menu puts it
// back) or Unpin, and Trash, which with Alt held becomes Delete… (for
// good, after asking).
FolioMenu {
id: menu

// The sidebar's row for the folder: {name, path}, and whether it's
// pinned rather than one of home's own.
property var place: ({})
property bool pinned: false

signal renameRequested(string path)
signal trashRequested(string path)
signal deleteRequested(string path)

// Opens at the pointer, or (from the keyboard) beside the row, with
// its first entry already highlighted.
function show(row, isPinned, near) {
place = row
pinned = isPinned
held = fileOps.altHeld()
if (near)
popup(near, Math.min(near.width / 2, 120), near.height / 2)
else
popup()
currentIndex = 0
}

// Alt can go down or up anywhere while the menu's open, so it's checked
// a few times a second rather than through key events.
property bool held: false
Timer {
interval: 50
repeat: true
running: menu.visible
onTriggered: menu.held = fileOps.altHeld()
}

FolioMenuItem {
text: qsTr("Rename…")
onTriggered: menu.renameRequested(menu.place.path)
}
FolioMenuItem {
text: menu.pinned ? qsTr("Unpin") : qsTr("Hide")
onTriggered: menu.pinned ? places.unpin(menu.place.path) : places.hideFromHome(menu.place.path)
}
MenuLine { }
FolioMenuItem {
text: menu.held ? qsTr("Delete…") : qsTr("Trash")
onTriggered: menu.held ? menu.deleteRequested(menu.place.path) : menu.trashRequested(menu.place.path)
}
}
5 changes: 3 additions & 2 deletions src/RenameDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ FolioDialog {
function close() { item = null }
function submit() {
problem = fileOps.rename(item.path, field.text)
if (problem.length === 0)
close()
if (problem.length > 0)
return
close()
}

// On the dialog, not the field, so Escape still cancels after Tab has
Expand Down
41 changes: 36 additions & 5 deletions src/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Rectangle {
signal finished()
// Format… in a drive's menu, with what udisks knows of the drive.
signal formatRequested(var disk)
// Rename… and Delete… in a folder's menu.
signal renameRequested(string path)
signal deleteRequested(string path)
// Trash in a folder's menu, done by the pane used last, as the rest are.
signal trashRequested(string path)
// A place picked here: the columns start at it, rather than at the
// folders above it.
signal placeChosen(string path)
Expand Down Expand Up @@ -102,24 +107,39 @@ Rectangle {
// Rows taken away under the keyboard leave it on the last one.
onRowsChanged: cursor = Math.max(0, Math.min(cursor, rows.length - 1))

// Alt+⏎ (or the Menu key) on a drive opens its menu beside it; the
// files' menu stands aside for it.
// Alt+⏎ (or the Menu key) on a drive or a folder of Home or Pinned
// opens its menu beside it; the files' menu stands aside for it.
readonly property var keyedDrive: activeFocus && cursor >= devicesAt && cursor < pluginsAt
? driveRows.itemAt(cursor - devicesAt) : null
readonly property var keyedPlace: !activeFocus ? null
: cursor < pinnedAt ? homeRows.itemAt(cursor)
: cursor < viewsAt ? pinRows.itemAt(cursor - pinnedAt) : null
function menuKey(event) {
return ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && (event.modifiers & Qt.AltModifier))
|| event.key === Qt.Key_Menu || (event.key === Qt.Key_F10 && (event.modifiers & Qt.ShiftModifier))
}
Keys.onShortcutOverride: (event) => event.accepted = menuKey(event) && keyedDrive !== null
Keys.onShortcutOverride: (event) => event.accepted = menuKey(event) && (keyedDrive !== null || keyedPlace !== null)
// Return has its own handler, which Keys calls before this one.
Keys.onPressed: (event) => event.accepted = openDriveMenu(event)
function openDriveMenu(event) {
if (!menuKey(event) || !keyedDrive)
if (!menuKey(event))
return false
if (keyedDrive)
driveMenu.show(keyedDrive.modelData, keyedDrive)
else if (keyedPlace)
placeMenu.show(keyedPlace.modelData, cursor >= pinnedAt, keyedPlace)
else
return false
driveMenu.show(keyedDrive.modelData, keyedDrive)
return true
}

PlaceMenu {
id: placeMenu
onRenameRequested: (path) => sidebar.renameRequested(path)
onDeleteRequested: (path) => sidebar.deleteRequested(path)
onTrashRequested: (path) => sidebar.trashRequested(path)
}

DriveMenu {
id: driveMenu
onOpenRequested: (path) => { sidebar.go(path); sidebar.finished() }
Expand Down Expand Up @@ -284,8 +304,10 @@ Rectangle {
TapHandler { onTapped: sidebar.go(places.home) }
}
Repeater {
id: homeRows
model: places.places
PlaceRow {
id: homeRow
required property var modelData
required property int index
dropPath: modelData.path
Expand All @@ -296,6 +318,10 @@ Rectangle {
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.go(modelData.path)
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: placeMenu.show(homeRow.modelData, false, null)
}
}
}

Expand All @@ -304,6 +330,7 @@ Rectangle {
// empty) as the place to drop it.
SectionLabel { text: qsTr("Pinned"); visible: places.pinned.length > 0 || sidebar.dragging }
Repeater {
id: pinRows
model: places.pinned
PlaceRow {
id: pinRow
Expand All @@ -321,6 +348,10 @@ Rectangle {
// hovered, or on the keyboard's row, where Delete does
// the same.
endPadding: unpin.visible ? unpin.implicitWidth + 6 : 14
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: placeMenu.show(pinRow.modelData, true, null)
}
IconButton {
id: unpin
anchors.right: parent.right
Expand Down
11 changes: 11 additions & 0 deletions src/fileops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ bool FileOps::shiftHeld() {
return QGuiApplication::queryKeyboardModifiers() & Qt::ShiftModifier;
}

bool FileOps::altHeld() {
return QGuiApplication::queryKeyboardModifiers() & Qt::AltModifier;
}

void FileOps::copy(const QStringList &paths) {
if (!paths.isEmpty())
QGuiApplication::clipboard()->setMimeData(mimeDataFor(paths, false));
Expand Down Expand Up @@ -1638,6 +1642,7 @@ QString FileOps::rename(const QString &path, const QString &name) {
return QFileInfo::exists(destination) ? tr("%1 already exists here.").arg(clean)
: tr("Couldn't rename %1.").arg(info.fileName());
remember({Renaming, info.fileName(), 1, {identified({false, destination, path})}});
emit renamed(path, destination);
emit done(info.absolutePath(), clean);
return {};
}
Expand Down Expand Up @@ -1941,6 +1946,12 @@ void FileOps::step(bool undoing) {
sayStopped(job);
else
emit notice(didMessage(change, undoing));
// A rename undone or redone moves the item back or on again;
// each flipped step is now at `path`, from `other`.
if (change.kind == Renaming)
for (const Step &step : result.steps.mid(result.left))
if (!step.trash && !step.folder)
emit renamed(step.other, step.path);
// What's back in a folder is selected there, as after a paste.
for (const Step &step : result.steps.mid(result.left))
if (!step.folder && (!step.trash || step.other.isEmpty())) {
Expand Down
4 changes: 4 additions & 0 deletions src/fileops.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class FileOps : public QObject {
// plain text, so pasting into a terminal or editor gives the path.
// Whether Shift is held right now, for menus that change with it.
Q_INVOKABLE static bool shiftHeld();
Q_INVOKABLE static bool altHeld();
Q_INVOKABLE void copy(const QStringList &paths);
Q_INVOKABLE void cut(const QStringList &paths);
Q_INVOKABLE void yank(const QStringList &paths);
Expand Down Expand Up @@ -277,6 +278,9 @@ class FileOps : public QObject {
void drivesChanged();
// Work finished in `folder`, which now holds `name` (to select it).
void done(const QString &folder, const QString &name);
// An item renamed from `from` to `to`, by Rename or by undoing or
// redoing one, for the sidebar's pins and hidden folders to follow.
void renamed(const QString &from, const QString &to);

private:
void setBusy(const QString &busy);
Expand Down
3 changes: 3 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"Couldn't recreate %1.": "Couldn't recreate %1.",
"Couldn't remove %1.": "Couldn't remove %1.",
"Couldn't rename %1.": "Couldn't rename %1.",
"Couldn't save the hidden folders to %1.": "Couldn't save the hidden folders to %1.",
"Couldn't save the pin to %1.": "Couldn't save the pin to %1.",
"Couldn't start a terminal: xdg-terminal-exec isn't installed.": "Couldn't start a terminal: xdg-terminal-exec isn't installed.",
"Couldn't unmount %1: %2": "Couldn't unmount %1: %2",
Expand Down Expand Up @@ -210,6 +211,7 @@
"GVfs gave no local folder for the mount": "GVfs gave no local folder for the mount",
"Go home": "Go home",
"Go to the parent folder": "Go to the parent folder",
"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",
Expand Down Expand Up @@ -364,6 +366,7 @@
"Show as grid": "Show as grid",
"Show as list": "Show as list",
"Show hidden files": "Show hidden files",
"Show in Home": "Show in Home",
"Show these shortcuts": "Show these shortcuts",
"Sign in": "Sign in",
"Size": "Size",
Expand Down
Loading
Loading