Changeset 5885


Ignore:
Timestamp:
May 21, 2008, 6:59:18 PM (14 years ago)
Author:
livings124
Message:

enable/disable the quicklook menu item/toolbar item

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r5878 r5885  
    257257
    258258- (NSArray *) quickLookURLs;
     259- (BOOL) canQuickLook;
    259260- (NSRect) quickLookFrameWithURL: (NSURL*) url;
    260261- (void) toggleQuickLook: (id) sender;
  • trunk/macosx/Controller.m

    r5879 r5885  
    34093409        return YES;
    34103410    }
     3411   
     3412    //enable quicklook item
     3413    if ([ident isEqualToString: TOOLBAR_QUICKLOOK])
     3414        return [[QuickLookController quickLook] canQuickLook];
    34113415
    34123416    return YES;
     
    36043608    if (action == @selector(switchFilter:))
    36053609        return [fWindow isVisible] && ![fFilterBar isHidden];
    3606 
     3610   
     3611    //enable quicklook item
     3612    if (action == @selector(toggleQuickLook:))
     3613        return [[QuickLookController quickLook] canQuickLook];
     3614   
    36073615    //enable reveal in finder
    36083616    if (action == @selector(revealFile:))
     
    40424050    NSArray * selectedTorrents = [fTableView selectedTorrents];
    40434051    NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
    4044    
    40454052    NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
    40464053    Torrent * torrent;
     
    40534060   
    40544061    return urlArray;
     4062}
     4063
     4064- (BOOL) canQuickLook
     4065{
     4066    NSArray * selectedTorrents = [fTableView selectedTorrents];
     4067    NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
     4068    Torrent * torrent;
     4069   
     4070    while ((torrent = [enumerator nextObject]))
     4071    {
     4072        if ([torrent folder] || [torrent isComplete])
     4073            return YES;
     4074    }
     4075   
     4076    return NO;
    40554077}
    40564078
  • trunk/macosx/InfoWindowController.h

    r5872 r5885  
    8181- (BOOL) shouldQuickLookFileView;
    8282- (NSArray *) quickLookURLs;
     83- (BOOL) canQuickLook;
    8384- (NSRect) quickLookFrameWithURL: (NSURL*) url;
    8485
  • trunk/macosx/InfoWindowController.m

    r5873 r5885  
    908908    {
    909909        NSDictionary * item = [fileOutlineView itemAtRow: i];
    910         if ([[item objectForKey: @"IsFolder"] boolValue]
    911             || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
     910        if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
    912911            [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item objectForKey: @"Path"]]]];
    913912    }
    914913   
    915914    return urlArray;
     915}
     916
     917- (BOOL) canQuickLook
     918{
     919    FileOutlineView * fileOutlineView = [fFileController outlineView];
     920    Torrent * torrent = [fTorrents objectAtIndex: 0];
     921    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
     922
     923    int i;
     924    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
     925    {
     926        NSDictionary * item = [fileOutlineView itemAtRow: i];
     927        if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
     928            return YES;
     929    }
     930   
     931    return NO;
    916932}
    917933
  • trunk/macosx/QuickLookController.h

    r5872 r5885  
    4343
    4444- (BOOL) quickLookSelectItems;
     45- (BOOL) canQuickLook;
    4546
    4647- (void) toggleQuickLook;
  • trunk/macosx/QuickLookController.m

    r5884 r5885  
    8282}
    8383
     84- (BOOL) canQuickLook
     85{
     86    if ([fInfoController shouldQuickLookFileView])
     87        return [fInfoController canQuickLook];
     88    else
     89        return [fMainController canQuickLook];
     90}
     91
    8492- (void) toggleQuickLook
    8593{
Note: See TracChangeset for help on using the changeset viewer.