diff --git a/Base.lproj/FileImportController.xib b/Base.lproj/FileImportController.xib index 9efd208..5fbca7d 100755 --- a/Base.lproj/FileImportController.xib +++ b/Base.lproj/FileImportController.xib @@ -187,10 +187,10 @@ - + - + @@ -220,10 +220,10 @@ - + - + diff --git a/Classes/AttributedStyles.swift b/Classes/AttributedStyles.swift index ad66a2f..baa275f 100644 --- a/Classes/AttributedStyles.swift +++ b/Classes/AttributedStyles.swift @@ -9,56 +9,39 @@ import Cocoa // MARK: - Attributed styles -private let detailBoldMonospacedAttr = { () -> [NSAttributedStringKey : Any] in +private func monospaceAttributes(size: CGFloat, aligment: NSTextAlignment, headIndent: CGFloat = -10.0, firstLineHeadIndent: CGFloat = 0, bold: Bool) -> [NSAttributedStringKey : Any] { let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - ps.headIndent = -10.0 - ps.alignment = NSTextAlignment.right - + ps.firstLineHeadIndent = firstLineHeadIndent + ps.headIndent = headIndent + ps.alignment = aligment + if #available(macOS 10.11, *) { - return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize, - weight: NSFont.Weight.bold), + return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: size, + weight: bold ? NSFont.Weight.bold : NSFont.Weight.regular), NSAttributedStringKey.paragraphStyle: ps, NSAttributedStringKey.foregroundColor: NSColor.gray] } else { - return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize), + return [NSAttributedStringKey.font: bold ? NSFont.boldSystemFont(ofSize: size) : NSFont.systemFont(ofSize: size), NSAttributedStringKey.paragraphStyle: ps, NSAttributedStringKey.foregroundColor: NSColor.gray] } +} + +private let detailBoldMonospacedAttr = { () -> [NSAttributedStringKey : Any] in + return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: true) }() private let detailBoldAttr = { () -> [NSAttributedStringKey : Any] in - let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - ps.headIndent = -10.0 - ps.alignment = NSTextAlignment.left - - if #available(macOS 10.11, *) { - return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize, - weight: NSFont.Weight.bold), - NSAttributedStringKey.paragraphStyle: ps, - NSAttributedStringKey.foregroundColor: NSColor.gray] - } - else { - return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize), - NSAttributedStringKey.paragraphStyle: ps, - NSAttributedStringKey.foregroundColor: NSColor.gray] - } + return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.left, bold: true) }() private let detailMonospacedAttr = { () -> [NSAttributedStringKey : Any] in - let ps = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle - ps.headIndent = -10.0 - ps.alignment = NSTextAlignment.right + return monospaceAttributes(size: NSFont.smallSystemFontSize, aligment: NSTextAlignment.right, bold: false) +}() - if #available(macOS 10.11, *) { - return [NSAttributedStringKey.font: NSFont.monospacedDigitSystemFont(ofSize: NSFont.smallSystemFontSize, - weight: NSFont.Weight.regular), - NSAttributedStringKey.paragraphStyle: ps] - } - else { - return [NSAttributedStringKey.font: NSFont.boldSystemFont(ofSize: NSFont.smallSystemFontSize), - NSAttributedStringKey.paragraphStyle: ps] - } +private let groupRowAttr = { () -> [NSAttributedStringKey : Any] in + return monospaceAttributes(size: NSFont.systemFontSize, aligment: NSTextAlignment.left, firstLineHeadIndent: 24, bold: true) }() extension String { @@ -74,5 +57,9 @@ extension String { func monospacedAttributedString() -> NSAttributedString { return NSAttributedString(string: self, attributes: detailMonospacedAttr) } + + func groupAttributedString() -> NSAttributedString { + return NSAttributedString(string: self, attributes: groupRowAttr) + } } diff --git a/Classes/FileImportController.swift b/Classes/FileImportController.swift index 9fc0e79..9983840 100644 --- a/Classes/FileImportController.swift +++ b/Classes/FileImportController.swift @@ -403,7 +403,7 @@ class FileImportController: NSWindowController, NSTableViewDataSource, NSTableVi switch items[row] { case .file(let importer): let groupCell = tableView.makeView(withIdentifier: trackNameColumn, owner:self) as? NSTableCellView - groupCell?.textField?.stringValue = importer.fileURL.lastPathComponent + groupCell?.textField?.attributedStringValue = importer.fileURL.lastPathComponent.groupAttributedString() return groupCell case .track(let settings):