Re: A Quick Look contribution and a question

2011-01-04 Thread Julien Jalon
Look at Apple provided code sample at:

http://developer.apple.com/library/mac/samplecode/QuickLookDownloader/Introduction/Intro.html

-- 
Julien Jalon

On Monday, January 3, 2011, Brad Stone  wrote:
> I'm submitting this code for anyone who needs a quick hack to get Quick Look 
> working.  It's a hack because it's using AppleScript and the Quick Look 
> Server debug and management tool.  If you send an array of paths this will 
> bring them up in a Quick Look window.
>
> I don't think the Quick Look documentation is as robust as it can be, I'm 
> still trying to figure out how to do the same thing the right way.
>
> - (void)quickLook:(NSArray *)srcPathArray {
>
>         //build the paths string
>         NSString *paths = @"";
>         for (NSString *thisPath in srcPathArray) {
>
>                 NSString *s = @"";
>                 if ([paths length] == 0) {
>                         s = [NSString stringWithFormat:@"(quoted form of 
> (POSIX path of \"%...@\"))", thisPath];
>                 } else {
>                         s = [NSString stringWithFormat:@" & \" \" & (quoted 
> form of (POSIX path of \"%...@\"))", thisPath];
>                 }
>                 paths = [paths stringByAppendingString:s];
>         }
>
>
>         NSAppleScript *quickLook = nil;
>         // do shell script ("qlmanage -p " & (quoted form of (POSIX path of 
> srcPath)))
>         NSString *command = [NSString stringWithFormat:@"do shell script 
> (\"qlmanage -p \" & %@)",paths];
>         quickLook = [[NSAppleScript alloc] initWithSource:command];
>         [quickLook executeAndReturnError:nil];
> }___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com
>
> This email sent to jja...@gmail.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: A Quick Look contribution and a question

2011-01-03 Thread Seth Willits
On Jan 3, 2011, at 8:42 AM, Brad Stone wrote:

> I don't think the Quick Look documentation is as robust as it can be, I'm 
> still trying to figure out how to do the same thing the right way. 


Roughly:



@interface MyView : NSView  {
QLPreviewPanel * mQLPreviewPanel;
}



- (IBAction)toggleQuickLook:(id)sender;
{
if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel 
sharedPreviewPanel] isVisible]) {
[[QLPreviewPanel sharedPreviewPanel] orderOut:nil];
} else {
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];
}
}




// Quick Look panel support
// 

- (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel;
{
return YES;
}


- (void)beginPreviewPanelControl:(QLPreviewPanel *)panel;
{
// This view is now responsible of the preview panel
// It is allowed to set the delegate, data source and refresh panel.
mQLPreviewPanel = [panel retain];
panel.delegate = self;
panel.dataSource = self;
}


- (void)endPreviewPanelControl:(QLPreviewPanel *)panel;
{
// This document loses its responsisibility on the preview panel
// Until the next call to -beginPreviewPanelControl: it must not
// change the panel's delegate, data source or refresh it.
[mQLPreviewPanel release];
mQLPreviewPanel = nil;
}




// Quick Look panel data source
// 

- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel;
{
return [self.controller.selectedItems count];
}


- (id )previewPanel:(QLPreviewPanel *)panel 
previewItemAtIndex:(NSInteger)index;
{
return [self.controller.selectedItems objectAtIndex:index];
}




// Quick Look panel delegate
// 

//- (BOOL)previewPanel:(QLPreviewPanel *)panel handleEvent:(NSEvent *)event
//{
//  // redirect all key down events to the view
//  if ([event type] == NSKeyDown) {
//  [self keyDown:event];
//  return YES;
//  }
//  return NO;
//}


// This delegate method provides the rect on screen from which the panel will 
zoom.
- (NSRect)previewPanel:(QLPreviewPanel *)panel 
sourceFrameOnScreenForPreviewItem:(id )item;
{
NSRect boundsInView = ...;
NSRect boundsOnScreen = [self convertRectToBase:boundsInView];

boundsOnScreen.origin = [[self window] 
convertBaseToScreen:boundsOnScreen.origin];

return boundsOnScreen;
}


// This delegate method provides a transition image between the table view and 
the preview panel
- (id)previewPanel:(QLPreviewPanel *)panel transitionImageForPreviewItem:(id 
)item contentRect:(NSRect *)contentRect
{
return [self.controller imageForItems:[NSArray arrayWithObject:item]];
}




--
Seth Willits



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


A Quick Look contribution and a question

2011-01-03 Thread Brad Stone
I'm submitting this code for anyone who needs a quick hack to get Quick Look 
working.  It's a hack because it's using AppleScript and the Quick Look Server 
debug and management tool.  If you send an array of paths this will bring them 
up in a Quick Look window.

I don't think the Quick Look documentation is as robust as it can be, I'm still 
trying to figure out how to do the same thing the right way. 

- (void)quickLook:(NSArray *)srcPathArray {

//build the paths string
NSString *paths = @"";
for (NSString *thisPath in srcPathArray) {

NSString *s = @"";
if ([paths length] == 0) {
s = [NSString stringWithFormat:@"(quoted form of (POSIX 
path of \"%...@\"))", thisPath];
} else {
s = [NSString stringWithFormat:@" & \" \" & (quoted 
form of (POSIX path of \"%...@\"))", thisPath];
}
paths = [paths stringByAppendingString:s];
}


NSAppleScript *quickLook = nil;
// do shell script ("qlmanage -p " & (quoted form of (POSIX path of 
srcPath)))
NSString *command = [NSString stringWithFormat:@"do shell script 
(\"qlmanage -p \" & %@)",paths];
quickLook = [[NSAppleScript alloc] initWithSource:command];
[quickLook executeAndReturnError:nil];
}___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com