Ignore:
Timestamp:
Sep 4, 2009, 4:10:46 AM (13 years ago)
Author:
livings124
Message:

draft #1 of #2369 - use public API for QuickLook? on 10.6 (and drop the hack for 10.5-support)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r9016 r9034  
    3434#import "CreatorWindowController.h"
    3535#import "StatsWindowController.h"
    36 #import "QuickLookController.h"
    3736#import "GroupsController.h"
    3837#import "AboutWindowController.h"
     
    294293        [PrefsController setHandle: fLib];
    295294        fPrefsController = [[PrefsController alloc] init];
    296        
    297         [QuickLookController quickLookControllerInitializeWithController: self infoController: fInfoController];
    298295       
    299296        fSoundPlaying = NO;
     
    14771474{
    14781475    [fInfoController setInfoForTorrents: [fTableView selectedTorrents]];
    1479     [[QuickLookController quickLook] updateQuickLook];
     1476   
     1477    if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible])
     1478        [[QLPreviewPanel sharedPreviewPanel] reloadData];
    14801479}
    14811480
     
    33673366        return YES;
    33683367    }
    3369    
    3370     //enable quicklook item
    3371     if ([ident isEqualToString: TOOLBAR_QUICKLOOK])
    3372         return [[QuickLookController quickLook] canQuickLook];
    33733368
    33743369    return YES;
     
    35653560        return [fWindow isVisible] && ![fFilterBar isHidden];
    35663561   
    3567     //enable quicklook item
    3568     if (action == @selector(toggleQuickLook:))
    3569         return [[QuickLookController quickLook] canQuickLook];
    3570    
    35713562    //enable reveal in finder
    35723563    if (action == @selector(revealFile:))
     
    39723963}
    39733964
    3974 - (NSArray *) quickLookURLs
    3975 {
    3976     NSArray * selectedTorrents = [fTableView selectedTorrents];
    3977     NSMutableArray * urlArray = [NSMutableArray arrayWithCapacity: [selectedTorrents count]];
    3978    
    3979     for (Torrent * torrent in selectedTorrents)
    3980         if ([self canQuickLookTorrent: torrent])
    3981             [urlArray addObject: [NSURL fileURLWithPath: [torrent dataLocation]]];
    3982    
    3983     return urlArray;
    3984 }
    3985 
    3986 - (BOOL) canQuickLook
    3987 {
    3988     for (Torrent * torrent in [fTableView selectedTorrents])
    3989         if ([self canQuickLookTorrent: torrent])
    3990             return YES;
    3991    
    3992     return NO;
    3993 }
    3994 
    3995 - (BOOL) canQuickLookTorrent: (Torrent *) torrent
    3996 {
    3997     if (![[NSFileManager defaultManager] fileExistsAtPath: [torrent dataLocation]])
    3998         return NO;
    3999    
    4000     return [torrent isFolder] || [torrent isComplete];
    4001 }
    4002 
    4003 - (NSRect) quickLookFrameWithURL: (NSURL *) url
    4004 {
    4005     if ([fWindow isVisible])
    4006     {
    4007         NSString * fullPath = [url path];
    4008         NSRange visibleRows = [fTableView rowsInRect: [fTableView bounds]];
    4009        
    4010         for (NSInteger row = 0; row < NSMaxRange(visibleRows); row++)
    4011         {
    4012             id item = [fTableView itemAtRow: row];
    4013             if ([item isKindOfClass: [Torrent class]] && [[(Torrent *)item dataLocation] isEqualToString: fullPath])
    4014             {
    4015                 NSRect frame = [fTableView iconRectForRow: row];
    4016                 frame.origin = [fTableView convertPoint: frame.origin toView: nil];
    4017                 frame.origin = [fWindow convertBaseToScreen: frame.origin];
    4018                 frame.origin.y -= frame.size.height;
    4019                 return frame;
    4020             }
    4021         }
    4022     }
    4023    
    4024     return NSZeroRect;
    4025 }
    4026 
    40273965- (void) toggleQuickLook: (id) sender
    40283966{
    4029     [[QuickLookController quickLook] toggleQuickLook];
     3967    if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible])
     3968        [[QLPreviewPanel sharedPreviewPanel] orderOut: nil];
     3969    else
     3970        [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront: nil];
    40303971}
    40313972
Note: See TracChangeset for help on using the changeset viewer.