summaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-20 16:11:13 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-07-20 16:11:13 +1000
commitf6a5836a897fbaa57e971313601e522a327cb570 (patch)
treee956f412d3a1a1a5ad36d7a95a8445c18e8a8677 /widgets
parentfiledialog: add filters and buttons (diff)
downloadcaelestia-shell-f6a5836a897fbaa57e971313601e522a327cb570.tar.gz
caelestia-shell-f6a5836a897fbaa57e971313601e522a327cb570.tar.bz2
caelestia-shell-f6a5836a897fbaa57e971313601e522a327cb570.zip
filedialog: loader
Diffstat (limited to 'widgets')
-rw-r--r--widgets/filedialog/DialogButtons.qml2
-rw-r--r--widgets/filedialog/FileDialog.qml104
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
+ }
}
}
}