filedialog: loader
This commit is contained in:
parent
75964fe608
commit
f6a5836a89
2 changed files with 70 additions and 42 deletions
|
|
@ -37,7 +37,7 @@ StyledRect {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Appearance.padding.normal
|
anchors.margins: Appearance.padding.normal
|
||||||
|
|
||||||
text: `${root.dialog.filterLabel} (${root.dialog.filters})`
|
text: `${root.dialog.filterLabel} (${root.dialog.filters.map(f => `*.${f}`).join(", ")})`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,73 +1,101 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
|
||||||
FloatingWindow {
|
LazyLoader {
|
||||||
id: root
|
id: loader
|
||||||
|
|
||||||
property list<string> cwd: ["Home"]
|
property list<string> cwd: ["Home"]
|
||||||
property string filterLabel: "All files"
|
property string filterLabel: "All files"
|
||||||
property list<string> filters: ["*"]
|
property list<string> filters: ["*"]
|
||||||
|
property string title: qsTr("Select a file")
|
||||||
readonly property bool selectionValid: {
|
|
||||||
const item = folderContents.currentItem;
|
|
||||||
return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix));
|
|
||||||
}
|
|
||||||
|
|
||||||
signal accepted(path: string)
|
signal accepted(path: string)
|
||||||
signal rejected
|
signal rejected
|
||||||
|
|
||||||
implicitWidth: 1000
|
function open(): void {
|
||||||
implicitHeight: 600
|
activeAsync = true;
|
||||||
color: Colours.palette.m3surface
|
}
|
||||||
|
|
||||||
onAccepted: visible = false
|
function close(): void {
|
||||||
onRejected: visible = false
|
rejected();
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
onAccepted: activeAsync = false
|
||||||
anchors.fill: parent
|
onRejected: activeAsync = false
|
||||||
|
|
||||||
spacing: 0
|
FloatingWindow {
|
||||||
|
id: root
|
||||||
|
|
||||||
Sidebar {
|
property list<string> cwd: loader.cwd
|
||||||
Layout.fillHeight: true
|
property string filterLabel: loader.filterLabel
|
||||||
dialog: root
|
property list<string> filters: loader.filters
|
||||||
|
|
||||||
|
readonly property bool selectionValid: {
|
||||||
|
const item = folderContents.currentItem;
|
||||||
|
return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
function accepted(path: string): void {
|
||||||
Layout.fillWidth: true
|
loader.accepted(path);
|
||||||
Layout.fillHeight: true
|
}
|
||||||
|
|
||||||
|
function rejected(): void {
|
||||||
|
loader.rejected();
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitWidth: 1000
|
||||||
|
implicitHeight: 600
|
||||||
|
color: Colours.palette.m3surface
|
||||||
|
title: loader.title
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
HeaderBar {
|
Sidebar {
|
||||||
Layout.fillWidth: true
|
|
||||||
dialog: root
|
|
||||||
}
|
|
||||||
|
|
||||||
FolderContents {
|
|
||||||
id: folderContents
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
dialog: root
|
dialog: root
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogButtons {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
dialog: root
|
Layout.fillHeight: true
|
||||||
folder: folderContents
|
|
||||||
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue