add QuickLook to the main window (keeping it in the info window as well)

This commit is contained in:
Mitchell Livingston 2008-05-21 15:45:27 +00:00
parent 1f0c5b891c
commit 64e328a741
5 changed files with 59 additions and 22 deletions

View File

@ -255,6 +255,9 @@ typedef enum
- (void) showMainWindow: (id) sender;
- (NSArray *) quickLookURLs;
- (NSRect) quickLookFrameWithURL: (NSURL*) url;
- (void) linkHomepage: (id) sender;
- (void) linkForums: (id) sender;
- (void) linkDonate: (id) sender;

View File

@ -2730,6 +2730,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification
{
[fInfoController setInfoForTorrents: [fTableView selectedTorrents]];
[[QuickLookController quickLook] updateQuickLook];
}
- (NSDragOperation) draggingEntered: (id <NSDraggingInfo>) info
@ -4016,6 +4017,43 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[self updateUI];
}
- (NSArray *) quickLookURLs
{
NSArray * selectedTorrents = [fTableView selectedTorrents];
NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
[urlArray addObject: [NSURL fileURLWithPath: [torrent dataLocation]]];
return urlArray;
}
- (NSRect) quickLookFrameWithURL: (NSURL *) url
{
NSString * fullPath = [url path];
NSRange visibleRows = [fTableView rowsInRect: [fTableView bounds]];
//do in reverse to find torrent before group
int row;
for (row = NSMaxRange(visibleRows) - 1; row >= visibleRows.location; row--)
{
id item = [fTableView itemAtRow: row];
if ([item isKindOfClass: [Torrent class]] && [[(Torrent *)item dataLocation] isEqualToString: fullPath])
{
NSRect frame = [fTableView rectOfRow: row];
frame.origin = [fTableView convertPoint: frame.origin toView: nil];
frame.origin = [fWindow convertBaseToScreen: frame.origin];
frame.origin.y -= frame.size.height;
return frame;
}
}
return NSZeroRect;
}
- (void) linkHomepage: (id) sender
{
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: WEBSITE_URL]];

View File

@ -924,7 +924,7 @@ typedef enum
NSRange visibleRows = [fileOutlineView rowsInRect: [fileOutlineView bounds]];
int row;
for (row = visibleRows.location; row <= row + visibleRows.length; row++)
for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
{
id rowItem = [fileOutlineView itemAtRow: row];
if ([[folder stringByAppendingPathComponent: [rowItem objectForKey: @"Path"]] isEqualToString: fullPath])

View File

@ -68,13 +68,7 @@ QuickLookController * fQuickLookInstance = nil;
if ([fInfoController shouldQuickLookFileView])
return [fInfoController quickLookFrameWithURL: url];
else
{
/*NSRect frame = [fImageView frame];
frame.origin = [[self window] convertBaseToScreen: frame.origin];
return frame;*/
}
return NSZeroRect;
return [fMainController quickLookFrameWithURL: url];
}
- (BOOL) quickLookSelectItems
@ -87,19 +81,7 @@ QuickLookController * fQuickLookInstance = nil;
if ([fInfoController shouldQuickLookFileView])
urlArray = [fInfoController quickLookURLs];
else
{
/*if ([fTorrents count] > 0)
{
urlArray = [NSMutableArray arrayWithCapacity: [fTorrents count]];
NSEnumerator * enumerator = [fTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
if ([torrent folder] || [torrent progress] == 1.0)
[urlArray addObject: [NSURL fileURLWithPath: [torrent dataLocation]]];
}
}*/
}
urlArray = [fMainController quickLookURLs];
if (urlArray && [urlArray count] > 0)
{

View File

@ -25,6 +25,7 @@
#import "TorrentTableView.h"
#import "TorrentCell.h"
#import "Torrent.h"
#import "QuickLookController.h"
#import "NSApplicationAdditions.h"
#define MAX_GROUP (INT_MAX-10)
@ -524,11 +525,24 @@
//option-command-f will focus the filter bar's search field
- (void) keyDown: (NSEvent *) event
{
if ([[event charactersIgnoringModifiers] isEqualToString: @"f"] && [event modifierFlags] & NSAlternateKeyMask
unichar firstChar = [[event charactersIgnoringModifiers] characterAtIndex: 0];
if (firstChar == 'f' && [event modifierFlags] & NSAlternateKeyMask
&& [event modifierFlags] & NSCommandKeyMask)
[fController focusFilterField];
else
{
//handle quicklook
if (firstChar == ' ')
[[QuickLookController quickLook] toggleQuickLook];
else if (firstChar == NSRightArrowFunctionKey)
[[QuickLookController quickLook] pressRight];
else if (firstChar == NSLeftArrowFunctionKey)
[[QuickLookController quickLook] pressLeft];
else;
[super keyDown: event];
}
}
- (void) paste: (id) sender