From f6a5836a897fbaa57e971313601e522a327cb570 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 20 Jul 2025 16:11:13 +1000 Subject: filedialog: loader --- widgets/filedialog/FileDialog.qml | 104 ++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 38 deletions(-) (limited to 'widgets/filedialog/FileDialog.qml') 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 cwd: ["Home"] property string filterLabel: "All files" property list 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 cwd: loader.cwd + property string filterLabel: loader.filterLabel + property list 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 + } } } } -- cgit v1.2.3-freya