From dfe3aed46e357ab99164ea067d5e908fe2f69a71 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sun, 21 Sep 2025 19:39:52 +0200 Subject: [PATCH] NFilePicker: fix some layout/color issues --- Widgets/NFileManager.qml | 65 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/Widgets/NFileManager.qml b/Widgets/NFileManager.qml index cd5805b8..811314e5 100644 --- a/Widgets/NFileManager.qml +++ b/Widgets/NFileManager.qml @@ -151,6 +151,11 @@ Popup { var fileIsDir = folderModel.get(i, "fileIsDir") var fileSize = folderModel.get(i, "fileSize") + // In folder selection mode, only show directories + if (root.selectFolders && !root.selectFiles && !fileIsDir) { + continue + } + // If no search text or file name contains search text if (searchText === "" || fileName.toLowerCase().includes(searchText)) { filteredModel.append({ @@ -537,8 +542,8 @@ Popup { contentItem: Rectangle { implicitWidth: 6 * scaling implicitHeight: 100 - radius: 3 * scaling - color: parent.pressed ? Color.mTertiary : parent.hovered ? Color.mSecondary : Color.mTertiary + radius: Style.radiusM * scaling + color: parent.pressed ? Qt.alpha(Color.mTertiary, 0.8) : parent.hovered ? Qt.alpha(Color.mTertiary, 0.8) : Qt.alpha(Color.mTertiary, 0.8) opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 1.0 : 0.0 Behavior on opacity { @@ -546,6 +551,26 @@ Popup { duration: Style.animationFast } } + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } + } + + background: Rectangle { + implicitWidth: 6 * scaling + implicitHeight: 100 + color: Color.transparent + opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 0.3 : 0.0 + radius: (Style.radiusM * scaling) / 2 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationFast + } + } } } @@ -753,8 +778,8 @@ Popup { contentItem: Rectangle { implicitWidth: 6 * scaling implicitHeight: 100 - radius: 3 * scaling - color: parent.pressed ? Color.mTertiary : parent.hovered ? Color.mSecondary : Color.mTertiary + radius: Style.radiusM * scaling + color: parent.pressed ? Qt.alpha(Color.mTertiary, 0.8) : parent.hovered ? Qt.alpha(Color.mTertiary, 0.8) : Qt.alpha(Color.mTertiary, 0.8) opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 1.0 : 0.0 Behavior on opacity { @@ -762,6 +787,26 @@ Popup { duration: Style.animationFast } } + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } + } + + background: Rectangle { + implicitWidth: 6 * scaling + implicitHeight: 100 + color: Color.transparent + opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 0.3 : 0.0 + radius: (Style.radiusM * scaling) / 2 + + Behavior on opacity { + NumberAnimation { + duration: Style.animationFast + } + } } } @@ -799,7 +844,7 @@ Popup { NIcon { icon: isDirectory ? "folder" : root.getFileIcon(fileName) font.pointSize: Style.fontSizeL * scaling - color: isDirectory ? Color.mPrimary : Color.mOnSurfaceVariant + color: isDirectory ? (fileManagerPanel.currentSelection.includes(filePath) ? Color.mOnSecondary : Color.mPrimary) : Color.mOnSurfaceVariant } NText { @@ -898,7 +943,15 @@ Popup { } NButton { - text: "Select" + text: { + if (root.selectFolders && !root.selectFiles) { + return "Select Folder" + } else if (root.selectFiles && !root.selectFolders) { + return "Select File" + } else { + return "Select" + } + } icon: "check" enabled: fileManagerPanel.currentSelection.length > 0 onClicked: root.confirmSelection()