filedialog: loader

This commit is contained in:
2 * r + 2 * t 2025-07-20 16:11:13 +10:00
parent 75964fe608
commit f6a5836a89
2 changed files with 70 additions and 42 deletions

View file

@ -37,7 +37,7 @@ StyledRect {
anchors.fill: parent
anchors.margins: Appearance.padding.normal
text: `${root.dialog.filterLabel} (${root.dialog.filters})`
text: `${root.dialog.filterLabel} (${root.dialog.filters.map(f => `*.${f}`).join(", ")})`
}
}

View file

@ -1,30 +1,57 @@
pragma ComponentBehavior: Bound
import qs.services
import qs.config
import Quickshell
import QtQuick
import QtQuick.Layouts
FloatingWindow {
id: root
LazyLoader {
id: loader
property list<string> cwd: ["Home"]
property string filterLabel: "All files"
property list<string> filters: ["*"]
property string title: qsTr("Select a file")
signal accepted(path: string)
signal rejected
function open(): void {
activeAsync = true;
}
function close(): void {
rejected();
}
onAccepted: activeAsync = false
onRejected: activeAsync = false
FloatingWindow {
id: root
property list<string> cwd: loader.cwd
property string filterLabel: loader.filterLabel
property list<string> filters: loader.filters
readonly property bool selectionValid: {
const item = folderContents.currentItem;
return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix));
}
signal accepted(path: string)
signal rejected
function accepted(path: string): void {
loader.accepted(path);
}
function rejected(): void {
loader.rejected();
}
implicitWidth: 1000
implicitHeight: 600
color: Colours.palette.m3surface
onAccepted: visible = false
onRejected: visible = false
title: loader.title
RowLayout {
anchors.fill: parent
@ -71,3 +98,4 @@ FloatingWindow {
}
}
}
}