feat: show favorite stars in application rows

This commit is contained in:
Valdemar Lorenzen
2026-10-14 11:58:26 +02:00
parent 9f6aa1db39
commit fd010ac864
3 changed files with 25 additions and 3 deletions
+21 -1
View File
@@ -533,6 +533,7 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
?? makeCell(identifier: identifier)
if let calculation {
cell.textField?.stringValue = calculation.displayValue
cell.textField?.setAccessibilityLabel(nil)
cell.locationLabel.isHidden = true
cell.kindLabel.stringValue = isCurrencyCalculation ? "Daily rates"
: calculation.copyValue == nil ? "Error" : "Calculator"
@@ -546,7 +547,10 @@ final class LauncherWindowController: NSWindowController, NSWindowDelegate, NSSe
let location = locationLabels[application.id]
cell.locationLabel.stringValue = location ?? ""
cell.locationLabel.isHidden = location == nil
cell.kindLabel.stringValue = "Application"
let isFavorite = history.isFavorite(application)
cell.kindLabel.attributedStringValue = isFavorite
? ApplicationCell.favoriteKind : ApplicationCell.applicationKind
cell.textField?.setAccessibilityLabel(isFavorite ? "\(application.name), Favorite" : nil)
cell.imageView?.contentTintColor = nil
cell.imageView?.image = NSWorkspace.shared.icon(forFile: application.url.path)
cell.toolTip = application.url.path
@@ -729,6 +733,22 @@ final class ApplicationCell: NSTableCellView {
private static let opaqueMask = [NSColor.black.cgColor, NSColor.black.cgColor]
private static let fadedMask = [NSColor.black.cgColor, NSColor.clear.cgColor]
private static let timing = CAMediaTimingFunction(name: .easeOut)
static let applicationKind = NSAttributedString(string: "Application", attributes: [
.font: NSFont.systemFont(ofSize: 14), .foregroundColor: SunsetPalette.secondaryText
])
static let favoriteKind: NSAttributedString = {
let attachment = NSTextAttachment()
attachment.image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: "Favorite")?
.withSymbolConfiguration(NSImage.SymbolConfiguration(pointSize: 12, weight: .regular)
.applying(.init(paletteColors: [SunsetPalette.secondaryText])))
let size = attachment.image?.size ?? .zero
attachment.bounds = NSRect(x: 0, y: (NSFont.systemFont(ofSize: 14).capHeight - size.height) / 2,
width: size.width, height: size.height)
let title = NSMutableAttributedString(attachment: attachment)
title.append(NSAttributedString(string: " "))
title.append(applicationKind)
return title
}()
let locationLabel = NSTextField(labelWithString: "")
let kindLabel = NSTextField(labelWithString: "Application")