Archived
1

-Added Songtexte.com Lyrics Hoster

-Repositioned the load more results button into the outline view
-Improved the replacing of html escape characters
-Lyrics Hosters can now be dragged into a preferred order in the preference window
-Changed results outline's column ordering method
-Some code changes
-Replaced the Buttons in the lyrics pane with an action button
-Preferred order of lyrics hosters will now be saved
-Translation Improvements
This commit is contained in:
Kim Wittenburg
2012-06-24 14:22:37 +02:00
parent 98b0e70a8b
commit 41b1ef775c
27 changed files with 3611 additions and 2826 deletions

View File

@@ -6,13 +6,14 @@
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
//TODO: Implement Auto-Lyricds Interval
//TODO: Set the title of the window when the toolbar button selection changed
//TODO:
#import "PreferencesController.h"
#import "iLyrics.h"
@implementation PreferencesController {
NSMutableArray *hosters;
AutoLyrics *autoLyrics;
iLyrics *ilyrics;
}
@synthesize generalView;
@synthesize autoLyricsView;
@@ -23,14 +24,15 @@
@synthesize hosterTable;
-(id)init {
ilyrics = [iLyrics sharediLyrics];
autoLyrics = [AutoLyrics autoLyrics];
hosters = [[NSMutableArray alloc] init];
return [super init];
}
#pragma mark -
#pragma mark Window Delegate Methods
#define HosterDataType @"HosterDataType"
-(void)awakeFromNib {
if ([autoLyrics enabled]) {
[self enableAutoLyrics:toggleAutoLyricsButton];
@@ -44,37 +46,19 @@
}
[[preferencesWindow toolbar] setSelectedItemIdentifier:@"general"];
[self showGeneralPreferences:nil];
[hosterTable registerForDraggedTypes:[NSArray arrayWithObject:HosterDataType]];
}
#pragma mark -
#pragma mark Properties
-(NSArray *)hosters {
return hosters;
}
-(void)setHosters:(NSArray *)hstrs {
hosters = [NSMutableArray arrayWithArray:hstrs];
[hosterTable reloadData];
}
#pragma mark Modifying hosters
-(void)addHoster:(id<LyricsHoster>)hoster {
[hosters addObject:hoster];
[hosterTable reloadData];
}
-(void)removeHoster:(id<LyricsHoster>)hoster {
[hosters removeObject:hoster];
[hosterTable reloadData];
}
- (IBAction)showGeneralPreferences:(id)sender {
[preferencesWindow setTitle:NSLocalizedString(@"iLyrics.preferences.text.general", @"")];
[self changeContentViewTo:generalView];
}
-(IBAction)showAutoLyricsPreferences:(id)sender {
[preferencesWindow setTitle:NSLocalizedString(@"iLyrics.preferences.text.auto-lyrics", @"")];
[self changeContentViewTo:autoLyricsView];
}
@@ -88,12 +72,12 @@
-(void)enableAutoLyrics: (id) sender{
[autoLyrics setEnabled:YES];
[sender setTitle:NSLocalizedString(@"iLyrics.text.disableAutoLyrics", @"")];
[sender setTitle:NSLocalizedString(@"iLyrics.preferences.text.disableAutoLyrics", @"")];
}
-(void)disableAutoLyrics: (id) sender {
[autoLyrics setEnabled:NO];
[sender setTitle:NSLocalizedString(@"iLyrics.text.enableAutoLyrics", @"")];
[sender setTitle:NSLocalizedString(@"iLyrics.preferences.text.enableAutoLyrics", @"")];
}
- (IBAction)changeAutoLyricsInterval:(id)sender {
@@ -112,18 +96,61 @@
#pragma mark -
#pragma mark Table Data Source
-(NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return [hosters count];
return [[ilyrics lyricsHosters] count];
}
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
id<LyricsHoster> hoster = [[ilyrics lyricsHosters] objectAtIndex:row];
if ([[tableColumn identifier] isEqualToString:@"hoster"]) {
return [[hosters objectAtIndex:row] name];
return [hoster name];
} else {
NSDate *version = [[hosters objectAtIndex:row] hosterVersion];
NSDate *version = [hoster hosterVersion];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
return [dateFormatter stringFromDate:version];
}
}
#pragma mark Drag and Drop Hosters
-(BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard {
// Copy the row numbers to the pasteboard.
NSData *indexData = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:HosterDataType] owner:self];
[pboard setData:indexData forType:HosterDataType];
return YES;
}
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row
proposedDropOperation:(NSTableViewDropOperation)op {
// Add code here to validate the drop
return NSDragOperationMove;
}
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation {
NSPasteboard* pboard = [info draggingPasteboard];
NSData* rowData = [pboard dataForType:HosterDataType];
NSIndexSet* rowIndexes =
[NSKeyedUnarchiver unarchiveObjectWithData:rowData];
NSInteger dragRow = [rowIndexes firstIndex];
if (dragRow < row) {
[[ilyrics lyricsHosters] insertObject:[[ilyrics lyricsHosters] objectAtIndex:dragRow] atIndex:row];
[[ilyrics lyricsHosters] removeObjectAtIndex:dragRow];
[hosterTable noteNumberOfRowsChanged];
[hosterTable reloadData];
return YES;
}
id<LyricsHoster> draggedHoster = [[ilyrics lyricsHosters] objectAtIndex:dragRow];
[[ilyrics lyricsHosters] removeObjectAtIndex:dragRow];
[[ilyrics lyricsHosters] insertObject:draggedHoster atIndex:row];
[hosterTable noteNumberOfRowsChanged];
[hosterTable reloadData];
return YES;
}
@end