From 548214479a433bec6b9d40f4c7c99f4a12b36528 Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Tue, 15 Sep 2015 16:54:22 +0200 Subject: [PATCH] Added option for displayed number of search results --- Changelog.txt | 7 +- TagTunes/Base.lproj/Main.storyboard | 100 +++++++++++++++++++--------- TagTunes/Preferences.swift | 13 ++++ TagTunes/iTunes.swift | 2 +- 4 files changed, 89 insertions(+), 33 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e7212cc..93e58fe 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,4 +14,9 @@ Added: Fixed: * Added support for OS X 10.11 El Capitan * Error descriptions are now more understandable -* Cancelling the saving process of tracks does not crash the application on slow network connections anymore \ No newline at end of file +* Cancelling the saving process of tracks does not crash the application on slow network connections anymore + +Version 1.2 + +Added: ++ Option for displayed number of search results \ No newline at end of file diff --git a/TagTunes/Base.lproj/Main.storyboard b/TagTunes/Base.lproj/Main.storyboard index 6310295..9f74fad 100644 --- a/TagTunes/Base.lproj/Main.storyboard +++ b/TagTunes/Base.lproj/Main.storyboard @@ -760,11 +760,11 @@ CA - + - - + + @@ -805,7 +802,7 @@ CA - + @@ -856,26 +853,67 @@ CA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -883,7 +921,7 @@ CA - + @@ -895,7 +933,7 @@ CA - + diff --git a/TagTunes/Preferences.swift b/TagTunes/Preferences.swift index d648b79..a30a5d5 100644 --- a/TagTunes/Preferences.swift +++ b/TagTunes/Preferences.swift @@ -36,6 +36,8 @@ import Cocoa static let keepSearchResultsKey = "Keep Search Results" + static let numberOfSearchResultsKey = "Number of Search Results" + static let removeSavedAlbumsKey = "Remove Saved Albums" static let useLowResolutionArtworkKey = "Use Low Resolution Artwork" @@ -76,6 +78,7 @@ import Cocoa UserDefaultsConstants.saveArtworkKey: false, UserDefaultsConstants.overwriteExistingFilesKey: false, UserDefaultsConstants.keepSearchResultsKey: false, + UserDefaultsConstants.numberOfSearchResultsKey: 10, UserDefaultsConstants.removeSavedAlbumsKey: false, UserDefaultsConstants.useLowResolutionArtworkKey: false, UserDefaultsConstants.useCensoredNamesKey: false, @@ -137,6 +140,16 @@ import Cocoa } } + /// The number of search results that should be displayed. + public dynamic var numberOfSearchResults: Int { + set { + NSUserDefaults.standardUserDefaults().setInteger(newValue, forKey: UserDefaultsConstants.numberOfSearchResultsKey) + } + get { + return NSUserDefaults.standardUserDefaults().integerForKey(UserDefaultsConstants.numberOfSearchResultsKey) + } + } + /// 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 { diff --git a/TagTunes/iTunes.swift b/TagTunes/iTunes.swift index 45b802e..2218095 100644 --- a/TagTunes/iTunes.swift +++ b/TagTunes/iTunes.swift @@ -129,7 +129,7 @@ public struct iTunesAPI { if searchTerm.isEmpty { return nil } - return NSURL(string: "https://itunes.apple.com/search?term=\(searchTerm)&media=music&entity=album&limit=10&country=de&lang=de_DE") + return NSURL(string: "https://itunes.apple.com/search?term=\(searchTerm)&media=music&entity=album&limit=\(Preferences.sharedPreferences.numberOfSearchResults)&country=de&lang=de_DE") } /// Creates an URL that looks up all tracks that belong to the album with the