diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-20 15:32:56 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-20 15:32:56 +1000 |
| commit | 73cf10ea968c7ee1fbc2eebc4691d6824989008a (patch) | |
| tree | 08543053837f3d279d9ced69ce3b2f254d7c52f2 /widgets/filedialog | |
| parent | filedialog: add empty text (diff) | |
| download | caelestia-shell-73cf10ea968c7ee1fbc2eebc4691d6824989008a.tar.gz caelestia-shell-73cf10ea968c7ee1fbc2eebc4691d6824989008a.tar.bz2 caelestia-shell-73cf10ea968c7ee1fbc2eebc4691d6824989008a.zip | |
filedialog: add current item
Diffstat (limited to 'widgets/filedialog')
| -rw-r--r-- | widgets/filedialog/CurrentItem.qml | 107 | ||||
| -rw-r--r-- | widgets/filedialog/FolderContents.qml | 8 |
2 files changed, 115 insertions, 0 deletions
diff --git a/widgets/filedialog/CurrentItem.qml b/widgets/filedialog/CurrentItem.qml new file mode 100644 index 0000000..65b78bd --- /dev/null +++ b/widgets/filedialog/CurrentItem.qml @@ -0,0 +1,107 @@ +import ".." +import qs.services +import qs.config +import QtQuick +import QtQuick.Shapes + +Item { + id: root + + required property var currentItem + + implicitWidth: content.implicitWidth + Appearance.padding.larger + content.anchors.rightMargin + implicitHeight: currentItem ? content.implicitHeight + Appearance.padding.normal + content.anchors.bottomMargin : 0 + + Shape { + preferredRendererType: Shape.CurveRenderer + + ShapePath { + id: path + + readonly property real rounding: Appearance.rounding.small + readonly property bool flatten: root.implicitHeight < rounding * 2 + readonly property real roundingY: flatten ? root.implicitHeight / 2 : rounding + + strokeWidth: -1 + fillColor: Colours.palette.m3surfaceContainer + + startX: root.implicitWidth + startY: root.implicitHeight + + PathLine { + relativeX: -(root.implicitWidth + path.rounding) + relativeY: 0 + } + PathArc { + relativeX: path.rounding + relativeY: -path.roundingY + radiusX: path.rounding + radiusY: Math.min(path.rounding, root.implicitHeight) + direction: PathArc.Counterclockwise + } + PathLine { + relativeX: 0 + relativeY: -(root.implicitHeight - path.roundingY * 2) + } + PathArc { + relativeX: path.rounding + relativeY: -path.roundingY + radiusX: path.rounding + radiusY: Math.min(path.rounding, root.implicitHeight) + } + PathLine { + relativeX: root.implicitHeight > 0 ? root.implicitWidth - path.rounding * 2 : root.implicitWidth + relativeY: 0 + } + PathArc { + relativeX: path.rounding + relativeY: -path.rounding + radiusX: path.rounding + radiusY: path.rounding + direction: PathArc.Counterclockwise + } + + Behavior on fillColor { + ColorAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + } + } + + Item { + anchors.fill: parent + clip: true + + StyledText { + id: content + + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: Appearance.padding.larger - Appearance.padding.small + anchors.bottomMargin: Appearance.padding.normal - Appearance.padding.small + + text: qsTr(`"%1" selected`).arg(root.currentItem.fileName) + } + } + + Behavior on implicitWidth { + enabled: !!root.currentItem + + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } + + Behavior on implicitHeight { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } + } +} diff --git a/widgets/filedialog/FolderContents.qml b/widgets/filedialog/FolderContents.qml index 82ed2bc..81f8729 100644 --- a/widgets/filedialog/FolderContents.qml +++ b/widgets/filedialog/FolderContents.qml @@ -203,6 +203,14 @@ Item { } } + CurrentItem { + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: Appearance.padding.small + + currentItem: view.currentItem + } + component Anim: NumberAnimation { duration: Appearance.anim.durations.normal easing.type: Easing.BezierSpline |