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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build/
*.pkg.tar.*
__pycache__/
/pkgbuild/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Files (`folio`) is Omarchy's file manager. It's one quiet window that follows yo

- **Three views**: Finder-style columns, a list that opens folders in place as a tree, and a grid with real previews. Ctrl+1/2/3 switches.
- **Space previews** pictures, video, audio, PDFs, text and Markdown at full size, in their own window.
- **The sidebar** holds everything in your home folder, pinned folders (shared with GTK file dialogs), Recents, Trash with restore, your drives, and the machines on your tailnet, which open over SFTP.
- **The sidebar** holds everything in your home folder, pinned folders (shared with GTK file dialogs), Recents, Trash with restore, your drives (mounted or not, as Nautilus lists them: a click mounts one, and a drive plugged in mounts by itself), and the machines on your tailnet, which open over SFTP.
- **Right-click** (or Alt+Enter) to open with another app, rename, duplicate, compress, share by Dropbox link, Taildrop or LocalSend, and delete. Copy and paste work with other apps, and nothing is ever overwritten.
- **Split** the window in two with Ctrl+Alt+N to move things between folders.
- **Plugins** add sidebar sections, Share entries and views; Tailscale, Dropbox and LocalSend are plugins too. [docs/plugins.md](docs/plugins.md) shows how to write one.
Expand Down
9 changes: 5 additions & 4 deletions src/DriveMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import QtQuick
FolioMenu {
id: menu

// The sidebar's row for the drive: {name, path, release}.
// The sidebar's row for the drive: {name, path, release}, with no path
// but its `volume` while it isn't mounted.
property var drive: ({})
// What udisks knows of it (fileOps.driveAt), or empty.
property var disk: ({})

signal openRequested(string path)
signal openRequested(var drive)
signal formatRequested(var disk)

// Opens at the pointer, or (from the keyboard) beside the row.
function show(row, near) {
drive = row
disk = fileOps.driveAt(row.path)
disk = row.path ? fileOps.driveAt(row.path) : ({})
if (near)
popup(near, Math.min(near.width / 2, 120), near.height / 2)
else
Expand All @@ -28,7 +29,7 @@ FolioMenu {

FolioMenuItem {
text: qsTr("Mount")
onTriggered: menu.openRequested(menu.drive.path)
onTriggered: menu.openRequested(menu.drive)
}
FolioMenuItem {
shown: !!menu.drive.release
Expand Down
16 changes: 10 additions & 6 deletions src/MountPrompt.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import QtQuick.Layouts
// GVfs's password request while connecting to another machine whose keys
// aren't set up, or its question about a server it can't vouch for (a key
// seen for the first time, a certificate that can't be verified), put to
// the user in the window. The wording comes from GVfs, already translated.
// the user in the window, as is an encrypted drive's passphrase. The
// wording comes from GVfs, already translated.
FolioDialog {
id: prompt

readonly property var mounter: backend.mounter
readonly property bool question: mounter.choices.length > 0

title: question ? qsTr("Check the server") : qsTr("Sign in")
readonly property bool drive: mounter.drive
title: question ? (drive ? qsTr("Check the drive") : qsTr("Check the server"))
: drive ? qsTr("Unlock") : qsTr("Sign in")
cardWidth: 600
spacing: 18
visible: mounter.asking
Expand All @@ -26,7 +29,7 @@ FolioDialog {
if (visible && question) {
forceActiveFocus()
} else if (visible) {
user.text = mounter.user
user.text = drive ? "" : mounter.user
password.forceActiveFocus()
}
}
Expand All @@ -52,15 +55,16 @@ FolioDialog {

PlainField {
id: user
visible: !prompt.question
// A drive's passphrase has no user to go with it.
visible: !prompt.question && !prompt.drive
Layout.fillWidth: true
placeholderText: qsTr("User")
}
PlainField {
id: password
visible: !prompt.question
Layout.fillWidth: true
placeholderText: qsTr("Password")
placeholderText: prompt.drive ? qsTr("Passphrase") : qsTr("Password")
echoMode: TextInput.Password
onAccepted: prompt.submit()
}
Expand All @@ -87,7 +91,7 @@ FolioDialog {
}
PlainButton {
visible: !prompt.question
text: qsTr("Connect")
text: prompt.drive ? qsTr("Unlock") : qsTr("Connect")
primary: true
onClicked: prompt.submit()
}
Expand Down
19 changes: 13 additions & 6 deletions src/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ Rectangle {
if (row.root !== undefined)
sidebar.target.open(row.path)
else
sidebar.go(row.path)
openDevice(row)
finished()
}
// A drive that isn't mounted yet has no path: opening it mounts it.
function openDevice(row) {
if (row.path)
sidebar.go(row.path)
else if (row.volume !== undefined)
sidebar.target.openVolume(row.volume, row.name)
}
function reveal(item) {
const y = item.mapToItem(column, 0, 0).y
if (y < flick.contentY)
Expand Down Expand Up @@ -142,7 +149,7 @@ Rectangle {

DriveMenu {
id: driveMenu
onOpenRequested: (path) => { sidebar.go(path); sidebar.finished() }
onOpenRequested: (drive) => { sidebar.openDevice(drive); sidebar.finished() }
onFormatRequested: (disk) => sidebar.formatRequested(disk)
}

Expand Down Expand Up @@ -430,11 +437,11 @@ Rectangle {
onKeyedChanged: if (keyed) sidebar.reveal(this)
text: modelData.name
glyph: eject.visible ? "" : modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.go(modelData.path)
active: !!modelData.path && sidebar.activePath === modelData.path
onClicked: sidebar.openDevice(modelData)
detail: {
translator.language // Re-read when the language (and so its digits) changes.
return modelData.free < 0 ? "" : Format.free(modelData.free)
return modelData.free === undefined || modelData.free < 0 ? "" : Format.free(modelData.free)
}
TapHandler {
acceptedButtons: Qt.RightButton
Expand All @@ -448,7 +455,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
implicitWidth: 28
implicitHeight: 28
visible: driveRow.modelData.release !== "" && (driveRow.hovered || hovered || driveRow.keyed)
visible: !!driveRow.modelData.release && (driveRow.hovered || hovered || driveRow.keyed)
glyph: "eject"
text: driveRow.modelData.release === "eject" ? qsTr("Eject") : qsTr("Unmount")
onClicked: places.eject(driveRow.modelData.path)
Expand Down
42 changes: 41 additions & 1 deletion src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ Backend::Backend(const QString &home, QObject *parent)
});
connect(&m_mounter, &Mounter::mounted, this, [this](const QString &folder) {
setBusy({});
// A drive opens at its top, or (plugged in) only says it's there.
if (std::exchange(m_mountDrive, false)) {
if (m_mountOpens)
navigate(folder);
else
showNotice(tr("%1 is mounted").arg(m_mountName));
return;
}
// The mount's folder is known now, so the plugin's row can light up.
if (m_plugins)
m_plugins->mountsChanged();
Expand All @@ -37,7 +45,9 @@ Backend::Backend(const QString &home, QObject *parent)
setBusy({});
// An empty error is the user cancelling the sign-in: nothing to report.
if (!error.isEmpty())
setMessage(tr("Couldn't connect to %1: %2").arg(m_mountName, error));
setMessage(m_mountDrive ? tr("Couldn't open %1: %2").arg(m_mountName, error)
: tr("Couldn't connect to %1: %2").arg(m_mountName, error));
m_mountDrive = false;
});
// The preview reports each file it steps to, and the grid follows.
connect(&m_preview, &QProcess::readyReadStandardOutput, this, [this] {
Expand Down Expand Up @@ -365,6 +375,9 @@ void Backend::openItem(const QString &path) {
}

void Backend::mount(const QString &url, const QString &name, bool verified) {
if (m_mounter.busy())
return;
m_mountDrive = false;
m_mountBare = QUrl(url).path().isEmpty() || QUrl(url).path() == "/";
m_mountName = name;
// Mounted already (by Folio or another app): straight there.
Expand Down Expand Up @@ -430,6 +443,33 @@ void Backend::finish(int run, const Plugins::Result &result) {
navigate(Plugins::expand(result.path));
}

void Backend::openVolume(const QString &volume, const QString &name) {
if (m_mounter.busy()) {
// Clicked while it's mounting as it was plugged in: that mount
// goes on, and opens the drive once it's done.
if (m_mountDrive && !m_mountOpens && m_mounter.volume() == volume) {
m_mountOpens = true;
setBusy(tr("Opening %1…").arg(m_mountName));
}
return;
}
m_mountName = name.isEmpty() ? tr("the drive") : name;
m_mountDrive = true;
m_mountOpens = true;
setBusy(tr("Opening %1…").arg(m_mountName));
m_mounter.mountVolume(volume);
}

bool Backend::mountVolume(const QString &volume, const QString &name) {
if (m_mounter.busy())
return false;
m_mountName = name.isEmpty() ? tr("the drive") : name;
m_mountDrive = true;
m_mountOpens = false;
m_mounter.mountVolume(volume);
return true;
}

void Backend::showNotice(const QString &notice) {
m_notice = notice;
emit noticeChanged();
Expand Down
10 changes: 10 additions & 0 deletions src/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ class Backend : public QObject {
// it's done.
Q_INVOKABLE void perform(const QString &plugin, const QString &action, const QStringList &paths,
const QString &target = {});
// Opens a drive from the sidebar's Devices, mounting it first when it
// isn't, which may ask for its passphrase or (through polkit) for
// permission.
Q_INVOKABLE void openVolume(const QString &volume, const QString &name);
// Mounts a drive just plugged in, staying where it is. False when this
// window is mounting something else already.
bool mountVolume(const QString &volume, const QString &name);
Q_INVOKABLE void dismissMessage();
Q_INVOKABLE void showMessage(const QString &message) { setMessage(message); }
// Good news that needs no answer ("Link copied"): shown for a few
Expand Down Expand Up @@ -202,6 +209,9 @@ class Backend : public QObject {
// The plugin actions running, each with its busy text, oldest first.
QList<std::pair<int, QString>> m_runs;
int m_lastRun = 0;
// What's being mounted is a drive, and whether to go there once it is.
bool m_mountDrive = false;
bool m_mountOpens = false;
QProcess m_preview;
// Set while Folio closes the preview itself, which isn't a crash.
bool m_closingPreview = false;
Expand Down
Loading