From 1295f22371319be0b0cc6019be6bff98220ff458 Mon Sep 17 00:00:00 2001 From: Kim Wittenburg Date: Sun, 17 Jun 2012 22:24:54 +0200 Subject: [PATCH] Added "Show in Browser" functionality --- Changelog.rtf | 8 +- iLyrics/AutoLyrics.m | 2 +- iLyrics/MainController.h | 1 + iLyrics/MainController.m | 32 ++++++-- iLyrics/de.lproj/MainMenu.xib | 142 ++++++++++++++++++++++++++++++---- iLyrics/en.lproj/MainMenu.xib | 99 ++++++++++++++++++++++-- iLyrics/iLyrics-Info.plist | 2 +- 7 files changed, 252 insertions(+), 34 deletions(-) diff --git a/Changelog.rtf b/Changelog.rtf index 33252b7..a81e191 100644 --- a/Changelog.rtf +++ b/Changelog.rtf @@ -26,4 +26,10 @@ \ \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural \cf0 -Added Auto-Lyrics\ --Improved the preferences window} \ No newline at end of file +-Improved the preferences window\ +\ +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\qc +\cf0 06/17/2012\ +\ +\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural +\cf0 -Added "Show in Browser" functionality} \ No newline at end of file diff --git a/iLyrics/AutoLyrics.m b/iLyrics/AutoLyrics.m index fa923cb..7563afc 100644 --- a/iLyrics/AutoLyrics.m +++ b/iLyrics/AutoLyrics.m @@ -29,7 +29,7 @@ AutoLyrics *instace; -(id)init { enabled = NO; replaceOldLyrics = NO; - [self setInterval:5]; + [self setInterval:30]; return [super init]; } diff --git a/iLyrics/MainController.h b/iLyrics/MainController.h index fd34377..0fbe378 100644 --- a/iLyrics/MainController.h +++ b/iLyrics/MainController.h @@ -39,6 +39,7 @@ - (IBAction)lyricsSelectionChanged:(NSOutlineView *)sender; - (IBAction)sendLyricsToiTunes:(id)sender; - (IBAction)downloadLyrics:(id)sender; +- (IBAction)showLyricsInBrowser:(id)sender; - (IBAction)showiLyricsWindow:(id)sender; - (void)saveToDefalts: (NSUserDefaults *)defaults; - (void)loadFromDefaults: (NSUserDefaults *)defaults; diff --git a/iLyrics/MainController.m b/iLyrics/MainController.m index ebe88b9..0342e68 100644 --- a/iLyrics/MainController.m +++ b/iLyrics/MainController.m @@ -9,7 +9,7 @@ #import "MainController.h" @implementation MainController { - NSMutableArray *data; + NSMutableArray *loadedResults; id currentHoster; BOOL lyricsSelected; NSInteger selectedSavePanelButton; @@ -35,7 +35,7 @@ -(id)init { iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; - data = [[NSMutableArray alloc] init]; + loadedResults = [[NSMutableArray alloc] init]; currentHoster = [[Magistrix alloc] init]; return [super init]; } @@ -43,11 +43,11 @@ #pragma mark - #pragma mark Outline view Data Source and Delegate -(NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { - return item == nil ? [data count] : 0; + return item == nil ? [loadedResults count] : 0; } -(id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item { - return [data objectAtIndex:index]; + return [loadedResults objectAtIndex:index]; } -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { @@ -108,14 +108,14 @@ NSRunAlertPanel(NSLocalizedString(@"Hoster.messages.noResults.title", @""), NSLocalizedString(@"Hoster.messages.noResults.detail", @""), NSLocalizedString(@"OK", @""), nil, nil); return; } - [data addObjectsFromArray:nextResults]; + [loadedResults addObjectsFromArray:nextResults]; [resultsOutline reloadData]; [loadMoreResultsButton setEnabled:[currentHoster hasMoreResults]]; } -(IBAction)resetLoadedResults:(id)sender { [currentHoster resetLoadedResults]; - [data removeAllObjects]; + [loadedResults removeAllObjects]; [resultsOutline reloadData]; [loadMoreResultsButton setEnabled:[currentHoster hasMoreResults]]; [self lyricsSelectionChanged:resultsOutline]; @@ -134,7 +134,7 @@ } else { if (selectedRow != index) { lyricsSelected = YES; - SearchResult *result = [data objectAtIndex:index]; + SearchResult *result = [loadedResults objectAtIndex:index]; Lyrics *lyrics = [currentHoster lyricsBySearchResult:result]; currentLyrics = lyrics; if (lyrics == nil) { @@ -204,6 +204,15 @@ [savePanel beginSheetModalForWindow:window completionHandler:handler]; } +- (IBAction)showLyricsInBrowser:(id)sender { + int row = [resultsOutline clickedRow]; + if (row < 0) { + row = [resultsOutline selectedRow]; + } + NSURL *link = [[loadedResults objectAtIndex:row] link]; + [[NSWorkspace sharedWorkspace] openURL:link]; +} + -(void) savePanelDidClose: (NSNotification *) notification{ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidEndSheetNotification object:window]; if (selectedSavePanelButton == NSOKButton) { @@ -254,6 +263,15 @@ if (action == @selector(showPreview:)) { return [resultsOutline clickedRow] >= 0; } + if (action == @selector(showLyricsInBrowser:)) { + if ([resultsOutline clickedRow] >= 0) { + return YES; + } else if ([resultsOutline selectedRow] >= 0) { + return YES; + } else { + return NO; + } + } return [self respondsToSelector:[item action]]; } diff --git a/iLyrics/de.lproj/MainMenu.xib b/iLyrics/de.lproj/MainMenu.xib index 5bb6561..b46ec5b 100644 --- a/iLyrics/de.lproj/MainMenu.xib +++ b/iLyrics/de.lproj/MainMenu.xib @@ -214,6 +214,24 @@ + + + YES + YES + + + 2147483647 + + + + + + Im Browser öffnen + + 2147483647 + + + Songtext sichern... @@ -900,11 +918,9 @@ Suchen - + 268 {{0, 14}, {96, 22}} - - _NS:9 YES @@ -1139,6 +1155,7 @@ 293 {{146, 1}, {72, 18}} + _NS:9 YES @@ -1173,6 +1190,7 @@ 289 {{224, -1}, {140, 23}} + _NS:22 YES @@ -1196,6 +1214,7 @@ 292 {{0, -1}, {139, 23}} + _NS:22 YES @@ -1227,6 +1246,7 @@ 4352 {362, 415} + _NS:13 YES @@ -1235,6 +1255,7 @@ 256 {362, 17} + _NS:16 @@ -1344,6 +1365,7 @@ {{1, 17}, {362, 415}} + _NS:11 @@ -1360,6 +1382,7 @@ -2147483392 {{224, 17}, {15, 102}} + _NS:58 @@ -1372,6 +1395,7 @@ -2147483392 {{1, 417}, {238, 15}} + _NS:60 1 @@ -1387,6 +1411,7 @@ {{1, 0}, {362, 17}} + _NS:15 @@ -1396,6 +1421,7 @@ {{0, 29}, {364, 433}} + _NS:9 133682 @@ -1408,6 +1434,7 @@ {364, 462} + _NS:11 NSView @@ -1429,6 +1456,7 @@ 2322 {457, 14} + _NS:13 @@ -1492,6 +1520,7 @@ {{1, 1}, {457, 367}} + _NS:11 @@ -1522,6 +1551,7 @@ 256 {{443, 1}, {15, 361}} + _NS:84 @@ -1534,6 +1564,7 @@ 256 {{1, 353}, {451, 15}} + _NS:33 1 @@ -1545,6 +1576,7 @@ {459, 369} + _NS:9 133170 @@ -1561,6 +1593,7 @@ 265 {{292, 9}, {153, 32}} + _NS:9 YES @@ -1584,6 +1617,7 @@ 265 {{292, 37}, {153, 32}} + _NS:9 YES @@ -1607,6 +1641,7 @@ 266 {{82, 20}, {211, 17}} + _NS:9 {250, 750} @@ -1631,6 +1666,7 @@ 268 {{17, 20}, {63, 17}} + _NS:1505 YES @@ -1650,6 +1686,7 @@ 266 {{82, 47}, {211, 17}} + _NS:9 {250, 750} @@ -1670,6 +1707,7 @@ 268 {{17, 47}, {36, 17}} + _NS:1505 YES @@ -1687,6 +1725,7 @@ {{0, 377}, {459, 85}} + _NS:9 NSView @@ -1694,6 +1733,7 @@ {{374, 0}, {487, 462}} + _NS:13 NSView @@ -1701,6 +1741,7 @@ {861, 462} + _NS:9 YES @@ -1709,6 +1750,7 @@ {861, 462} + {{0, 0}, {1680, 1028}} @@ -1730,7 +1772,7 @@ YES - + 268 @@ -1772,7 +1814,7 @@ 2322 {301, 14} - + _NS:13 @@ -1869,7 +1911,7 @@ {{0, 20}, {303, 172}} - + _NS:9 133138 @@ -1878,7 +1920,6 @@ {303, 192} - _NS:9 NSView @@ -2013,11 +2054,9 @@ - + 256 {480, 270} - - _NS:20 {{0, 0}, {1680, 1028}} @@ -2028,7 +2067,7 @@ PreferencesController - + 268 @@ -2063,7 +2102,7 @@ 256 {424, 146} - + _NS:13 YES @@ -2185,7 +2224,6 @@ -2147483392 {{1, 173}, {438, 15}} - _NS:60 1 @@ -2208,7 +2246,7 @@ {{20, 20}, {426, 164}} - + _NS:9 133682 @@ -2244,7 +2282,6 @@ {466, 251} - _NS:9 NSView @@ -2485,6 +2522,19 @@ _NS:9 NSView + + + + + + Im Browser öffnen + + 2147483647 + + + + + @@ -3128,6 +3178,22 @@ 1799 + + + showLyricsInBrowser: + + + + 2596 + + + + showLyricsInBrowser: + + + + 2600 + delegate @@ -3144,6 +3210,14 @@ 592 + + + menu + + + + 2597 + delegate @@ -3378,6 +3452,8 @@ + + @@ -4595,6 +4671,29 @@ + + 2592 + + + + + + + + 2593 + + + + + 2598 + + + + + 2599 + + + @@ -4727,7 +4826,7 @@ ToolTip - Not available yet. Auto-Lyrics check in 30 seconds intervals. + Noch nicht verfügbar. Auto-Lyrics überprüft Songtexte alle 30 Sekunden. com.apple.InterfaceBuilder.CocoaPlugin @@ -4737,6 +4836,10 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4818,7 +4921,7 @@ - 2591 + 2600 @@ -4898,6 +5001,7 @@ NSOutlineView id id + id id id @@ -4926,6 +5030,10 @@ sendLyricsToiTunes: id + + showLyricsInBrowser: + id + showiLyricsWindow: id diff --git a/iLyrics/en.lproj/MainMenu.xib b/iLyrics/en.lproj/MainMenu.xib index 57f73b5..7e2f12a 100644 --- a/iLyrics/en.lproj/MainMenu.xib +++ b/iLyrics/en.lproj/MainMenu.xib @@ -214,6 +214,24 @@ + + + YES + YES + + + 2147483647 + + + + + + Show in Browser + + 2147483647 + + + Save… @@ -1121,7 +1139,7 @@ - + 256 @@ -1225,7 +1243,7 @@ 4352 {299, 415} - + _NS:13 YES @@ -1394,7 +1412,7 @@ {{0, 29}, {301, 433}} - + _NS:9 133682 @@ -1705,6 +1723,7 @@ {861, 462} + {{0, 0}, {1680, 1028}} @@ -1713,6 +1732,19 @@ 128 YES + + + + + + Show in Browser + + 2147483647 + + + + + MainController @@ -2057,7 +2089,7 @@ 256 {424, 146} - + _NS:13 YES @@ -2201,7 +2233,7 @@ {{20, 20}, {426, 164}} - + _NS:9 133682 @@ -3111,6 +3143,22 @@ 1799 + + + showLyricsInBrowser: + + + + 2597 + + + + showLyricsInBrowser: + + + + 2600 + delegate @@ -3127,6 +3175,14 @@ 592 + + + menu + + + + 2596 + delegate @@ -3359,8 +3415,10 @@ - + + + @@ -4578,6 +4636,29 @@ + + 2592 + + + + + + + + 2593 + + + + + 2598 + + + + + 2599 + + + @@ -4720,6 +4801,10 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -4801,7 +4886,7 @@ - 2591 + 2600 0 diff --git a/iLyrics/iLyrics-Info.plist b/iLyrics/iLyrics-Info.plist index 8caee39..f8d2600 100644 --- a/iLyrics/iLyrics-Info.plist +++ b/iLyrics/iLyrics-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 5 + 1 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion