diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift index 64836328b..d2e38c3cc 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Extensions/Logger+Extensions.swift @@ -11,6 +11,7 @@ extension Logger { private static var subsystem = Bundle.main.bundleIdentifier! static let actionViewController = Logger(subsystem: subsystem, category: "actionViewController") + static let lockViewController = Logger(subsystem: subsystem, category: "lockViewController") static let metadataProvider = Logger(subsystem: subsystem, category: "metadataProvider") static let shareCapabilities = Logger(subsystem: subsystem, category: "shareCapabilities") static let shareController = Logger(subsystem: subsystem, category: "shareController") diff --git a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift index ae113bee7..369ac0256 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift +++ b/shell_integration/MacOSX/NextcloudIntegration/FileProviderUIExt/Locking/LockViewController.swift @@ -43,4 +43,31 @@ class LockViewController: NSViewController { Logger.lockViewController.error("Error: \(error, privacy: .public)") descriptionLabel.stringValue = "Error: \(error)" } + + private func updateFileDetailsDisplay(itemUrl: URL) async { + let lockAction = locking ? "Locking" : "Unlocking" + fileNameLabel.stringValue = "\(lockAction) file \(itemUrl.lastPathComponent)…" + + let request = QLThumbnailGenerator.Request( + fileAt: itemUrl, + size: CGSize(width: 48, height: 48), + scale: 1.0, + representationTypes: .icon + ) + let generator = QLThumbnailGenerator.shared + let fileThumbnail = await withCheckedContinuation { continuation in + generator.generateRepresentations(for: request) { thumbnail, type, error in + if thumbnail == nil || error != nil { + Logger.lockViewController.error( + "Could not get thumbnail: \(error, privacy: .public)" + ) + } + continuation.resume(returning: thumbnail) + } + } + + fileNameIcon.image = + fileThumbnail?.nsImage ?? + NSImage(systemSymbolName: "doc", accessibilityDescription: "doc") + } }