1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

enable/disable the quicklook menu item/toolbar item

This commit is contained in:
Mitchell Livingston 2008-05-21 18:59:18 +00:00
parent f8d72c8708
commit 3bac97b948
6 changed files with 53 additions and 4 deletions

View file

@ -256,6 +256,7 @@ typedef enum
- (void) showMainWindow: (id) sender;
- (NSArray *) quickLookURLs;
- (BOOL) canQuickLook;
- (NSRect) quickLookFrameWithURL: (NSURL*) url;
- (void) toggleQuickLook: (id) sender;

View file

@ -3409,6 +3409,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
return YES;
}
//enable quicklook item
if ([ident isEqualToString: TOOLBAR_QUICKLOOK])
return [[QuickLookController quickLook] canQuickLook];
return YES;
}
@ -3604,6 +3608,10 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
if (action == @selector(switchFilter:))
return [fWindow isVisible] && ![fFilterBar isHidden];
//enable quicklook item
if (action == @selector(toggleQuickLook:))
return [[QuickLookController quickLook] canQuickLook];
//enable reveal in finder
if (action == @selector(revealFile:))
return canUseTable && [fTableView numberOfSelectedRows] > 0;
@ -4041,7 +4049,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
{
NSArray * selectedTorrents = [fTableView selectedTorrents];
NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
Torrent * torrent;
@ -4054,6 +4061,21 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
return urlArray;
}
- (BOOL) canQuickLook
{
NSArray * selectedTorrents = [fTableView selectedTorrents];
NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
{
if ([torrent folder] || [torrent isComplete])
return YES;
}
return NO;
}
- (NSRect) quickLookFrameWithURL: (NSURL *) url
{
if ([fWindow isVisible])

View file

@ -80,6 +80,7 @@
- (BOOL) shouldQuickLookFileView;
- (NSArray *) quickLookURLs;
- (BOOL) canQuickLook;
- (NSRect) quickLookFrameWithURL: (NSURL*) url;
- (void) setPiecesView: (id) sender;

View file

@ -907,14 +907,30 @@ typedef enum
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
{
NSDictionary * item = [fileOutlineView itemAtRow: i];
if ([[item objectForKey: @"IsFolder"] boolValue]
|| [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
[urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item objectForKey: @"Path"]]]];
}
return urlArray;
}
- (BOOL) canQuickLook
{
FileOutlineView * fileOutlineView = [fFileController outlineView];
Torrent * torrent = [fTorrents objectAtIndex: 0];
NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
int i;
for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
{
NSDictionary * item = [fileOutlineView itemAtRow: i];
if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
return YES;
}
return NO;
}
- (NSRect) quickLookFrameWithURL: (NSURL *) url
{
FileOutlineView * fileOutlineView = [fFileController outlineView];

View file

@ -42,6 +42,7 @@
+ (QuickLookController *) quickLook;
- (BOOL) quickLookSelectItems;
- (BOOL) canQuickLook;
- (void) toggleQuickLook;
- (void) updateQuickLook;

View file

@ -81,6 +81,14 @@ QuickLookController * fQuickLookInstance = nil;
return NO;
}
- (BOOL) canQuickLook
{
if ([fInfoController shouldQuickLookFileView])
return [fInfoController canQuickLook];
else
return [fMainController canQuickLook];
}
- (void) toggleQuickLook
{
if (!fQuickLookAvailable)