diff options
| -rw-r--r-- | widgets/filedialog/DialogButtons.qml | 2 | ||||
| -rw-r--r-- | widgets/filedialog/FileDialog.qml | 104 |
2 files changed, 67 insertions, 39 deletions
diff --git a/widgets/filedialog/DialogButtons.qml b/widgets/filedialog/DialogButtons.qml index 28284fe..a64195a 100644 --- a/widgets/filedialog/DialogButtons.qml +++ b/widgets/filedialog/DialogButtons.qml @@ -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(", ")})` } } diff --git a/widgets/filedialog/FileDialog.qml b/widgets/filedialog/FileDialog.qml index 33bae6a..43c7048 100644 --- a/widgets/filedialog/FileDialog.qml +++ b/widgets/filedialog/FileDialog.qml @@ -1,73 +1,101 @@ +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: ["*"] - - readonly property bool selectionValid: { - const item = folderContents.currentItem; - return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix)); - } + property string title: qsTr("Select a file") signal accepted(path: string) signal rejected - implicitWidth: 1000 - implicitHeight: 600 - color: Colours.palette.m3surface + function open(): void { + activeAsync = true; + } + + function close(): void { + rejected(); + } - onAccepted: visible = false - onRejected: visible = false + onAccepted: activeAsync = false + onRejected: activeAsync = false - RowLayout { - anchors.fill: parent + FloatingWindow { + id: root - spacing: 0 + property list<string> cwd: loader.cwd + property string filterLabel: loader.filterLabel + property list<string> filters: loader.filters - Sidebar { - Layout.fillHeight: true - dialog: root + readonly property bool selectionValid: { + const item = folderContents.currentItem; + return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix)); } - ColumnLayout { - Layout.fillWidth: true - Layout.fillHeight: true + function accepted(path: string): void { + loader.accepted(path); + } - spacing: 0 + function rejected(): void { + loader.rejected(); + } - HeaderBar { - Layout.fillWidth: true - dialog: root - } + implicitWidth: 1000 + implicitHeight: 600 + color: Colours.palette.m3surface + title: loader.title - FolderContents { - id: folderContents + RowLayout { + anchors.fill: parent - Layout.fillWidth: true + spacing: 0 + + Sidebar { Layout.fillHeight: true dialog: root } - DialogButtons { + ColumnLayout { Layout.fillWidth: true - dialog: root - folder: folderContents + Layout.fillHeight: true + + spacing: 0 + + HeaderBar { + Layout.fillWidth: true + dialog: root + } + + FolderContents { + id: folderContents + + Layout.fillWidth: true + Layout.fillHeight: true + dialog: root + } + + DialogButtons { + Layout.fillWidth: true + dialog: root + folder: folderContents + } } } - } - Behavior on color { - ColorAnimation { - duration: Appearance.anim.durations.normal - easing.type: Easing.BezierSpline - easing.bezierCurve: Appearance.anim.curves.standard + Behavior on color { + ColorAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } } } } |