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,30 +1,57 @@
|
||||||
|
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")
|
||||||
|
|
||||||
|
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: {
|
readonly property bool selectionValid: {
|
||||||
const item = folderContents.currentItem;
|
const item = folderContents.currentItem;
|
||||||
return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix));
|
return item && !item.fileIsDir && (filters.includes("*") || filters.includes(item.fileSuffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
signal accepted(path: string)
|
function accepted(path: string): void {
|
||||||
signal rejected
|
loader.accepted(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rejected(): void {
|
||||||
|
loader.rejected();
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: 1000
|
implicitWidth: 1000
|
||||||
implicitHeight: 600
|
implicitHeight: 600
|
||||||
color: Colours.palette.m3surface
|
color: Colours.palette.m3surface
|
||||||
|
title: loader.title
|
||||||
onAccepted: visible = false
|
|
||||||
onRejected: visible = false
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
@ -70,4 +97,5 @@ FloatingWindow {
|
||||||
easing.bezierCurve: Appearance.anim.curves.standard
|
easing.bezierCurve: Appearance.anim.curves.standard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue