//
//  AppDelegate.m
//  QCDemo
//
//  Created by Robert Metcalfe on 27/05/13.
//  Copyright (c) 2013 Robert Metcalfe. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window;
@synthesize qcView;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}



- (IBAction)loadComposition:(id)sender {
    void (^handler)(NSInteger);
    
    NSOpenPanel *panel = [NSOpenPanel openPanel];
    
    [panel setAllowedFileTypes:[NSArray arrayWithObjects: @"qtz", nil]];
    
    handler = ^(NSInteger result) {
        if (result == NSFileHandlingPanelOKButton) {
            NSString *filePath = [[[panel URLs] objectAtIndex:0] path];
            if (![qcView loadCompositionFromFile:filePath]) {
                NSLog(@"Could not load composition");
            }
        }
    };
    
    [panel beginSheetModalForWindow:window completionHandler:handler];
    
}
@end
