Archived
1

Added option to use lower resolution artworks in TagTunes

This commit is contained in:
Kim Wittenburg
2015-09-15 14:17:40 +02:00
committed by Kim Wittenburg
parent d49ad31b79
commit dcd7d2620d
4 changed files with 35 additions and 4 deletions

View File

@@ -120,7 +120,7 @@ public class AlbumTableCellView: AdvancedTableCellView {
public func setupForAlbum(album: Album, loading: Bool, error: NSError?) {
textField?.stringValue = Preferences.sharedPreferences.useCensoredNames ? album.censoredName : album.name
secondaryTextField?.stringValue = album.artistName
asyncImageView.downloadImageFromURL(album.artwork.hiResURL)
asyncImageView.downloadImageFromURL(album.artwork.displayImageURL)
if loading {
textField?.textColor = NSColor.disabledControlTextColor()
rightAccessoryView = loadingIndicator
@@ -163,7 +163,7 @@ public class AlbumTableCellView: AdvancedTableCellView {
textField?.stringValue = Preferences.sharedPreferences.useCensoredNames ? searchResult.censoredName : searchResult.name
textField?.textColor = NSColor.controlTextColor()
secondaryTextField?.stringValue = searchResult.artistName
asyncImageView.downloadImageFromURL(searchResult.artwork.hiResURL)
asyncImageView.downloadImageFromURL(searchResult.artwork.displayImageURL)
if selectable {
button.title = NSLocalizedString("Select", comment: "Button title for 'selecting a search result'")
button.enabled = true

View File

@@ -56,7 +56,7 @@ public class Artwork: iTunesType {
let filePath = directory.stringByAppendingString("/\(filename).tiff")
try NSFileManager.defaultManager().createDirectoryAtPath(directory, withIntermediateDirectories: true, attributes: nil)
let _ = NSFileManager.defaultManager().createFileAtPath(filePath, contents: hiResImage?.TIFFRepresentation, attributes: nil)
let _ = NSFileManager.defaultManager().createFileAtPath(filePath, contents: saveImage?.TIFFRepresentation, attributes: nil)
}
// MARK: Calculated Properties
@@ -103,4 +103,18 @@ public class Artwork: iTunesType {
return cachedHiResImage
}
/// Returns the url of an image that should be used to display this artwork
/// with respect to the user's preferences.
public var displayImageURL: NSURL {
if !Preferences.sharedPreferences.useLowResolutionArtwork && hiResURL != nil {
return hiResURL
}
return url100
}
/// Returns the image that should be used to save this artwork.
public var saveImage: NSImage? {
return hiResImage != nil ? hiResImage : image100
}
}

View File

@@ -831,6 +831,9 @@ CA
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="aSx-iH-PLA" name="value" keyPath="sharedPreferences.useLowResolutionArtwork" id="pFX-Hd-IVH"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ODz-LZ-Acs">
<rect key="frame" x="30" y="20" width="402" height="28"/>
@@ -932,7 +935,7 @@ CA
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="21" rowSizeStyle="automatic" viewBased="YES" id="WCb-HH-YPh">
<rect key="frame" x="0.0" y="0.0" width="408" height="172"/>
<rect key="frame" x="0.0" y="0.0" width="408" height="0.0"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
<size key="intercellSpacing" width="3" height="2"/>

View File

@@ -36,6 +36,8 @@ import Cocoa
static let removeSavedAlbumsKey = "Remove Saved Albums"
static let useLowResolutionArtworkKey = "Use Low Resolution Artwork"
static let useCensoredNamesKey = "Use Censored Names"
static let caseSensitiveKey = "Case Sensitive"
@@ -72,6 +74,7 @@ import Cocoa
UserDefaultsConstants.saveArtworkKey: false,
UserDefaultsConstants.keepSearchResultsKey: false,
UserDefaultsConstants.removeSavedAlbumsKey: false,
UserDefaultsConstants.useLowResolutionArtworkKey: false,
UserDefaultsConstants.useCensoredNamesKey: false,
UserDefaultsConstants.caseSensitiveKey: true,
UserDefaultsConstants.clearArtworksKey: false
@@ -121,6 +124,17 @@ import Cocoa
}
}
/// If `true` the main table view will use 100x100 artworks instead of full
/// sized images. This option does not affect saving.
public dynamic var useLowResolutionArtwork: Bool {
set {
NSUserDefaults.standardUserDefaults().setBool(newValue, forKey: UserDefaultsConstants.useLowResolutionArtworkKey)
}
get {
return NSUserDefaults.standardUserDefaults().boolForKey(UserDefaultsConstants.useLowResolutionArtworkKey)
}
}
// MARK: Tag Preferences
/// If `true` TagTunes displays and saves censored names instead of the