From 022d509f99d4e1ea5b7911630cfaebe219a34806 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 21 Mar 2026 15:44:03 +1100 Subject: [PATCH] chore: fix components missing-property warnings --- components/StateLayer.qml | 3 +- components/filedialog/DialogButtons.qml | 2 +- components/filedialog/FolderContents.qml | 157 ++++++++++++----------- components/filedialog/Sidebar.qml | 3 +- components/images/CachingIconImage.qml | 3 +- 5 files changed, 87 insertions(+), 81 deletions(-) diff --git a/components/StateLayer.qml b/components/StateLayer.qml index a20e2661..7cd19b57 100644 --- a/components/StateLayer.qml +++ b/components/StateLayer.qml @@ -8,7 +8,8 @@ MouseArea { property bool disabled property bool showHoverBackground: true property color color: Colours.palette.m3onSurface - property real radius: parent?.radius ?? 0 + // Pick up radius from parent if it has one (parent can be anything with a radius property) + property real radius: parent?.radius ?? 0 // qmllint disable missing-property property alias rect: hoverLayer function onClicked(): void { diff --git a/components/filedialog/DialogButtons.qml b/components/filedialog/DialogButtons.qml index ff24efdb..5a30a12f 100644 --- a/components/filedialog/DialogButtons.qml +++ b/components/filedialog/DialogButtons.qml @@ -1,4 +1,4 @@ -import ".." +import qs.components import qs.services import qs.config import QtQuick.Layouts diff --git a/components/filedialog/FolderContents.qml b/components/filedialog/FolderContents.qml index 58fe3fe1..9789a3da 100644 --- a/components/filedialog/FolderContents.qml +++ b/components/filedialog/FolderContents.qml @@ -1,8 +1,9 @@ pragma ComponentBehavior: Bound -import ".." -import "../controls" -import "../images" +import qs.components +import qs.components.filedialog +import qs.components.controls +import qs.components.images import qs.services import qs.config import qs.utils @@ -16,7 +17,7 @@ Item { id: root required property var dialog - property alias currentItem: view.currentItem + readonly property FileEntry currentItem: view.currentItem as FileEntry StyledRect { anchors.fill: parent @@ -91,11 +92,11 @@ Item { Keys.onReturnPressed: { if (root.dialog.selectionValid) - root.dialog.accepted(currentItem.modelData.path); + root.dialog.accepted((currentItem as FileEntry).modelData.path); } Keys.onEnterPressed: { if (root.dialog.selectionValid) - root.dialog.accepted(currentItem.modelData.path); + root.dialog.accepted((currentItem as FileEntry).modelData.path); } StyledScrollBar.vertical: StyledScrollBar { @@ -112,77 +113,7 @@ Item { onPathChanged: view.currentIndex = -1 } - delegate: StyledRect { - id: item - - required property int index - required property FileSystemEntry modelData - - readonly property real nonAnimHeight: icon.implicitHeight + name.anchors.topMargin + name.implicitHeight + Appearance.padding.normal * 2 - - implicitWidth: Sizes.itemWidth - implicitHeight: nonAnimHeight - - radius: Appearance.rounding.normal - color: Qt.alpha(Colours.tPalette.m3surfaceContainerHighest, GridView.isCurrentItem ? Colours.tPalette.m3surfaceContainerHighest.a : 0) - z: GridView.isCurrentItem || implicitHeight !== nonAnimHeight ? 1 : 0 - clip: true - - StateLayer { - function onClicked(): void { - view.currentIndex = item.index; - } - - onDoubleClicked: { - if (item.modelData.isDir) - root.dialog.cwd.push(item.modelData.name); - else if (root.dialog.selectionValid) - root.dialog.accepted(item.modelData.path); - } - } - - CachingIconImage { - id: icon - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: Appearance.padding.normal - - implicitSize: Sizes.itemWidth - Appearance.padding.normal * 2 - - Component.onCompleted: { - const file = item.modelData; - if (file.isImage) - source = Qt.resolvedUrl(file.path); - else if (!file.isDir) - source = Quickshell.iconPath(file.mimeType.replace("/", "-"), "application-x-zerosize"); - else if (root.dialog.cwd.length === 1 && ["Desktop", "Documents", "Downloads", "Music", "Pictures", "Public", "Templates", "Videos"].includes(file.name)) - source = Quickshell.iconPath(`folder-${file.name.toLowerCase()}`); - else - source = Quickshell.iconPath("inode-directory"); - } - } - - StyledText { - id: name - - anchors.left: parent.left - anchors.right: parent.right - anchors.top: icon.bottom - anchors.topMargin: Appearance.spacing.small - anchors.margins: Appearance.padding.normal - - horizontalAlignment: Text.AlignHCenter - elide: item.GridView.isCurrentItem ? Text.ElideNone : Text.ElideRight - wrapMode: item.GridView.isCurrentItem ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap - - Component.onCompleted: text = item.modelData.name - } - - Behavior on implicitHeight { - Anim {} - } - } + delegate: FileEntry {} add: Transition { Anim { @@ -226,4 +157,76 @@ Item { currentItem: view.currentItem } + + component FileEntry: StyledRect { + id: item + + required property int index + required property FileSystemEntry modelData + + readonly property real nonAnimHeight: icon.implicitHeight + name.anchors.topMargin + name.implicitHeight + Appearance.padding.normal * 2 + + implicitWidth: Sizes.itemWidth + implicitHeight: nonAnimHeight + + radius: Appearance.rounding.normal + color: Qt.alpha(Colours.tPalette.m3surfaceContainerHighest, GridView.isCurrentItem ? Colours.tPalette.m3surfaceContainerHighest.a : 0) + z: GridView.isCurrentItem || implicitHeight !== nonAnimHeight ? 1 : 0 + clip: true + + StateLayer { + function onClicked(): void { + view.currentIndex = item.index; + } + + onDoubleClicked: { + if (item.modelData.isDir) + root.dialog.cwd.push(item.modelData.name); + else if (root.dialog.selectionValid) + root.dialog.accepted(item.modelData.path); + } + } + + CachingIconImage { + id: icon + + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: Appearance.padding.normal + + implicitSize: Sizes.itemWidth - Appearance.padding.normal * 2 + + Component.onCompleted: { + const file = item.modelData; + if (file.isImage) + source = Qt.resolvedUrl(file.path); + else if (!file.isDir) + source = Quickshell.iconPath(file.mimeType.replace("/", "-"), "application-x-zerosize"); + else if (root.dialog.cwd.length === 1 && ["Desktop", "Documents", "Downloads", "Music", "Pictures", "Public", "Templates", "Videos"].includes(file.name)) + source = Quickshell.iconPath(`folder-${file.name.toLowerCase()}`); + else + source = Quickshell.iconPath("inode-directory"); + } + } + + StyledText { + id: name + + anchors.left: parent.left + anchors.right: parent.right + anchors.top: icon.bottom + anchors.topMargin: Appearance.spacing.small + anchors.margins: Appearance.padding.normal + + horizontalAlignment: Text.AlignHCenter + elide: item.GridView.isCurrentItem ? Text.ElideNone : Text.ElideRight + wrapMode: item.GridView.isCurrentItem ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap + + Component.onCompleted: text = item.modelData.name + } + + Behavior on implicitHeight { + Anim {} + } + } } diff --git a/components/filedialog/Sidebar.qml b/components/filedialog/Sidebar.qml index 4e83318b..a6389864 100644 --- a/components/filedialog/Sidebar.qml +++ b/components/filedialog/Sidebar.qml @@ -1,6 +1,7 @@ pragma ComponentBehavior: Bound -import ".." +import qs.components +import qs.components.filedialog import qs.services import qs.config import QtQuick diff --git a/components/images/CachingIconImage.qml b/components/images/CachingIconImage.qml index 52c0d14f..d22b5131 100644 --- a/components/images/CachingIconImage.qml +++ b/components/images/CachingIconImage.qml @@ -7,7 +7,8 @@ import QtQuick Item { id: root - readonly property int status: loader.item?.status ?? Image.Null + // Easier (and more efficient) to ignore it than to check type and cast + readonly property int status: loader.item?.status ?? Image.Null // qmllint disable missing-property readonly property real actualSize: Math.min(width, height) property real implicitSize property url source