Skip to content
Closed
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/Glyph.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Item {
// for this name is built. Any other name, "file" among them, is a page.
readonly property string path: {
switch (name) {
case "home": return "M3 11l9-7 9 7M5 9.5V20h5v-6h4v6h5V9.5"
case "desktop": return box(3, 4, 18, 12, r) + "M8 20h8M12 16v4"
case "documents": return page() + "M9 12h6M9 16h6"
case "downloads": return "M12 4v11M7 10l5 5 5-5M4 20h16"
case "pictures": return box(3, 5, 18, 14, r) + "M3 16l5-5 4 4 3-3 6 6" + circle(16, 9, 1.5)
Expand Down
165 changes: 124 additions & 41 deletions src/Sidebar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import QtQuick.Controls
import QtQuick.Layouts
import "Format.js" as Format

// Home's folders, pinned folders, views, drives and plugins' sections. The one holding the current folder stays lit while you
// Places (Home, its standard folders, Recents and Trash), pinned folders,
// drives and plugins' sections, the way Nautilus lays them out. The one holding the current folder stays lit while you
// dig into it, so you always know which root you're under.
Rectangle {
id: sidebar
Expand Down Expand Up @@ -32,10 +33,10 @@ Rectangle {
// Each plugin section's rows, then the row for its view.
function sectionRows(section) { return section.view ? section.rows.concat([section.view]) : section.rows }
readonly property var pluginRows: plugins.sections.reduce((all, section) => all.concat(sectionRows(section)), [])
readonly property var rows: [].concat(places.places, places.pinned, places.views, places.devices, pluginRows)
readonly property int pinnedAt: places.places.length
readonly property int viewsAt: pinnedAt + places.pinned.length
readonly property int devicesAt: viewsAt + places.views.length
readonly property var rows: [].concat(places.places, places.views, places.pinned, places.devices, pluginRows)
readonly property int viewsAt: places.places.length
readonly property int pinnedAt: viewsAt + places.views.length
readonly property int devicesAt: pinnedAt + places.pinned.length
readonly property int pluginsAt: devicesAt + places.devices.length
// Where a plugin section's rows start in `rows`.
function sectionAt(index) {
Expand Down Expand Up @@ -89,32 +90,80 @@ Rectangle {
// A pinned folder is unpinned, a plugin's item taken off the sidebar.
Keys.onDeletePressed: {
const row = rows[cursor]
if (cursor >= pinnedAt && cursor < viewsAt)
if (cursor >= pinnedAt && cursor < devicesAt)
places.unpin(row.path)
else if (row && row.forgettable)
plugins.forget(row.plugin, row.id)
}
// 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, place or pin 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 < viewsAt ? placeRows.itemAt(cursor)
: cursor >= pinnedAt && cursor < devicesAt ? 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, keyedPlace)
else
return false
driveMenu.show(keyedDrive.modelData, keyedDrive)
return true
}

// Right-click on a folder in Places or Pinned.
FolioMenu {
id: placeMenu
property string path
property bool pinned: false
// Opens at the pointer, or (from the keyboard) beside the row.
function show(row, near) {
path = row.path
pinned = places.isPinned(row.path)
if (near)
popup(near, Math.min(near.width / 2, 120), near.height / 2)
else
popup()
}
FolioMenuItem {
text: qsTr("Open")
onTriggered: sidebar.target.navigate(placeMenu.path)
}
FolioMenuItem {
text: qsTr("Open Terminal Here")
onTriggered: fileOps.openTerminal(placeMenu.path)
}
FolioMenuItem {
text: qsTr("Copy Path")
onTriggered: fileOps.yank([placeMenu.path])
}
MenuLine { shown: placeMenu.pinned }
FolioMenuItem {
shown: placeMenu.pinned
text: qsTr("Unpin")
onTriggered: places.unpin(placeMenu.path)
}
}

// A pin being dragged to a new place among the pins: where it was, and
// the pin it's over.
property int pinFrom: -1
property int pinTo: -1

DriveMenu {
id: driveMenu
onOpenRequested: (path) => { sidebar.target.navigate(path); sidebar.finished() }
Expand All @@ -125,7 +174,7 @@ Rectangle {
readonly property string activePath: {
let best = ""
const here = sidebar.target.path
for (const list of [places.places, places.pinned, places.views, places.devices,
for (const list of [places.places, places.views, places.pinned, places.devices,
plugins.sections.filter(section => section.view).map(section => section.view)]) {
for (const p of list) {
if (p.path !== "/" && (here === p.path || here.startsWith(p.path + "/")) && p.path.length > best.length)
Expand Down Expand Up @@ -274,17 +323,9 @@ Rectangle {
width: sidebar.width - 24
spacing: 1

// The section's label is home itself: click it to go there.
SectionLabel {
Layout.topMargin: 0
text: qsTr("Home")
color: sidebar.target.path === places.home ? theme.accent
: homeHover.hovered ? theme.foreground : theme.secondaryForeground
Accessible.role: Accessible.Button
HoverHandler { id: homeHover; cursorShape: Qt.PointingHandCursor }
TapHandler { onTapped: sidebar.target.navigate(places.home) }
}
// Places: Home and its standard folders, then Recents and Trash.
Repeater {
id: placeRows
model: places.places
PlaceRow {
required property var modelData
Expand All @@ -293,10 +334,29 @@ Rectangle {
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
keyed: sidebar.activeFocus && sidebar.cursor === 0 + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
text: modelData.name
text: modelData.icon === "home" ? qsTr("Home") : modelData.name
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: placeMenu.show(parent.modelData, null)
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}
}
Repeater {
model: places.views
PlaceRow {
required property var modelData
required property int index
dropTrashes: modelData.icon === "trash"
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
text: modelData.icon === "trash" ? qsTr("Trash") : qsTr("Recents")
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
keyed: sidebar.activeFocus && sidebar.cursor === sidebar.viewsAt + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
}
}

Expand All @@ -305,6 +365,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 @@ -318,6 +379,46 @@ Rectangle {
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: placeMenu.show(pinRow.modelData, null)
}
// Dragged up or down, the pin moves among the pins.
readonly property int pinIndex: index
opacity: sidebar.pinFrom === index ? 0.5 : 1
DragHandler {
id: pinDrag
target: null
xAxis.enabled: false
onActiveChanged: {
if (active) {
sidebar.pinFrom = pinRow.index
sidebar.pinTo = pinRow.index
} else {
if (sidebar.pinFrom >= 0 && sidebar.pinTo >= 0 && sidebar.pinTo !== sidebar.pinFrom)
places.movePin(pinRow.modelData.path, sidebar.pinTo)
sidebar.pinFrom = -1
sidebar.pinTo = -1
}
}
onCentroidChanged: {
if (!active)
return
const at = pinRow.mapToItem(column, centroid.position.x, centroid.position.y)
const over = column.childAt(column.width / 2, at.y)
if (over && over.pinIndex !== undefined)
sidebar.pinTo = over.pinIndex
}
}
// Where the dragged pin will land: a line above or below.
Rectangle {
visible: sidebar.pinFrom >= 0 && sidebar.pinTo === pinRow.index && sidebar.pinFrom !== pinRow.index
anchors.left: parent.left
anchors.right: parent.right
y: sidebar.pinFrom > pinRow.index ? 0 : parent.height - height
height: 2
color: theme.accent
}
// The name ends short of the unpin button while it shows:
// hovered, or on the keyboard's row, where Delete does
// the same.
Expand Down Expand Up @@ -364,24 +465,6 @@ Rectangle {
}
}

// Views: lists that aren't a folder of their own.
SectionLabel { text: qsTr("Views") }
Repeater {
model: places.views
PlaceRow {
required property var modelData
required property int index
dropTrashes: modelData.icon === "trash"
onDropHoverChanged: sidebar.dropHovers += dropHover ? 1 : -1
text: modelData.icon === "trash" ? qsTr("Trash") : qsTr("Recents")
glyph: modelData.icon
active: sidebar.activePath === modelData.path
onClicked: sidebar.target.navigate(modelData.path)
keyed: sidebar.activeFocus && sidebar.cursor === sidebar.viewsAt + index
onKeyedChanged: if (keyed) sidebar.reveal(this)
}
}

// Each drive says how much is free under its name, where there's
// room for it, and while it's hovered or has the keyboard its icon
// becomes the button that ejects it. Right-clicked, it has a menu
Expand Down
1 change: 0 additions & 1 deletion src/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@
"Untitled Folder": "مجلد بلا عنوان",
"Untitled Folder %1": "مجلد بلا عنوان %1",
"User": "المستخدم",
"Views": "طرق العرض",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "يعمل في كل مكان تقريبًا، حتى مع الكاميرات القديمة وأجهزة ستيريو السيارات، لكن لا يمكن أن يتجاوز حجم أي ملف 4 غيغابايت.",
"Works with Mac, Windows and Linux, and holds big files.": "يعمل مع Mac وWindows وLinux، ويستوعب الملفات الكبيرة.",
"You don't have permission to open this folder.": "ليست لديك صلاحية فتح هذا المجلد.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Папка без име",
"Untitled Folder %1": "Папка без име %1",
"User": "Потребител",
"Views": "Изгледи",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Работи почти навсякъде, включително със стари фотоапарати и автомобилни уредби, но нито един файл не може да е по-голям от 4 ГБ.",
"Works with Mac, Windows and Linux, and holds big files.": "Работи с Mac, Windows и Linux и побира големи файлове.",
"You don't have permission to open this folder.": "Нямаш разрешение да отвориш тази папка.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "শিরোনামহীন ফোল্ডার",
"Untitled Folder %1": "শিরোনামহীন ফোল্ডার %1",
"User": "ব্যবহারকারী",
"Views": "ভিউ",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "প্রায় সব জায়গায় চলে, পুরনো ক্যামেরা ও গাড়ির স্টেরিওতেও, কিন্তু কোনো ফাইল 4 GB-এর বেশি হতে পারবে না।",
"Works with Mac, Windows and Linux, and holds big files.": "Mac, Windows ও Linux-এ চলে, আর বড় ফাইল রাখা যায়।",
"You don't have permission to open this folder.": "এই ফোল্ডারটি খোলার অনুমতি আপনার নেই।",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@
"Untitled Folder": "Carpeta sense títol",
"Untitled Folder %1": "Carpeta sense títol %1",
"User": "Usuari",
"Views": "Vistes",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Funciona gairebé a tot arreu, fins i tot en càmeres antigues i equips de música de cotxe, però cap fitxer pot superar els 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Funciona amb Mac, Windows i Linux, i admet fitxers grans.",
"You don't have permission to open this folder.": "No tens permís per obrir aquesta carpeta.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@
"Untitled Folder": "Složka bez názvu",
"Untitled Folder %1": "Složka bez názvu %1",
"User": "Uživatel",
"Views": "Zobrazení",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Funguje téměř všude, i ve starých fotoaparátech a autorádiích, ale žádný soubor nesmí přesáhnout 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Funguje na Macu, ve Windows i v Linuxu a pojme i velké soubory.",
"You don't have permission to open this folder.": "Nemáte oprávnění k otevření této složky.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Unavngiven mappe",
"Untitled Folder %1": "Unavngiven mappe %1",
"User": "Bruger",
"Views": "Visninger",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Virker næsten overalt, også med gamle kameraer og bilradioer, men ingen fil må være over 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Virker med Mac, Windows og Linux og kan rumme store filer.",
"You don't have permission to open this folder.": "Du har ikke tilladelse til at åbne denne mappe.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Unbenannter Ordner",
"Untitled Folder %1": "Unbenannter Ordner %1",
"User": "Benutzer",
"Views": "Ansichten",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Funktioniert fast überall, auch mit alten Kameras und Autoradios, aber keine Datei darf größer als 4 GB sein.",
"Works with Mac, Windows and Linux, and holds big files.": "Funktioniert mit Mac, Windows und Linux und kann große Dateien speichern.",
"You don't have permission to open this folder.": "Sie haben keine Berechtigung, diesen Ordner zu öffnen.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Φάκελος χωρίς τίτλο",
"Untitled Folder %1": "Φάκελος χωρίς τίτλο %1",
"User": "Χρήστης",
"Views": "Προβολές",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Λειτουργεί σχεδόν παντού, και σε παλιές φωτογραφικές μηχανές και ηχοσυστήματα αυτοκινήτου, αλλά κανένα αρχείο δεν μπορεί να ξεπερνά τα 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Λειτουργεί με Mac, Windows και Linux και χωρά μεγάλα αρχεία.",
"You don't have permission to open this folder.": "Δεν έχετε δικαίωμα να ανοίξετε αυτόν τον φάκελο.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@
"Untitled Folder": "Untitled Folder",
"Untitled Folder %1": "Untitled Folder %1",
"User": "User",
"Views": "Views",
"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.",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@
"Untitled Folder": "Carpeta sin título",
"Untitled Folder %1": "Carpeta sin título %1",
"User": "Usuario",
"Views": "Vistas",
"Works almost anywhere, old cameras and car stereos too, but no file can be over 4 GB.": "Funciona en casi cualquier lugar, incluso en cámaras viejas y autoestéreos, pero ningún archivo puede superar los 4 GB.",
"Works with Mac, Windows and Linux, and holds big files.": "Funciona con Mac, Windows y Linux, y admite archivos grandes.",
"You don't have permission to open this folder.": "No tienes permiso para abrir esta carpeta.",
Expand Down
Loading